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_Airspeed/AP_Airspeed_DroneCAN.h
Views: 1798
1
#pragma once
2
3
#include "AP_Airspeed_config.h"
4
5
#if AP_AIRSPEED_DRONECAN_ENABLED
6
7
#include "AP_Airspeed_Backend.h"
8
9
#include <AP_DroneCAN/AP_DroneCAN.h>
10
11
class AP_Airspeed_DroneCAN : public AP_Airspeed_Backend {
12
public:
13
14
using AP_Airspeed_Backend::AP_Airspeed_Backend;
15
16
bool init(void) override;
17
18
// return the current differential_pressure in Pascal
19
bool get_differential_pressure(float &pressure) override;
20
21
// temperature not available via analog backend
22
bool get_temperature(float &temperature) override;
23
24
#if AP_AIRSPEED_HYGROMETER_ENABLE
25
// get hygrometer data
26
bool get_hygrometer(uint32_t &last_sample_ms, float &temperature, float &humidity) override;
27
#endif
28
29
static bool subscribe_msgs(AP_DroneCAN* ap_dronecan);
30
31
static AP_Airspeed_Backend* probe(AP_Airspeed &_frontend, uint8_t _instance, uint32_t previous_devid);
32
33
private:
34
35
static void handle_airspeed(AP_DroneCAN *ap_dronecan, const CanardRxTransfer& transfer, const uavcan_equipment_air_data_RawAirData &msg);
36
static void handle_hygrometer(AP_DroneCAN *ap_dronecan, const CanardRxTransfer& transfer, const dronecan_sensors_hygrometer_Hygrometer &msg);
37
38
static AP_Airspeed_DroneCAN* get_dronecan_backend(AP_DroneCAN* ap_dronecan, uint8_t node_id);
39
40
float _pressure; // Pascal
41
float _temperature; // Celcius
42
uint32_t _last_sample_time_ms;
43
44
// hygrometer data
45
struct {
46
float temperature;
47
float humidity;
48
uint32_t last_sample_ms;
49
} _hygrometer;
50
51
HAL_Semaphore _sem_airspeed;
52
53
// Module Detection Registry
54
static struct DetectedModules {
55
AP_DroneCAN* ap_dronecan;
56
uint8_t node_id;
57
AP_Airspeed_DroneCAN *driver;
58
} _detected_modules[AIRSPEED_MAX_SENSORS];
59
60
static HAL_Semaphore _sem_registry;
61
bool _have_temperature;
62
};
63
64
65
#endif // AP_AIRSPEED_DRONECAN_ENABLED
66
67