Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //calculate til compensation data, user and factory calibration
- float rollUF = atan2(Ya_cal, sqrt(Xa_cal * Xa_cal + Za_cal * Za_cal));
- float pitchUF = -atan2(Xa_cal, sqrt(Ya_cal * Ya_cal + Za_cal * Za_cal)); //negativ to get tilt compensation working
- float heelRawUF = rollUF * 180.0 / M_PI;
- float trimRawUF = pitchUF * 180.0 / M_PI;
- //correct for tilt in unit, user and factory calibration
- float XhCalUF = estimated_mx * cos(pitchUF) + estimated_my * sin(rollUF) * sin(pitchUF) + estimated_mz * cos(rollUF) * sin(pitchUF);
- float YhCalUF = estimated_my * cos(rollUF) - estimated_mz * sin(rollUF);
- //Calculation of heading, user and facotry calculation
- hdgUF = atan2(YhCalUF, XhCalUF) * 180 / PI;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement