mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 07:23:34 +08:00
ekf2: scope HeightSensor enum
This commit is contained in:
@@ -155,7 +155,7 @@ void Ekf::controlBaroHeightFusion()
|
||||
|
||||
} else {
|
||||
if (starting_conditions_passing) {
|
||||
if (_params.height_sensor_ref == HeightSensor::BARO) {
|
||||
if (_params.height_sensor_ref == static_cast<int32_t>(HeightSensor::BARO)) {
|
||||
ECL_INFO("starting %s height fusion, resetting height", HGT_SRC_NAME);
|
||||
_height_sensor_ref = HeightSensor::BARO;
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ enum TerrainFusionMask : uint8_t {
|
||||
};
|
||||
#endif // CONFIG_EKF2_TERRAIN
|
||||
|
||||
enum HeightSensor : uint8_t {
|
||||
enum class HeightSensor : uint8_t {
|
||||
BARO = 0,
|
||||
GNSS = 1,
|
||||
RANGE = 2,
|
||||
@@ -277,7 +277,7 @@ struct parameters {
|
||||
int32_t imu_ctrl{static_cast<int32_t>(ImuCtrl::GyroBias) | static_cast<int32_t>(ImuCtrl::AccelBias)};
|
||||
|
||||
// measurement source control
|
||||
int32_t height_sensor_ref{HeightSensor::BARO};
|
||||
int32_t height_sensor_ref{static_cast<int32_t>(HeightSensor::BARO)};
|
||||
int32_t position_sensor_ref{static_cast<int32_t>(PositionSensor::GNSS)};
|
||||
|
||||
int32_t sensor_interval_max_ms{10}; ///< maximum time of arrival difference between non IMU sensor updates. Sets the size of the observation buffers. (mSec)
|
||||
|
||||
@@ -407,7 +407,7 @@ public:
|
||||
|
||||
float getYawVar() const;
|
||||
|
||||
uint8_t getHeightSensorRef() const { return _height_sensor_ref; }
|
||||
HeightSensor getHeightSensorRef() const { return _height_sensor_ref; }
|
||||
|
||||
#if defined(CONFIG_EKF2_AIRSPEED)
|
||||
const auto &aid_src_airspeed() const { return _aid_src_airspeed; }
|
||||
@@ -1139,7 +1139,7 @@ private:
|
||||
// yaw_variance : yaw error variance (rad^2)
|
||||
void resetQuatStateYaw(float yaw, float yaw_variance);
|
||||
|
||||
uint8_t _height_sensor_ref{HeightSensor::UNKNOWN};
|
||||
HeightSensor _height_sensor_ref{HeightSensor::UNKNOWN};
|
||||
uint8_t _position_sensor_ref{static_cast<uint8_t>(PositionSensor::GNSS)};
|
||||
|
||||
#if defined(CONFIG_EKF2_EXTERNAL_VISION)
|
||||
|
||||
@@ -191,7 +191,7 @@ void Ekf::controlEvHeightFusion(const extVisionSample &ev_sample, const bool com
|
||||
} else {
|
||||
if (starting_conditions_passing) {
|
||||
// activate fusion, only reset if necessary
|
||||
if (_params.height_sensor_ref == HeightSensor::EV) {
|
||||
if (_params.height_sensor_ref == static_cast<int32_t>(HeightSensor::EV)) {
|
||||
ECL_INFO("starting %s fusion, resetting state", AID_SRC_NAME);
|
||||
_information_events.flags.reset_hgt_to_ev = true;
|
||||
resetVerticalPositionTo(measurement, measurement_var);
|
||||
|
||||
@@ -136,7 +136,7 @@ void Ekf::controlGnssHeightFusion(const gpsSample &gps_sample)
|
||||
|
||||
} else {
|
||||
if (starting_conditions_passing) {
|
||||
if (_params.height_sensor_ref == HeightSensor::GNSS) {
|
||||
if (_params.height_sensor_ref == static_cast<int32_t>(HeightSensor::GNSS)) {
|
||||
ECL_INFO("starting %s height fusion, resetting height", HGT_SRC_NAME);
|
||||
_height_sensor_ref = HeightSensor::GNSS;
|
||||
|
||||
|
||||
@@ -39,11 +39,12 @@
|
||||
#define EKF_HEIGHT_BIAS_ESTIMATOR_HPP
|
||||
|
||||
#include "bias_estimator.hpp"
|
||||
#include "common.h"
|
||||
|
||||
class HeightBiasEstimator: public BiasEstimator
|
||||
{
|
||||
public:
|
||||
HeightBiasEstimator(uint8_t sensor, const uint8_t &sensor_ref):
|
||||
HeightBiasEstimator(HeightSensor sensor, const HeightSensor &sensor_ref):
|
||||
BiasEstimator(0.f, 0.f),
|
||||
_sensor(sensor),
|
||||
_sensor_ref(sensor_ref)
|
||||
@@ -68,8 +69,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const uint8_t _sensor;
|
||||
const uint8_t &_sensor_ref;
|
||||
const HeightSensor _sensor;
|
||||
const HeightSensor &_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
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ void Ekf::checkHeightSensorRefFallback()
|
||||
|
||||
HeightSensor fallback_list[4];
|
||||
|
||||
switch (_params.height_sensor_ref) {
|
||||
switch (static_cast<HeightSensor>(_params.height_sensor_ref)) {
|
||||
default:
|
||||
|
||||
/* FALLTHROUGH */
|
||||
|
||||
@@ -12,7 +12,7 @@ EkfWrapper::~EkfWrapper()
|
||||
|
||||
void EkfWrapper::setBaroHeightRef()
|
||||
{
|
||||
_ekf_params->height_sensor_ref = HeightSensor::BARO;
|
||||
_ekf_params->height_sensor_ref = static_cast<int32_t>(HeightSensor::BARO);
|
||||
}
|
||||
|
||||
void EkfWrapper::enableBaroHeightFusion()
|
||||
@@ -32,7 +32,7 @@ bool EkfWrapper::isIntendingBaroHeightFusion() const
|
||||
|
||||
void EkfWrapper::setGpsHeightRef()
|
||||
{
|
||||
_ekf_params->height_sensor_ref = HeightSensor::GNSS;
|
||||
_ekf_params->height_sensor_ref = static_cast<int32_t>(HeightSensor::GNSS);
|
||||
}
|
||||
|
||||
void EkfWrapper::enableGpsHeightFusion()
|
||||
@@ -52,7 +52,7 @@ bool EkfWrapper::isIntendingGpsHeightFusion() const
|
||||
|
||||
void EkfWrapper::setRangeHeightRef()
|
||||
{
|
||||
_ekf_params->height_sensor_ref = HeightSensor::RANGE;
|
||||
_ekf_params->height_sensor_ref = static_cast<int32_t>(HeightSensor::RANGE);
|
||||
}
|
||||
|
||||
void EkfWrapper::enableRangeHeightFusion()
|
||||
@@ -72,7 +72,7 @@ bool EkfWrapper::isIntendingRangeHeightFusion() const
|
||||
|
||||
void EkfWrapper::setExternalVisionHeightRef()
|
||||
{
|
||||
_ekf_params->height_sensor_ref = HeightSensor::EV;
|
||||
_ekf_params->height_sensor_ref = static_cast<int32_t>(HeightSensor::EV);
|
||||
}
|
||||
|
||||
void EkfWrapper::enableExternalVisionHeightFusion()
|
||||
|
||||
Reference in New Issue
Block a user