mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-24 07:09:48 +08:00
mc_att_control_main: separate yaw rate setpoint generation from absolute yaw reset
This commit is contained in:
committed by
Silvan Fuhrer
parent
ce5cff55b7
commit
2b0f7879bc
@@ -112,15 +112,19 @@ MulticopterAttitudeControl::generate_attitude_setpoint(const Quatf &q, float dt,
|
||||
vehicle_attitude_setpoint_s attitude_setpoint{};
|
||||
const float yaw = Eulerf(q).psi();
|
||||
|
||||
/* reset yaw setpoint to current position if needed */
|
||||
// Avoid giving yaw rate setpoint with arming stick gesture
|
||||
if ((_manual_control_setpoint.throttle > -.9f) || (_param_mc_airmode.get() == 2)) {
|
||||
attitude_setpoint.yaw_sp_move_rate = _manual_control_setpoint.yaw * math::radians(_param_mpc_man_y_max.get());
|
||||
|
||||
} else {
|
||||
attitude_setpoint.yaw_sp_move_rate = 0.f;
|
||||
}
|
||||
|
||||
// Make sure not absolute heading error builds up
|
||||
if (reset_yaw_sp) {
|
||||
_man_yaw_sp = yaw;
|
||||
|
||||
} else if ((_manual_control_setpoint.throttle > -.9f)
|
||||
|| (_param_mc_airmode.get() == 2)) {
|
||||
|
||||
const float yaw_rate = math::radians(_param_mpc_man_y_max.get());
|
||||
attitude_setpoint.yaw_sp_move_rate = _manual_control_setpoint.yaw * yaw_rate;
|
||||
} else {
|
||||
_man_yaw_sp = wrap_pi(_man_yaw_sp + attitude_setpoint.yaw_sp_move_rate * dt);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user