Skip to content

Fix yaw positive feedback #31

@lobodol

Description

@lobodol

File: drone-flight-controller.ino
Line: 253

Problem

angular_motions[YAW] uses +gyro_raw[Z], while measures[YAW] uses -gyro_raw[Z].
They represent the same physical quantity with opposite signs.

The PID error is computed from angular_motions[YAW]. Since the yaw set point is positive for a rightward rotation, but angular_motions[YAW] is negative for the same rotation, the error grows larger as the drone approaches the desired yaw rate — positive feedback.
The drone will spin uncontrollably.

Fix

// Before
angular_motions[YAW] = 0.7 * angular_motions[YAW] + 0.3 * gyro_raw[Z] / SSF_GYRO;

// After
angular_motions[YAW] = 0.7 * angular_motions[YAW] - 0.3 * gyro_raw[Z] / SSF_GYRO;

Verification

With throttle low and yaw stick pushed right, the drone should rotate clockwise (nose right) at a speed proportional to stick deflection, and stop rotating when the stick returns to center.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions