void CustomRobotControl motiontime += 1; s = motiontime; udpGetRecvstate; printfd fn motiontime stateimuquaternion2; cmdmode = 0; 0idle default stand 1forced stand 2walk continuous
To make the robot walk straight, you can adjust the cmd.velocity[1] parameter to be 0. This will make the robot move only in the x-axis direction and not in the y-axis direction. The modified code for the RobotControl function is shown below:
void Custom::RobotControl() { motiontime += 1; s = motiontime; udp.GetRecv(state);
cmd.mode = 0; // 0:idle, default stand 1:forced stand 2:walk continuously cmd.gaitType = 0; cmd.speedLevel = 0; cmd.footRaiseHeight = 0; cmd.bodyHeight = 0; cmd.euler[0] = 0; cmd.euler[1] = 0; cmd.euler[2] = 0; cmd.velocity[0] = 0.3f; cmd.velocity[1] = 0.0f; // Set y-axis velocity to 0 cmd.yawSpeed = 0.0f; cmd.reserve = 0;
if (s % 2000 < 1000){ cmd.mode = 2; cmd.gaitType = 2; cmd.yawSpeed = 0.01f; cmd.footRaiseHeight = 0.01; std::cout << 0 << std::endl; } else{ cmd.mode = 2; cmd.gaitType = 2; cmd.yawSpeed = -0.01f; cmd.footRaiseHeight = 0.01; std::cout<<1<<std::endl; }
std::cout << motiontime << std::endl; udp.SetSend(cmd);
原文地址: https://www.cveoy.top/t/topic/g2BO 著作权归作者所有。请勿转载和采集!