CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.h
Views: 1798
1
/*
2
This program is free software: you can redistribute it and/or modify
3
it under the terms of the GNU General Public License as published by
4
the Free Software Foundation, either version 3 of the License, or
5
(at your option) any later version.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program. If not, see <http://www.gnu.org/licenses/>.
14
*/
15
/*
16
parent class for ExternalAHRS backends
17
*/
18
19
#pragma once
20
21
#include "AP_ExternalAHRS.h"
22
23
#if HAL_EXTERNAL_AHRS_ENABLED
24
25
class AP_ExternalAHRS_backend {
26
public:
27
AP_ExternalAHRS_backend(AP_ExternalAHRS *frontend, AP_ExternalAHRS::state_t &state);
28
29
// get serial port number, -1 for not enabled
30
virtual int8_t get_port(void) const { return -1; }
31
32
// Get model/type name
33
virtual const char* get_name() const = 0;
34
35
// Accessors for AP_AHRS
36
37
// If not healthy, none of the other API's can be trusted.
38
// Example: Serial cable is severed.
39
virtual bool healthy(void) const = 0;
40
// The communication interface is up and the device has sent valid data.
41
virtual bool initialised(void) const = 0;
42
virtual bool pre_arm_check(char *failure_msg, uint8_t failure_msg_len) const = 0;
43
virtual void get_filter_status(nav_filter_status &status) const {}
44
virtual bool get_variances(float &velVar, float &posVar, float &hgtVar, Vector3f &magVar, float &tasVar) const { return false; }
45
46
// Check for new data.
47
// This is used when there's not a separate thread for EAHRS.
48
// This can also copy interim state protected by locking.
49
virtual void update() = 0;
50
51
// Return the number of GPS sensors sharing data to AP_GPS.
52
virtual uint8_t num_gps_sensors(void) const = 0;
53
54
protected:
55
AP_ExternalAHRS::state_t &state;
56
uint16_t get_rate(void) const;
57
bool option_is_set(AP_ExternalAHRS::OPTIONS option) const;
58
59
// set default of EAHRS_SENSORS
60
void set_default_sensors(uint16_t sensors) {
61
frontend.set_default_sensors(sensors);
62
}
63
64
/*
65
return true if the GNSS is disabled
66
*/
67
bool gnss_is_disabled(void) const {
68
return frontend.gnss_is_disabled;
69
}
70
71
/*
72
return true when we are in fixed wing flight
73
*/
74
bool in_fly_forward(void) const;
75
76
/*
77
scale factors for get_variances() to return normalised values from SI units
78
*/
79
const float vel_gate_scale = 0.2;
80
const float pos_gate_scale = 0.2;
81
const float hgt_gate_scale = 0.2;
82
83
private:
84
AP_ExternalAHRS &frontend;
85
};
86
87
#endif // HAL_EXTERNAL_AHRS_ENABLED
88
89
90