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) {
|
||||
// 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
|
||||
|
||||
@@ -55,11 +55,23 @@ 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;
|
||||
|
||||
Reference in New Issue
Block a user