Skip to content

Commit

Permalink
ekf: fix earth spin rate initialisation when starting at 0;0
Browse files Browse the repository at this point in the history
  • Loading branch information
bresch committed Nov 21, 2024
1 parent 09488d9 commit 71e772b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/modules/ekf2/EKF/ekf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ bool Ekf::initialiseTilt()

void Ekf::predictState(const imuSample &imu_delayed)
{
if (std::fabs(_gpos.latitude_rad() - _earth_rate_lat_ref_rad) > math::radians(1.0)) {
if (!PX4_ISFINITE(_earth_rate_lat_ref_rad)
|| std::fabs(_gpos.latitude_rad() - _earth_rate_lat_ref_rad) > math::radians(1.0)) {
_earth_rate_lat_ref_rad = _gpos.latitude_rad();
_earth_rate_NED = calcEarthRateNED((float)_earth_rate_lat_ref_rad);
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/ekf2/EKF/ekf.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,8 @@ class Ekf final : public EstimatorInterface

LatLonAlt _last_known_gpos{};

Vector3f _earth_rate_NED{}; ///< earth rotation vector (NED) in rad/s
double _earth_rate_lat_ref_rad; ///< latitude at which the earth rate was evaluated (radians)
Vector3f _earth_rate_NED{CONSTANTS_EARTH_SPIN_RATE, 0.f, 0.f}; ///< earth rotation vector (NED) in rad/s
double _earth_rate_lat_ref_rad{0.0}; ///< latitude at which the earth rate was evaluated (radians)

Dcmf _R_to_earth{}; ///< transformation matrix from body frame to earth frame from last EKF prediction

Expand Down

0 comments on commit 71e772b

Please sign in to comment.