18 #define AP_COMPASS_MOT_COMP_DISABLED 0x00 19 #define AP_COMPASS_MOT_COMP_THROTTLE 0x01 20 #define AP_COMPASS_MOT_COMP_CURRENT 0x02 21 #define AP_COMPASS_MOT_COMP_PER_MOTOR 0x03 24 #ifndef MAG_BOARD_ORIENTATION 25 #if CONFIG_HAL_BOARD == HAL_BOARD_LINUX && CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP 26 # define MAG_BOARD_ORIENTATION ROTATION_YAW_90 27 #elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX && (CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \ 28 CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI) 29 # define MAG_BOARD_ORIENTATION ROTATION_YAW_270 31 # define MAG_BOARD_ORIENTATION ROTATION_NONE 37 #define AP_COMPASS_CALIBRATION_FITNESS_DEFAULT 16.0f 38 #define AP_COMPASS_MAX_XYZ_ANG_DIFF radians(90.0f) 39 #define AP_COMPASS_MAX_XY_ANG_DIFF radians(60.0f) 40 #define AP_COMPASS_MAX_XY_LENGTH_DIFF 200.0f 46 #define COMPASS_MAX_INSTANCES 3 47 #define COMPASS_MAX_BACKEND 3 139 void start_calibration_all(
bool retry=
false,
bool autosave=
false,
float delay_sec=0.0
f,
bool autoreboot =
false);
280 void setHIL(uint8_t instance,
float roll,
float pitch,
float yaw);
320 _learn.set_and_save((int8_t)type);
351 bool _start_calibration_mask(uint8_t mask,
bool retry=
false,
bool autosave=
false,
float delay_sec=0.0
f,
bool autoreboot=
false);
uint8_t register_compass(void)
AP_Int8 _auto_declination
void per_motor_calibration_end(void)
bool _start_calibration(uint8_t i, bool retry=false, float delay_sec=0.0f)
void calibration_end(void)
bool _have_driver(AP_HAL::Device::BusType bus_type, uint8_t bus_num, uint8_t address, uint8_t devtype) const
Vector3< float > Vector3f
void set_board_orientation(enum Rotation orientation, Matrix3f *custom_rotation=nullptr)
void set_learn_type(enum LearnType type, bool save)
bool _cal_complete_requires_reboot
float get_declination() const
uint32_t last_update_usec
AP_Int32 _driver_type_mask
static Compass * get_singleton()
bool _driver_enabled(enum DriverType driver_type)
const Vector3f & get_motor_offsets(uint8_t i) const
bool _compass_cal_autoreboot
void set_and_save_offdiagonals(uint8_t i, const Vector3f &diagonals)
const Vector3f & get_offsets(void) const
bool _cal_saved[COMPASS_MAX_INSTANCES]
void setHIL(uint8_t instance, float roll, float pitch, float yaw)
void start_calibration_all(bool retry=false, bool autosave=false, float delay_sec=0.0f, bool autoreboot=false)
void calibration_update(void)
bool _add_backend(AP_Compass_Backend *backend, const char *name, bool external)
void set_and_save_offsets(uint8_t i, const Vector3f &offsets)
uint8_t mag_history_index
void cancel_calibration_all()
void per_motor_calibration_update(void)
#define AP_COMPASS_MOT_COMP_THROTTLE
uint8_t _get_cal_mask() const
void set_offsets(uint8_t i, const Vector3f &offsets)
const Vector3f & get_offdiagonals(void) const
void set_motor_compensation(uint8_t i, const Vector3f &motor_comp_factor)
void set_throttle(float thr_pct)
uint8_t get_healthy_mask() const
void _setup_earth_field()
uint32_t last_update_usec(uint8_t i) const
uint8_t get_primary(void) const
float calculate_heading(const Matrix3f &dcm_matrix) const
const Vector3f & get_field(uint8_t i) const
Return the current field as a Vector3f in milligauss.
CompassCalibrator _calibrator[COMPASS_MAX_INSTANCES]
MAV_RESULT handle_mag_cal_command(const mavlink_command_long_t &packet)
A system for managing and storing variables that are of general interest to the system.
bool _accept_calibration(uint8_t i)
void send_mag_cal_report(mavlink_channel_t chan)
void set_and_save_diagonals(uint8_t i, const Vector3f &diagonals)
const Vector3f & get_diagonals(uint8_t i) const
const Vector3f & get_motor_compensation(uint8_t i) const
get motor compensation factors as a vector
uint8_t get_filter_range() const
const Vector3f & get_diagonals(void) const
void set_use_for_yaw(uint8_t i, bool use)
const Vector3f & get_offsets(uint8_t i) const
bool _accept_calibration_mask(uint8_t mask)
Compass & operator=(const Compass &)=delete
bool _start_calibration_mask(uint8_t mask, bool retry=false, bool autosave=false, float delay_sec=0.0f, bool autoreboot=false)
AP_Compass_Backend * _backends[COMPASS_MAX_BACKEND]
Vector3f field[COMPASS_MAX_INSTANCES]
uint16_t get_offsets_max(void) const
const Vector3f & getHIL(uint8_t instance) const
const Vector3f & get_motor_offsets(void) const
uint32_t last_update_ms(uint8_t i) const
void _detect_backends(void)
bool learn_offsets_enabled() const
void calibration_start(void)
AP_Float _calibration_threshold
Compass_PerMotor _per_motor
uint8_t get_count(void) const
Common definitions and utility routines for the ArduPilot libraries.
void set_voltage(float _voltage)
void set_voltage(float voltage)
Set the battery voltage for per-motor compensation.
enum LearnType get_learn_type(void) const
void set_declination(float radians, bool save_to_eeprom=true)
#define COMPASS_MAX_INSTANCES
void motor_compensation_type(const uint8_t comp_type)
uint32_t last_update_usec(void) const
Matrix3f * _custom_rotation
static constexpr float radians(float deg)
void per_motor_calibration_start(void)
const Vector3f & get_field(void) const
void compass_cal_update()
AP_HAL::AnalogSource * chan
static Compass * _singleton
uint8_t get_motor_compensation_type() const
get the motor compensation value.
uint32_t last_update_ms(void) const
bool healthy(uint8_t i) const
Return the health of a compass.
void _cancel_calibration(uint8_t i)
static const struct AP_Param::GroupInfo var_info[]
void _cancel_calibration_mask(uint8_t mask)
bool is_calibrating() const
void send_mag_cal_progress(mavlink_channel_t chan)
void set_and_save_offsets(uint8_t i, int x, int y, int z)
#define COMPASS_MAX_BACKEND
bool use_for_yaw(void) const
return true if the compass should be used for yaw calculations
bool compass_cal_requires_reboot()
struct Compass::mag_state _state[COMPASS_MAX_INSTANCES]
void set_initial_location(int32_t latitude, int32_t longitude)
const Vector3f & get_motor_compensation(void) const
enum Rotation _board_orientation
AP_Vector3f motor_compensation
static const uint8_t _mag_history_size
void save_motor_compensation()
const Vector3f & get_offdiagonals(uint8_t i) const