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_Baro/AP_Baro_Backend.h
Views: 1798
1
#pragma once
2
3
#include "AP_Baro.h"
4
5
class AP_Baro_Backend
6
{
7
public:
8
AP_Baro_Backend(AP_Baro &baro);
9
virtual ~AP_Baro_Backend(void) {};
10
11
// each driver must provide an update method to copy accumulated
12
// data to the frontend
13
virtual void update() = 0;
14
15
void backend_update(uint8_t instance);
16
17
// Check that the baro valid by using a mean filter.
18
// If the value further that filter_range from mean value, it is rejected.
19
bool pressure_ok(float press);
20
uint32_t get_error_count() const { return _error_count; }
21
22
#if AP_BARO_MSP_ENABLED
23
virtual void handle_msp(const MSP::msp_baro_data_message_t &pkt) {}
24
#endif
25
26
#if AP_BARO_EXTERNALAHRS_ENABLED
27
virtual void handle_external(const AP_ExternalAHRS::baro_data_message_t &pkt) {}
28
#endif
29
30
/*
31
device driver IDs. These are used to fill in the devtype field
32
of the device ID, which shows up as BARO_DEVID* parameters to
33
users.
34
*/
35
enum DevTypes {
36
DEVTYPE_BARO_SITL = 0x01,
37
DEVTYPE_BARO_BMP085 = 0x02,
38
DEVTYPE_BARO_BMP280 = 0x03,
39
DEVTYPE_BARO_BMP388 = 0x04,
40
DEVTYPE_BARO_DPS280 = 0x05,
41
DEVTYPE_BARO_DPS310 = 0x06,
42
DEVTYPE_BARO_FBM320 = 0x07,
43
DEVTYPE_BARO_ICM20789 = 0x08,
44
DEVTYPE_BARO_KELLERLD = 0x09,
45
DEVTYPE_BARO_LPS2XH = 0x0A,
46
DEVTYPE_BARO_MS5611 = 0x0B,
47
DEVTYPE_BARO_SPL06 = 0x0C,
48
DEVTYPE_BARO_UAVCAN = 0x0D,
49
DEVTYPE_BARO_MSP = 0x0E,
50
DEVTYPE_BARO_ICP101XX = 0x0F,
51
DEVTYPE_BARO_ICP201XX = 0x10,
52
DEVTYPE_BARO_MS5607 = 0x11,
53
DEVTYPE_BARO_MS5837 = 0x12,
54
DEVTYPE_BARO_MS5637 = 0x13,
55
DEVTYPE_BARO_BMP390 = 0x14,
56
DEVTYPE_BARO_BMP581 = 0x15,
57
};
58
59
protected:
60
// reference to frontend object
61
AP_Baro &_frontend;
62
63
void _copy_to_frontend(uint8_t instance, float pressure, float temperature);
64
65
// semaphore for access to shared frontend data
66
HAL_Semaphore _sem;
67
68
virtual void update_healthy_flag(uint8_t instance);
69
70
// mean pressure for range filter
71
float _mean_pressure;
72
// number of dropped samples. Not used for now, but can be usable to choose more reliable sensor
73
uint32_t _error_count;
74
75
// set bus ID of this instance, for BARO_DEVID parameters
76
void set_bus_id(uint8_t instance, uint32_t id) {
77
_frontend.sensors[instance].bus_id.set(int32_t(id));
78
}
79
};
80
81