初级会员

- 积分
- 70
- 金钱
- 70
- 注册时间
- 2020-9-10
- 在线时间
- 26 小时
|
1金钱
STM32F103 hal库 pid控制麦克纳姆轮,在一个死循环内 先前进5秒,在停止1秒,为什么在前进5秒后,麦克纳姆轮没停止,反而向后转。
代码:
while(1)
{
forward(&speed_xyr); //前进
cal_mecanum(&speed_xyr,&common_mt_ctrl,motors);//麦克纳姆轮运动学算解
speed_xyr.cal_speed = 0; //复位标志位
Get_cnt(motors); //同步编码器数据
Motor_task(&common_mt_ctrl,motors); //不停调用电机驱动程序以计算、控制电机、内含pid
HAL_Delay(3000);
stop(&speed_xyr); //停止
cal_mecanum(&speed_xyr,&common_mt_ctrl,motors);//麦克纳姆轮运动学算解
speed_xyr.cal_speed = 0; //复位标志位
Get_cnt(motors); //同步编码器数据
Motor_task(&common_mt_ctrl,motors); //不停调用电机驱动程序以计算、控制电机、内含pid
HAL_Delay(1000);
}
|
|