2020-11-05 19:22:38 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AP_RangeFinder/AP_RangeFinder.h>
|
|
|
|
|
2023-11-07 18:23:39 -04:00
|
|
|
#if AP_RANGEFINDER_ENABLED
|
|
|
|
|
2020-11-05 19:22:38 -04:00
|
|
|
#include <AP_Logger/LogStructure.h>
|
|
|
|
|
|
|
|
class AP_RangeFinder_Backend;
|
|
|
|
|
|
|
|
class AP_DAL_RangeFinder {
|
|
|
|
public:
|
|
|
|
|
|
|
|
// RangeFinder-like methods:
|
|
|
|
enum class Status {
|
|
|
|
NotConnected = 0,
|
|
|
|
NoData,
|
|
|
|
OutOfRangeLow,
|
|
|
|
OutOfRangeHigh,
|
|
|
|
Good
|
|
|
|
};
|
|
|
|
|
|
|
|
int16_t ground_clearance_cm_orient(enum Rotation orientation) const;
|
|
|
|
int16_t max_distance_cm_orient(enum Rotation orientation) const;
|
|
|
|
|
2020-11-08 21:28:58 -04:00
|
|
|
// return true if we have a range finder with the specified orientation
|
|
|
|
bool has_orientation(enum Rotation orientation) const;
|
|
|
|
|
2020-11-05 19:22:38 -04:00
|
|
|
// DAL methods:
|
|
|
|
AP_DAL_RangeFinder();
|
|
|
|
|
|
|
|
void start_frame();
|
|
|
|
|
|
|
|
class AP_DAL_RangeFinder_Backend *get_backend(uint8_t id) const;
|
|
|
|
|
2020-11-26 06:39:57 -04:00
|
|
|
void handle_message(const log_RRNH &msg);
|
|
|
|
void handle_message(const log_RRNI &msg);
|
2020-11-05 19:22:38 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
struct log_RRNH _RRNH;
|
2020-11-26 06:39:57 -04:00
|
|
|
struct log_RRNI *_RRNI;
|
|
|
|
AP_DAL_RangeFinder_Backend **_backend;
|
2020-11-05 19:22:38 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class AP_DAL_RangeFinder_Backend {
|
|
|
|
public:
|
|
|
|
|
|
|
|
AP_DAL_RangeFinder_Backend(struct log_RRNI &RRNI);
|
|
|
|
|
|
|
|
// RangeFinder-backend-like methods
|
|
|
|
|
|
|
|
enum Rotation orientation() const {
|
|
|
|
return (Rotation)_RRNI.orientation;
|
|
|
|
}
|
|
|
|
|
|
|
|
AP_DAL_RangeFinder::Status status() const {
|
|
|
|
return (AP_DAL_RangeFinder::Status)_RRNI.status;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t distance_cm() const { return _RRNI.distance_cm; }
|
|
|
|
|
|
|
|
const Vector3f &get_pos_offset() const { return _RRNI.pos_offset; }
|
|
|
|
|
|
|
|
// DAL methods:
|
|
|
|
void start_frame(AP_RangeFinder_Backend *backend);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
struct log_RRNI &_RRNI;
|
|
|
|
};
|
2023-11-07 18:23:39 -04:00
|
|
|
|
|
|
|
#endif // AP_RANGEFINDER_ENABLED
|