mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 02:43:33 +08:00
EKF: Improve accuracy of state prediction
Use an a common estimator value for gravity Use average orientation across update interval when rotating delta velocities
This commit is contained in:
+12
-3
@@ -511,9 +511,18 @@ void Ekf::predictState()
|
||||
// save the previous value of velocity so we can use trapzoidal integration
|
||||
Vector3f vel_last = _state.vel;
|
||||
|
||||
// predict velocity states
|
||||
_state.vel += _R_to_earth * _imu_sample_delayed.delta_vel;
|
||||
_state.vel(2) += 9.81f * _imu_sample_delayed.delta_vel_dt;
|
||||
// calculate the increment in velocity using the previous orientation
|
||||
Vector3f delta_vel_earth_1 = _R_to_earth * _imu_sample_delayed.delta_vel;
|
||||
|
||||
// update the rotation matrix and calculate the increment in velocity using the current orientation
|
||||
_R_to_earth = quat_to_invrotmat(_state.quat_nominal);
|
||||
Vector3f delta_vel_earth_2 = _R_to_earth * _imu_sample_delayed.delta_vel;
|
||||
|
||||
// Update the velocity assuming constant angular rate and acceleration across the same delta time interval
|
||||
_state.vel += (delta_vel_earth_1 + delta_vel_earth_2) * 0.5f;
|
||||
|
||||
// compensate for acceleration due to gravity
|
||||
_state.vel(2) += _gravity_mss * _imu_sample_delayed.delta_vel_dt;
|
||||
|
||||
// predict position states via trapezoidal integration of velocity
|
||||
_state.pos += (vel_last + _state.vel) * _imu_sample_delayed.delta_vel_dt * 0.5f;
|
||||
|
||||
@@ -124,7 +124,8 @@ public:
|
||||
private:
|
||||
|
||||
static const uint8_t _k_num_states = 24;
|
||||
static constexpr float _k_earth_rate = 0.000072921f;
|
||||
const float _k_earth_rate = 0.000072921f;
|
||||
const float _gravity_mss = 9.80665f;
|
||||
|
||||
stateSample _state; // state struct of the ekf running at the delayed time horizon
|
||||
|
||||
|
||||
Reference in New Issue
Block a user