Line data Source code
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 : float ground_clearance_orient(enum Rotation orientation) const; 24 : float max_distance_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 422099 : enum Rotation orientation() const { 55 422099 : return (Rotation)_RRNI.orientation; 56 : } 57 : 58 400517 : AP_DAL_RangeFinder::Status status() const { 59 400517 : return (AP_DAL_RangeFinder::Status)_RRNI.status; 60 : } 61 : 62 223440 : float distance() const { return _RRNI.distance; } 63 : 64 176951 : 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