mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 09:28:31 -04:00
AP_NavEKF: prevent a possible numerical error on startup
fixes issue #1294
This commit is contained in:
parent
e22ab50b16
commit
3ee3a71644
@ -511,13 +511,16 @@ void NavEKF::InitialiseFilterBootstrap(void)
|
||||
readMagData();
|
||||
|
||||
// normalise the acceleration vector
|
||||
initAccVec.normalize();
|
||||
float pitch=0, roll=0;
|
||||
if (initAccVec.length() > 0.001f) {
|
||||
initAccVec.normalize();
|
||||
|
||||
// calculate initial pitch angle
|
||||
float pitch = asinf(initAccVec.x);
|
||||
// calculate initial pitch angle
|
||||
pitch = asinf(initAccVec.x);
|
||||
|
||||
// calculate initial roll angle
|
||||
float roll = -asinf(initAccVec.y / cosf(pitch));
|
||||
// calculate initial roll angle
|
||||
roll = -asinf(initAccVec.y / cosf(pitch));
|
||||
}
|
||||
|
||||
// calculate initial orientation and earth magnetic field states
|
||||
Quaternion initQuat;
|
||||
|
Loading…
Reference in New Issue
Block a user