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_DAL/AP_DAL_RangeFinder.h
Views: 1798
1
#pragma once
2
3
#include <AP_RangeFinder/AP_RangeFinder.h>
4
5
#if AP_RANGEFINDER_ENABLED
6
7
#include <AP_Logger/LogStructure.h>
8
9
class AP_RangeFinder_Backend;
10
11
class AP_DAL_RangeFinder {
12
public:
13
14
// RangeFinder-like methods:
15
enum class Status {
16
NotConnected = 0,
17
NoData,
18
OutOfRangeLow,
19
OutOfRangeHigh,
20
Good
21
};
22
23
int16_t ground_clearance_cm_orient(enum Rotation orientation) const;
24
int16_t max_distance_cm_orient(enum Rotation orientation) const;
25
26
// return true if we have a range finder with the specified orientation
27
bool has_orientation(enum Rotation orientation) const;
28
29
// DAL methods:
30
AP_DAL_RangeFinder();
31
32
void start_frame();
33
34
class AP_DAL_RangeFinder_Backend *get_backend(uint8_t id) const;
35
36
void handle_message(const log_RRNH &msg);
37
void handle_message(const log_RRNI &msg);
38
39
private:
40
41
struct log_RRNH _RRNH;
42
struct log_RRNI *_RRNI;
43
AP_DAL_RangeFinder_Backend **_backend;
44
};
45
46
47
class AP_DAL_RangeFinder_Backend {
48
public:
49
50
AP_DAL_RangeFinder_Backend(struct log_RRNI &RRNI);
51
52
// RangeFinder-backend-like methods
53
54
enum Rotation orientation() const {
55
return (Rotation)_RRNI.orientation;
56
}
57
58
AP_DAL_RangeFinder::Status status() const {
59
return (AP_DAL_RangeFinder::Status)_RRNI.status;
60
}
61
62
uint16_t distance_cm() const { return _RRNI.distance_cm; }
63
64
const Vector3f &get_pos_offset() const { return _RRNI.pos_offset; }
65
66
// DAL methods:
67
void start_frame(AP_RangeFinder_Backend *backend);
68
69
private:
70
71
struct log_RRNI &_RRNI;
72
};
73
74
#endif // AP_RANGEFINDER_ENABLED
75
76