diff --git a/src/modules/ekf2/EKF/common.h b/src/modules/ekf2/EKF/common.h index ad052f33d4..d6bb2ad52b 100644 --- a/src/modules/ekf2/EKF/common.h +++ b/src/modules/ekf2/EKF/common.h @@ -134,7 +134,7 @@ enum class ImuCtrl : uint8_t { GravityVector = (1<<2), }; -enum GnssCtrl : uint8_t { +enum class GnssCtrl : uint8_t { HPOS = (1<<0), VPOS = (1<<1), VEL = (1<<2), @@ -325,7 +325,7 @@ struct parameters { #endif // CONFIG_EKF2_BAROMETER #if defined(CONFIG_EKF2_GNSS) - int32_t gnss_ctrl{GnssCtrl::HPOS | GnssCtrl::VEL}; + int32_t gnss_ctrl{static_cast(GnssCtrl::HPOS) | static_cast(GnssCtrl::VEL)}; float gps_delay_ms{110.0f}; ///< GPS measurement delay relative to the IMU (mSec) Vector3f gps_pos_body{}; ///< xyz position of the GPS antenna in body frame (m) diff --git a/src/modules/ekf2/EKF/gnss_height_control.cpp b/src/modules/ekf2/EKF/gnss_height_control.cpp index 430fe175c7..600ba08876 100644 --- a/src/modules/ekf2/EKF/gnss_height_control.cpp +++ b/src/modules/ekf2/EKF/gnss_height_control.cpp @@ -86,7 +86,7 @@ void Ekf::controlGnssHeightFusion(const gpsSample &gps_sample) } // determine if we should use height aiding - const bool continuing_conditions_passing = (_params.gnss_ctrl & GnssCtrl::VPOS) + const bool continuing_conditions_passing = (_params.gnss_ctrl & static_cast(GnssCtrl::VPOS)) && measurement_valid && _NED_origin_initialised && _gps_checks_passed; @@ -113,7 +113,7 @@ void Ekf::controlGnssHeightFusion(const gpsSample &gps_sample) bias_est.setBias(_state.pos(2) + measurement); // reset vertical velocity - if (PX4_ISFINITE(gps_sample.vel(2)) && (_params.gnss_ctrl & GnssCtrl::VEL)) { + if (PX4_ISFINITE(gps_sample.vel(2)) && (_params.gnss_ctrl & static_cast(GnssCtrl::VEL))) { // use 1.5 as a typical ratio of vacc/hacc resetVerticalVelocityTo(gps_sample.vel(2), sq(math::max(1.5f * gps_sample.sacc, _params.gps_vel_noise))); diff --git a/src/modules/ekf2/EKF/gps_control.cpp b/src/modules/ekf2/EKF/gps_control.cpp index 4e1afc5ff8..6e8d3892aa 100644 --- a/src/modules/ekf2/EKF/gps_control.cpp +++ b/src/modules/ekf2/EKF/gps_control.cpp @@ -99,7 +99,7 @@ void Ekf::controlGpsFusion(const imuSample &imu_delayed) vel_obs_var, // observation variance math::max(_params.gps_vel_innov_gate, 1.f), // innovation gate _aid_src_gnss_vel); - const bool gnss_vel_enabled = (_params.gnss_ctrl & GnssCtrl::VEL); + const bool gnss_vel_enabled = (_params.gnss_ctrl & static_cast(GnssCtrl::VEL)); // GNSS position const Vector2f position{gps_sample.pos}; @@ -121,7 +121,7 @@ void Ekf::controlGpsFusion(const imuSample &imu_delayed) pos_obs_var, // observation variance math::max(_params.gps_pos_innov_gate, 1.f), // innovation gate _aid_src_gnss_pos); - const bool gnss_pos_enabled = (_params.gnss_ctrl & GnssCtrl::HPOS); + const bool gnss_pos_enabled = (_params.gnss_ctrl & static_cast(GnssCtrl::HPOS)); // Determine if we should use GPS aiding for velocity and horizontal position // To start using GPS we need angular alignment completed, the local NED origin set and GPS data that has not failed checks recently @@ -310,7 +310,7 @@ bool Ekf::shouldResetGpsFusion() const #if defined(CONFIG_EKF2_GNSS_YAW) void Ekf::controlGpsYawFusion(const gpsSample &gps_sample, bool gps_checks_passing, bool gps_checks_failing) { - if (!(_params.gnss_ctrl & GnssCtrl::YAW) + if (!(_params.gnss_ctrl & static_cast(GnssCtrl::YAW)) || _control_status.flags.gps_yaw_fault) { stopGpsYawFusion(); diff --git a/src/modules/ekf2/test/sensor_simulator/ekf_wrapper.cpp b/src/modules/ekf2/test/sensor_simulator/ekf_wrapper.cpp index 596d087cf3..73a6c2b8e1 100644 --- a/src/modules/ekf2/test/sensor_simulator/ekf_wrapper.cpp +++ b/src/modules/ekf2/test/sensor_simulator/ekf_wrapper.cpp @@ -37,12 +37,12 @@ void EkfWrapper::setGpsHeightRef() void EkfWrapper::enableGpsHeightFusion() { - _ekf_params->gnss_ctrl |= GnssCtrl::VPOS; + _ekf_params->gnss_ctrl |= static_cast(GnssCtrl::VPOS); } void EkfWrapper::disableGpsHeightFusion() { - _ekf_params->gnss_ctrl &= ~GnssCtrl::VPOS; + _ekf_params->gnss_ctrl &= ~static_cast(GnssCtrl::VPOS); } bool EkfWrapper::isIntendingGpsHeightFusion() const @@ -102,12 +102,12 @@ bool EkfWrapper::isIntendingBetaFusion() const void EkfWrapper::enableGpsFusion() { - _ekf_params->gnss_ctrl |= GnssCtrl::HPOS | GnssCtrl::VEL; + _ekf_params->gnss_ctrl |= static_cast(GnssCtrl::HPOS) | static_cast(GnssCtrl::VEL); } void EkfWrapper::disableGpsFusion() { - _ekf_params->gnss_ctrl &= ~(GnssCtrl::HPOS | GnssCtrl::VEL); + _ekf_params->gnss_ctrl &= ~(static_cast(GnssCtrl::HPOS) | static_cast(GnssCtrl::VEL)); } bool EkfWrapper::isIntendingGpsFusion() const @@ -117,12 +117,12 @@ bool EkfWrapper::isIntendingGpsFusion() const void EkfWrapper::enableGpsHeadingFusion() { - _ekf_params->gnss_ctrl |= GnssCtrl::YAW; + _ekf_params->gnss_ctrl |= static_cast(GnssCtrl::YAW); } void EkfWrapper::disableGpsHeadingFusion() { - _ekf_params->gnss_ctrl &= ~GnssCtrl::YAW; + _ekf_params->gnss_ctrl &= ~static_cast(GnssCtrl::YAW); } bool EkfWrapper::isIntendingGpsHeadingFusion() const