fixed motion command

This commit is contained in:
Ruixiang Du
2021-07-13 18:36:36 +08:00
parent f7224bf56f
commit 3d86c9548c
2 changed files with 19 additions and 7 deletions

View File

@@ -76,8 +76,8 @@ int main(int argc, char **argv) {
while (true) {
// motion control
// if (count < 100) {
// std::cout << "Motor: 0.2, 0" << std::endl;
// scout->SetMotionCommand(0.2, 0.0);
std::cout << "Motor: 0.2, 0" << std::endl;
scout->SetMotionCommand(0.2, 0.0);
// }
// get robot state

View File

@@ -55,12 +55,24 @@ class AgilexBase : public RobotInterface {
if (can_connected_) {
// motion control message
AgxMessage msg;
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;
if (parser_.GetProtocolVersion() == ProtocolVersion::AGX_V1) {
msg.type = AgxMsgMotionCommandV1;
msg.body.v1_motion_command_msg.control_mode = CONTROL_MODE_CAN;
msg.body.v1_motion_command_msg.clear_all_error = false;
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
can_frame frame;
if (parser_.EncodeMessage(&msg, &frame)) can_->SendFrame(frame);