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_DroneCAN.h
Views: 1798
1
#pragma once
2
3
#include "AP_Baro_Backend.h"
4
5
#if AP_BARO_DRONECAN_ENABLED
6
7
#include <AP_DroneCAN/AP_DroneCAN.h>
8
#if AP_TEST_DRONECAN_DRIVERS
9
#include <SITL/SITL.h>
10
#endif
11
12
class AP_Baro_DroneCAN : public AP_Baro_Backend {
13
public:
14
AP_Baro_DroneCAN(AP_Baro &baro);
15
16
void update() override;
17
18
static bool subscribe_msgs(AP_DroneCAN* ap_dronecan);
19
static AP_Baro_DroneCAN* get_dronecan_backend(AP_DroneCAN* ap_dronecan, uint8_t node_id, bool create_new);
20
static AP_Baro_Backend* probe(AP_Baro &baro);
21
22
static void handle_pressure(AP_DroneCAN *ap_dronecan, const CanardRxTransfer& transfer, const uavcan_equipment_air_data_StaticPressure &msg);
23
static void handle_temperature(AP_DroneCAN *ap_dronecan, const CanardRxTransfer& transfer, const uavcan_equipment_air_data_StaticTemperature &msg);
24
#if AP_TEST_DRONECAN_DRIVERS
25
void update_healthy_flag(uint8_t instance) override { _frontend.sensors[instance].healthy = !AP::sitl()->baro[instance].disable; };
26
#endif
27
private:
28
29
static void _update_and_wrap_accumulator(float *accum, float val, uint8_t *count, const uint8_t max_count);
30
31
uint8_t _instance;
32
33
bool new_pressure;
34
float _pressure;
35
float _temperature;
36
uint8_t _pressure_count;
37
HAL_Semaphore _sem_baro;
38
39
AP_DroneCAN* _ap_dronecan;
40
uint8_t _node_id;
41
42
// Module Detection Registry
43
static struct DetectedModules {
44
AP_DroneCAN* ap_dronecan;
45
uint8_t node_id;
46
AP_Baro_DroneCAN* driver;
47
} _detected_modules[BARO_MAX_DRIVERS];
48
49
static HAL_Semaphore _sem_registry;
50
};
51
52
#endif // AP_BARO_DRONECAN_ENABLED
53
54