2019-08-31 08:21:01 -03:00
|
|
|
#pragma once
|
|
|
|
|
2023-07-06 01:25:14 -03:00
|
|
|
#include "AP_RangeFinder_config.h"
|
2022-03-12 06:37:29 -04:00
|
|
|
|
|
|
|
#if AP_RANGEFINDER_LANBAO_ENABLED
|
|
|
|
|
2023-07-06 01:25:14 -03:00
|
|
|
#include "AP_RangeFinder.h"
|
|
|
|
#include "AP_RangeFinder_Backend_Serial.h"
|
|
|
|
|
2019-11-01 07:10:57 -03:00
|
|
|
class AP_RangeFinder_Lanbao : public AP_RangeFinder_Backend_Serial
|
2019-08-31 08:21:01 -03:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2022-06-22 08:03:22 -03:00
|
|
|
static AP_RangeFinder_Backend_Serial *create(
|
|
|
|
RangeFinder::RangeFinder_State &_state,
|
|
|
|
AP_RangeFinder_Params &_params) {
|
2024-05-26 22:24:14 -03:00
|
|
|
return NEW_NOTHROW AP_RangeFinder_Lanbao(_state, _params);
|
2022-06-22 08:03:22 -03:00
|
|
|
}
|
2019-11-01 07:10:57 -03:00
|
|
|
|
|
|
|
// Lanbao is always 115200:
|
|
|
|
uint32_t initial_baudrate(uint8_t serial_instance) const override {
|
|
|
|
return 115200;
|
|
|
|
}
|
2019-08-31 08:21:01 -03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2020-01-13 01:48:07 -04:00
|
|
|
MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
|
2019-08-31 08:21:01 -03:00
|
|
|
return MAV_DISTANCE_SENSOR_LASER;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2022-06-22 08:03:22 -03:00
|
|
|
|
|
|
|
using AP_RangeFinder_Backend_Serial::AP_RangeFinder_Backend_Serial;
|
|
|
|
|
2019-08-31 08:21:01 -03:00
|
|
|
// get a reading
|
2021-10-18 02:45:33 -03:00
|
|
|
bool get_reading(float &reading_m) override;
|
2019-08-31 08:21:01 -03:00
|
|
|
|
|
|
|
uint8_t buf[6];
|
|
|
|
uint8_t buf_len = 0;
|
|
|
|
};
|
2022-03-12 06:37:29 -04:00
|
|
|
|
|
|
|
#endif // AP_RANGEFINDER_LANBAO_ENABLED
|