Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. //calculate til compensation data, user and factory calibration
  2. float rollUF = atan2(Ya_cal, sqrt(Xa_cal * Xa_cal + Za_cal * Za_cal));
  3. float pitchUF = -atan2(Xa_cal, sqrt(Ya_cal * Ya_cal + Za_cal * Za_cal)); //negativ to get tilt compensation working
  4. float heelRawUF = rollUF * 180.0 / M_PI;
  5. float trimRawUF = pitchUF * 180.0 / M_PI;
  6.  
  7. //correct for tilt in unit, user and factory calibration
  8. float XhCalUF = estimated_mx * cos(pitchUF) + estimated_my * sin(rollUF) * sin(pitchUF) + estimated_mz * cos(rollUF) * sin(pitchUF);
  9. float YhCalUF = estimated_my * cos(rollUF) - estimated_mz * sin(rollUF);
  10.  
  11. //Calculation of heading, user and facotry calculation
  12. hdgUF = atan2(YhCalUF, XhCalUF) * 180 / PI;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement