2021-03-24 03:24:01 -03:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
parent class for ExternalAHRS backends
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "AP_ExternalAHRS.h"
|
|
|
|
|
|
|
|
#if HAL_EXTERNAL_AHRS_ENABLED
|
|
|
|
|
|
|
|
class AP_ExternalAHRS_backend {
|
|
|
|
public:
|
|
|
|
AP_ExternalAHRS_backend(AP_ExternalAHRS *frontend, AP_ExternalAHRS::state_t &state);
|
|
|
|
|
|
|
|
// get serial port number, -1 for not enabled
|
|
|
|
virtual int8_t get_port(void) const { return -1; }
|
|
|
|
|
2022-12-21 11:51:42 -04:00
|
|
|
// Get model/type name
|
|
|
|
virtual const char* get_name() const = 0;
|
|
|
|
|
2023-11-24 21:14:55 -04:00
|
|
|
// Accessors for AP_AHRS
|
|
|
|
|
|
|
|
// If not healthy, none of the other API's can be trusted.
|
|
|
|
// Example: Serial cable is severed.
|
2021-03-24 03:24:01 -03:00
|
|
|
virtual bool healthy(void) const = 0;
|
2023-11-24 21:14:55 -04:00
|
|
|
// The communication interface is up and the device has sent valid data.
|
2021-03-24 03:24:01 -03:00
|
|
|
virtual bool initialised(void) const = 0;
|
|
|
|
virtual bool pre_arm_check(char *failure_msg, uint8_t failure_msg_len) const = 0;
|
|
|
|
virtual void get_filter_status(nav_filter_status &status) const {}
|
2024-10-15 00:18:39 -03:00
|
|
|
virtual bool get_variances(float &velVar, float &posVar, float &hgtVar, Vector3f &magVar, float &tasVar) const { return false; }
|
2021-03-24 03:24:01 -03:00
|
|
|
|
2023-11-24 21:14:55 -04:00
|
|
|
// Check for new data.
|
|
|
|
// This is used when there's not a separate thread for EAHRS.
|
|
|
|
// This can also copy interim state protected by locking.
|
2021-03-24 03:24:01 -03:00
|
|
|
virtual void update() = 0;
|
2023-11-24 21:14:55 -04:00
|
|
|
|
2024-03-24 23:40:31 -03:00
|
|
|
// Return the number of GPS sensors sharing data to AP_GPS.
|
|
|
|
virtual uint8_t num_gps_sensors(void) const = 0;
|
|
|
|
|
2021-03-24 03:24:01 -03:00
|
|
|
protected:
|
|
|
|
AP_ExternalAHRS::state_t &state;
|
|
|
|
uint16_t get_rate(void) const;
|
2022-12-22 17:16:10 -04:00
|
|
|
bool option_is_set(AP_ExternalAHRS::OPTIONS option) const;
|
2021-03-24 03:24:01 -03:00
|
|
|
|
2023-12-01 20:52:50 -04:00
|
|
|
// set default of EAHRS_SENSORS
|
|
|
|
void set_default_sensors(uint16_t sensors) {
|
|
|
|
frontend.set_default_sensors(sensors);
|
|
|
|
}
|
2024-02-15 19:37:34 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
return true if the GNSS is disabled
|
|
|
|
*/
|
|
|
|
bool gnss_is_disabled(void) const {
|
|
|
|
return frontend.gnss_is_disabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
return true when we are in fixed wing flight
|
|
|
|
*/
|
|
|
|
bool in_fly_forward(void) const;
|
|
|
|
|
2024-10-15 00:18:39 -03:00
|
|
|
/*
|
|
|
|
scale factors for get_variances() to return normalised values from SI units
|
|
|
|
*/
|
|
|
|
const float vel_gate_scale = 0.2;
|
|
|
|
const float pos_gate_scale = 0.2;
|
|
|
|
const float hgt_gate_scale = 0.2;
|
|
|
|
|
2021-03-24 03:24:01 -03:00
|
|
|
private:
|
|
|
|
AP_ExternalAHRS &frontend;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // HAL_EXTERNAL_AHRS_ENABLED
|
|
|
|
|