fix位移控制
This commit is contained in:
parent
b6c6522a63
commit
0f4dfbd61d
@ -1041,10 +1041,16 @@ int8_t Chassis_LQRControl(Chassis_t *c, const Chassis_CMD_t *c_cmd) {
|
||||
float world_vy = c_cmd->move_vec.vy * c->param->rotor_ctrl.max_trans_speed;
|
||||
c->chassis_state.target_velocity_x = -world_vx * sinf(gimbal_offset) + world_vy * cosf(gimbal_offset);
|
||||
c->chassis_state.last_target_velocity_x = c->chassis_state.target_velocity_x;
|
||||
c->chassis_state.target_x += c->chassis_state.target_velocity_x * c->dt;
|
||||
} else {
|
||||
c->chassis_state.target_velocity_x = c_cmd->move_vec.vx * 2.0f;
|
||||
c->chassis_state.last_target_velocity_x = c->chassis_state.target_velocity_x;
|
||||
}
|
||||
|
||||
/* 有速度指令时:纯速度控制,目标位移跟随当前位移(消除位移误差)
|
||||
* 无速度指令时:位移+速度双环控制,积分保持位置锁定 */
|
||||
if (fabsf(c->chassis_state.target_velocity_x) > 0.01f) {
|
||||
c->chassis_state.target_x = c->chassis_state.position_x;
|
||||
} else {
|
||||
c->chassis_state.target_x += c->chassis_state.target_velocity_x * c->dt;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user