You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some more tracker testing and tuning. Using a west magnetic declination of -1556 causes an overflow of the tracker heading at approx 350 degrees. Version 11.1.0 on SPRacing hardware.
flight / imu.c file
function int16_t imuCalculateHeading(t_fp_vector *vec)
For bearings close to North (example -10) the calculation results in a int16_t overflow/underflow
return (int16_t) ((hd * 1800.0 / M_PIf) + magneticDeclination + OFFSET * 10.0f)%3600;
This same issue can be replicated using negative offsets. For example: magneticDeclination +10degrees (E), OFFSET -15degrees
The text was updated successfully, but these errors were encountered:
AlexC176
changed the title
Magnetic declination West (negative value) cause incorrect heading calculation
Magnetic declination West (negative value) causes incorrect heading calculation
Jun 4, 2022
Some more tracker testing and tuning. Using a west magnetic declination of -1556 causes an overflow of the tracker heading at approx 350 degrees. Version 11.1.0 on SPRacing hardware.
flight / imu.c file
function int16_t imuCalculateHeading(t_fp_vector *vec)
For bearings close to North (example -10) the calculation results in a int16_t overflow/underflow
return (int16_t) ((hd * 1800.0 / M_PIf) + magneticDeclination + OFFSET * 10.0f)%3600;
Suggest
float truehd = ((hd * 1800.0 / M_PIf) + magneticDeclination + OFFSET * 10.0f);
// always positive
if ( truehd < 0.0f ) { truehd = truehd + 3600.0f; )
return (int16_t) truehd%3600;
This same issue can be replicated using negative offsets. For example: magneticDeclination +10degrees (E), OFFSET -15degrees
The text was updated successfully, but these errors were encountered: