Reset yaw target when drone disarmed

Prevent unexpected behavior when the drone tries to restore its old yaw on takeoff.
This commit is contained in:
Oleg Kalachev
2025-10-07 15:42:11 +03:00
parent bf9eeb90a4
commit 49a0aa7036

View File

@@ -80,7 +80,7 @@ void interpretControls() {
if (mode == STAB) {
float yawTarget = attitudeTarget.getYaw();
if (invalid(yawTarget) || controlYaw != 0) yawTarget = attitude.getYaw(); // reset yaw target if NAN or pilot commands yaw rate
if (!armed || invalid(yawTarget) || controlYaw != 0) yawTarget = attitude.getYaw(); // reset yaw target
attitudeTarget = Quaternion::fromEuler(Vector(controlRoll * tiltMax, controlPitch * tiltMax, yawTarget));
ratesExtra = Vector(0, 0, -controlYaw * maxRate.z); // positive yaw stick means clockwise rotation in FLU
}