Skip to content
Snippets Groups Projects
Commit a193cbb8 authored by rmackay9's avatar rmackay9
Browse files

AP_InertialNav: Jason's bug fix to inertial nav velocity and position calculations

parent ee50e637
No related branches found
No related tags found
No related merge requests found
...@@ -55,6 +55,7 @@ void AP_InertialNav::update(float dt) ...@@ -55,6 +55,7 @@ void AP_InertialNav::update(float dt)
{ {
Vector3f acc_corr = accel_correction.get(); Vector3f acc_corr = accel_correction.get();
Vector3f accel_ef; Vector3f accel_ef;
Vector3f velocity_increase;
// discard samples where dt is too large // discard samples where dt is too large
if( dt > 0.1 ) { if( dt > 0.1 ) {
...@@ -84,11 +85,14 @@ void AP_InertialNav::update(float dt) ...@@ -84,11 +85,14 @@ void AP_InertialNav::update(float dt)
// get earth frame accelerometer correction // get earth frame accelerometer correction
accel_correction_ef = dcm * acc_corr; accel_correction_ef = dcm * acc_corr;
// calculate velocity by adding new acceleration from accelerometers // calculate velocity increase adding new acceleration from accelerometers
_velocity += (-accel_ef + accel_correction_ef) * dt; velocity_increase = (-accel_ef + accel_correction_ef) * dt;
// calculate new estimate of position // calculate new estimate of position
_position_base += _velocity * dt; _position_base += (_velocity + velocity_increase*0.5) * dt;
// calculate new velocity
_velocity += velocity_increase;
// store 3rd order estimate (i.e. estimated vertical position) for future use // store 3rd order estimate (i.e. estimated vertical position) for future use
_hist_position_estimate_z.add(_position_base.z); _hist_position_estimate_z.add(_position_base.z);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment