1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-20 14:55:18 +03:00

Rename yawRotation to fakeToRealYawOffset

Also, add a small comment explaining the logic behind the home
yaw adjustment.
This commit is contained in:
Alberto García Hierro 2018-05-22 11:05:00 +01:00
parent 200a85a2ca
commit d624f65b20

View file

@ -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);
}