Skip to content

Commit

Permalink
Rename yawRotation to fakeToRealYawOffset
Browse files Browse the repository at this point in the history
Also, add a small comment explaining the logic behind the home
yaw adjustment.
  • Loading branch information
fiam committed May 22, 2018
1 parent 200a85a commit d624f65
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/navigation/navigation.c
Original file line number Diff line number Diff line change
Expand Up @@ -1505,8 +1505,12 @@ void updateActualHeading(bool headingValid, int32_t newHeading)
(posControl.homeFlags & (NAV_HOME_VALID_XY | NAV_HOME_VALID_Z)) &&
(posControl.homeFlags & NAV_HOME_VALID_HEADING) == 0) {

int32_t yawRotation = newHeading - posControl.actualState.yaw;
posControl.homePosition.yaw += yawRotation;
// Home was stored using the fake heading (assuming boot as 0deg). Calculate
// the offset from the fake to the actual yaw and apply the same rotation
// to the home point.
int32_t fakeToRealYawOffset = newHeading - posControl.actualState.yaw;

posControl.homePosition.yaw += fakeToRealYawOffset;
if (posControl.homePosition.yaw < 0) {
posControl.homePosition.yaw += DEGREES_TO_CENTIDEGREES(360);
}
Expand Down

0 comments on commit d624f65

Please sign in to comment.