From 8a955fc5aaa52639721f13372287afee69d4b8af Mon Sep 17 00:00:00 2001 From: bresch Date: Tue, 5 Dec 2023 12:04:59 +0100 Subject: [PATCH] ekf2-pos bias estimator: use enum --- src/modules/ekf2/EKF/ekf.h | 4 ++-- src/modules/ekf2/EKF/position_bias_estimator.hpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/ekf2/EKF/ekf.h b/src/modules/ekf2/EKF/ekf.h index b5af4f523b62..9460e9bff318 100644 --- a/src/modules/ekf2/EKF/ekf.h +++ b/src/modules/ekf2/EKF/ekf.h @@ -1140,11 +1140,11 @@ class Ekf final : public EstimatorInterface void resetQuatStateYaw(float yaw, float yaw_variance); HeightSensor _height_sensor_ref{HeightSensor::UNKNOWN}; - uint8_t _position_sensor_ref{static_cast(PositionSensor::GNSS)}; + PositionSensor _position_sensor_ref{PositionSensor::GNSS}; #if defined(CONFIG_EKF2_EXTERNAL_VISION) HeightBiasEstimator _ev_hgt_b_est{HeightSensor::EV, _height_sensor_ref}; - PositionBiasEstimator _ev_pos_b_est{static_cast(PositionSensor::EV), _position_sensor_ref}; + PositionBiasEstimator _ev_pos_b_est{PositionSensor::EV, _position_sensor_ref}; AlphaFilter _ev_q_error_filt{0.001f}; bool _ev_q_error_initialized{false}; #endif // CONFIG_EKF2_EXTERNAL_VISION diff --git a/src/modules/ekf2/EKF/position_bias_estimator.hpp b/src/modules/ekf2/EKF/position_bias_estimator.hpp index 0e997e2d2851..0cba8fcd996b 100644 --- a/src/modules/ekf2/EKF/position_bias_estimator.hpp +++ b/src/modules/ekf2/EKF/position_bias_estimator.hpp @@ -39,11 +39,12 @@ #define EKF_POSITION_BIAS_ESTIMATOR_HPP #include "bias_estimator.hpp" +#include "common.h" class PositionBiasEstimator { public: - PositionBiasEstimator(uint8_t sensor, const uint8_t &sensor_ref): + PositionBiasEstimator(PositionSensor sensor, const PositionSensor &sensor_ref): _sensor(sensor), _sensor_ref(sensor_ref) {} @@ -107,8 +108,8 @@ class PositionBiasEstimator private: BiasEstimator _bias[2] {}; - const uint8_t _sensor; - const uint8_t &_sensor_ref; + const PositionSensor _sensor; + const PositionSensor &_sensor_ref; bool _is_sensor_fusion_active{false}; // TODO: replace by const ref and remove setter when migrating _control_status.flags from union to bool };