Skip to content

Commit

Permalink
Fix yaw inversion with rcCommmand[YAW] (#63)
Browse files Browse the repository at this point in the history
Yaw inversion was done before rcCommand calculation,
making rcCommand[YAW] reversed. This caused reversed
yaw direction in stick commands and OSD/CMS control.

Now yaw is reversed in setpoint calculation, so that
rcInput, rcCommand and rcDeflection all have the same
yaw direction, while setpoint and gyro are reversed.
  • Loading branch information
pmattila committed Dec 1, 2023
1 parent 5c9df9f commit 1395bf6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/main/fc/rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ void updateRcCommands(void)
// Center point
data = rcInput[axis] - rcControlsConfig()->rc_center;

// RC yaw rate and gyro yaw rate have opposite signs
if (axis == FD_YAW)
data = -data;

// Apply deadband
data = fapplyDeadband(data, rcDeadband[axis]);
range = rcControlsConfig()->rc_deflection - rcDeadband[axis];
Expand Down
8 changes: 7 additions & 1 deletion src/main/flight/setpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,13 @@ void setpointUpdate(void)
DEBUG_AXIS(SETPOINT, FD_PITCH, 1, sp.deflection[FD_PITCH] * 1000);

for (int axis = 0; axis < 4; axis++) {
float SP = sp.limited[axis] = slewLimit(sp.limited[axis], sp.deflection[axis], sp.accelLimit[axis]);
float SP = sp.deflection[axis];

// rcCommand[YAW] CW direction is positive, while gyro[YAW] is negative
if (axis == FD_YAW)
SP = -SP;

SP = sp.limited[axis] = slewLimit(sp.limited[axis], SP, sp.accelLimit[axis]);
DEBUG_AXIS(SETPOINT, axis, 2, SP * 1000);

SP = sp.deflection[axis] = filterApply(&sp.filter[axis], SP);
Expand Down

0 comments on commit 1395bf6

Please sign in to comment.