2020-06-17 08:28:03 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AP_Param/AP_Param.h>
|
|
|
|
|
|
|
|
#define AP_NAKEKF_SOURCE_SET_MAX 3 // three sets of sources
|
|
|
|
|
|
|
|
class AP_NavEKF_Source
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Constructor
|
|
|
|
AP_NavEKF_Source();
|
|
|
|
|
|
|
|
/* Do not allow copies */
|
2022-09-30 06:50:43 -03:00
|
|
|
CLASS_NO_COPY(AP_NavEKF_Source);
|
2020-06-17 08:28:03 -03:00
|
|
|
|
2020-12-15 06:48:52 -04:00
|
|
|
enum class SourceXY : uint8_t {
|
2020-06-17 08:28:03 -03:00
|
|
|
NONE = 0,
|
|
|
|
// BARO = 1 (not applicable)
|
|
|
|
// RANGEFINDER = 2 (not applicable)
|
|
|
|
GPS = 3,
|
|
|
|
BEACON = 4,
|
|
|
|
OPTFLOW = 5,
|
|
|
|
EXTNAV = 6,
|
|
|
|
WHEEL_ENCODER = 7
|
|
|
|
};
|
|
|
|
|
2020-12-15 06:48:52 -04:00
|
|
|
enum class SourceZ : uint8_t {
|
2020-06-17 08:28:03 -03:00
|
|
|
NONE = 0,
|
|
|
|
BARO = 1,
|
|
|
|
RANGEFINDER = 2,
|
|
|
|
GPS = 3,
|
|
|
|
BEACON = 4,
|
|
|
|
// OPTFLOW = 5 (not applicable, optical flow can be used for terrain alt but not relative or absolute alt)
|
|
|
|
EXTNAV = 6
|
|
|
|
// WHEEL_ENCODER = 7 (not applicable)
|
|
|
|
};
|
|
|
|
|
2020-12-15 06:48:52 -04:00
|
|
|
enum class SourceYaw : uint8_t {
|
2020-06-17 08:28:03 -03:00
|
|
|
NONE = 0,
|
|
|
|
COMPASS = 1,
|
2020-12-22 04:07:38 -04:00
|
|
|
GPS = 2,
|
|
|
|
GPS_COMPASS_FALLBACK = 3,
|
2020-12-22 03:15:21 -04:00
|
|
|
EXTNAV = 6,
|
|
|
|
GSF = 8
|
2020-06-17 08:28:03 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
// enum for OPTIONS parameter
|
|
|
|
enum class SourceOptions {
|
|
|
|
FUSE_ALL_VELOCITIES = (1 << 0) // fuse all velocities configured in source sets
|
|
|
|
};
|
|
|
|
|
|
|
|
// initialisation
|
|
|
|
void init();
|
|
|
|
|
|
|
|
// get current position source
|
2020-12-15 06:59:15 -04:00
|
|
|
SourceXY getPosXYSource() const { return _source_set[active_source_set].posxy; }
|
|
|
|
SourceZ getPosZSource() const { return _source_set[active_source_set].posz; }
|
2020-06-17 08:28:03 -03:00
|
|
|
|
|
|
|
// set position, velocity and yaw sources to either 0=primary, 1=secondary, 2=tertiary
|
|
|
|
void setPosVelYawSourceSet(uint8_t source_set_idx);
|
2021-07-16 01:26:36 -03:00
|
|
|
uint8_t getPosVelYawSourceSet() const { return active_source_set; }
|
2020-06-17 08:28:03 -03:00
|
|
|
|
|
|
|
// get/set velocity source
|
2020-12-15 06:59:15 -04:00
|
|
|
SourceXY getVelXYSource() const { return _source_set[active_source_set].velxy; }
|
|
|
|
SourceZ getVelZSource() const { return _source_set[active_source_set].velz; }
|
2020-06-17 08:28:03 -03:00
|
|
|
|
|
|
|
// true/false of whether velocity source should be used
|
|
|
|
bool useVelXYSource(SourceXY velxy_source) const;
|
|
|
|
bool useVelZSource(SourceZ velz_source) const;
|
|
|
|
|
|
|
|
// true if a velocity source is configured
|
|
|
|
bool haveVelZSource() const;
|
|
|
|
|
|
|
|
// get yaw source
|
2020-12-17 03:26:51 -04:00
|
|
|
SourceYaw getYawSource() const;
|
2020-06-17 08:28:03 -03:00
|
|
|
|
|
|
|
// align position of inactive sources to ahrs
|
|
|
|
void align_inactive_sources();
|
|
|
|
|
|
|
|
// sensor-specific helper functions
|
|
|
|
|
|
|
|
// true if any source is GPS
|
|
|
|
bool usingGPS() const;
|
|
|
|
|
2020-11-19 23:34:09 -04:00
|
|
|
// true if source parameters have been configured (used for parameter conversion)
|
2022-05-11 19:04:36 -03:00
|
|
|
bool configured();
|
2020-11-19 23:34:09 -04:00
|
|
|
|
2022-05-11 19:04:36 -03:00
|
|
|
// mark parameters as configured (used to ensure parameter conversion is only done once)
|
|
|
|
void mark_configured();
|
2020-06-17 08:28:03 -03:00
|
|
|
|
|
|
|
// returns false if we fail arming checks, in which case the buffer will be populated with a failure message
|
2021-01-20 23:42:47 -04:00
|
|
|
// requires_position should be true if horizontal position configuration should be checked
|
|
|
|
bool pre_arm_check(bool requires_position, char *failure_msg, uint8_t failure_msg_len) const;
|
2020-06-17 08:28:03 -03:00
|
|
|
|
2020-11-26 18:37:13 -04:00
|
|
|
// return true if ext nav is enabled on any source
|
|
|
|
bool ext_nav_enabled(void) const;
|
|
|
|
|
2020-12-22 04:07:38 -04:00
|
|
|
// return true if GPS yaw is enabled on any source
|
|
|
|
bool gps_yaw_enabled(void) const;
|
2020-12-17 03:23:03 -04:00
|
|
|
|
2020-11-26 18:37:13 -04:00
|
|
|
// return true if wheel encoder is enabled on any source
|
|
|
|
bool wheel_encoder_enabled(void) const;
|
2020-12-17 03:23:03 -04:00
|
|
|
|
2022-08-06 12:10:34 -03:00
|
|
|
// returns active source set
|
|
|
|
uint8_t get_active_source_set() const;
|
|
|
|
|
2020-12-17 03:23:03 -04:00
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
|
2020-06-17 08:28:03 -03:00
|
|
|
private:
|
|
|
|
|
|
|
|
// Parameters
|
2020-11-26 18:37:13 -04:00
|
|
|
struct SourceSet {
|
2020-12-15 06:48:52 -04:00
|
|
|
AP_Enum<SourceXY> posxy; // xy position source
|
|
|
|
AP_Enum<SourceXY> velxy; // xy velocity source
|
|
|
|
AP_Enum<SourceZ> posz; // position z (aka altitude or height) source
|
|
|
|
AP_Enum<SourceZ> velz; // velocity z source
|
|
|
|
AP_Enum<SourceYaw> yaw; // yaw source
|
2020-06-17 08:28:03 -03:00
|
|
|
} _source_set[AP_NAKEKF_SOURCE_SET_MAX];
|
|
|
|
|
|
|
|
AP_Int16 _options; // source options bitmask
|
|
|
|
|
2020-12-15 06:59:15 -04:00
|
|
|
uint8_t active_source_set; // index of active source set
|
2022-05-11 19:04:36 -03:00
|
|
|
bool _configured; // true once configured has returned true
|
2020-06-17 08:28:03 -03:00
|
|
|
};
|