mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
fixed motion command
This commit is contained in:
@@ -76,8 +76,8 @@ int main(int argc, char **argv) {
|
|||||||
while (true) {
|
while (true) {
|
||||||
// motion control
|
// motion control
|
||||||
// if (count < 100) {
|
// if (count < 100) {
|
||||||
// std::cout << "Motor: 0.2, 0" << std::endl;
|
std::cout << "Motor: 0.2, 0" << std::endl;
|
||||||
// scout->SetMotionCommand(0.2, 0.0);
|
scout->SetMotionCommand(0.2, 0.0);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// get robot state
|
// get robot state
|
||||||
|
|||||||
@@ -55,12 +55,24 @@ class AgilexBase : public RobotInterface {
|
|||||||
if (can_connected_) {
|
if (can_connected_) {
|
||||||
// motion control message
|
// motion control message
|
||||||
AgxMessage msg;
|
AgxMessage msg;
|
||||||
msg.type = AgxMsgMotionCommand;
|
if (parser_.GetProtocolVersion() == ProtocolVersion::AGX_V1) {
|
||||||
msg.body.motion_command_msg.linear_velocity = linear_vel;
|
msg.type = AgxMsgMotionCommandV1;
|
||||||
msg.body.motion_command_msg.angular_velocity = angular_vel;
|
msg.body.v1_motion_command_msg.control_mode = CONTROL_MODE_CAN;
|
||||||
msg.body.motion_command_msg.lateral_velocity = lateral_velocity;
|
msg.body.v1_motion_command_msg.clear_all_error = false;
|
||||||
msg.body.motion_command_msg.steering_angle = steering_angle;
|
msg.body.v1_motion_command_msg.linear = linear_vel;
|
||||||
|
msg.body.v1_motion_command_msg.angular = angular_vel;
|
||||||
|
msg.body.v1_motion_command_msg.lateral = lateral_velocity;
|
||||||
|
} else if (parser_.GetProtocolVersion() == ProtocolVersion::AGX_V2) {
|
||||||
|
msg.type = AgxMsgMotionCommand;
|
||||||
|
msg.body.motion_command_msg.linear_velocity = linear_vel;
|
||||||
|
msg.body.motion_command_msg.angular_velocity = angular_vel;
|
||||||
|
msg.body.motion_command_msg.lateral_velocity = lateral_velocity;
|
||||||
|
msg.body.motion_command_msg.steering_angle = steering_angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "sending motion cmd: " << linear_vel << "," << angular_vel
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
// send to can bus
|
// send to can bus
|
||||||
can_frame frame;
|
can_frame frame;
|
||||||
if (parser_.EncodeMessage(&msg, &frame)) can_->SendFrame(frame);
|
if (parser_.EncodeMessage(&msg, &frame)) can_->SendFrame(frame);
|
||||||
|
|||||||
Reference in New Issue
Block a user