2016-02-17 21:25:44 -04:00
|
|
|
#pragma once
|
2013-12-02 07:02:56 -04:00
|
|
|
|
|
|
|
#include "RangeFinder.h"
|
2014-06-27 00:39:52 -03:00
|
|
|
#include "RangeFinder_Backend.h"
|
2016-04-14 17:00:38 -03:00
|
|
|
#include <AP_HAL/I2CDevice.h>
|
2013-12-02 07:02:56 -04:00
|
|
|
|
|
|
|
/* Connection diagram
|
|
|
|
*
|
|
|
|
* ------------------------------------------------------------------------------------
|
2014-04-30 14:35:38 -03:00
|
|
|
* | J2-1(LED) J2-2(5V) J2-3(Enable) J2-4(Ref Clk) J2-5(GND) J2-6(GND) |
|
2013-12-02 07:02:56 -04:00
|
|
|
* | |
|
2014-04-30 14:35:38 -03:00
|
|
|
* | |
|
|
|
|
* | J1-3(I2C Clk) J1-2(I2C Data) J1-1(GND) |
|
2013-12-02 07:02:56 -04:00
|
|
|
* ------------------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2014-06-27 00:39:52 -03:00
|
|
|
class AP_RangeFinder_PulsedLightLRF : public AP_RangeFinder_Backend
|
2013-12-02 07:02:56 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2014-06-27 00:39:52 -03:00
|
|
|
// static detection function
|
2017-08-07 00:41:01 -03:00
|
|
|
static AP_RangeFinder_Backend *detect(uint8_t bus,
|
2017-03-01 00:22:32 -04:00
|
|
|
RangeFinder::RangeFinder_State &_state,
|
2019-02-03 22:21:58 -04:00
|
|
|
AP_RangeFinder_Params &_params,
|
2017-03-01 00:22:32 -04:00
|
|
|
RangeFinder::RangeFinder_Type rftype);
|
2013-12-02 07:02:56 -04:00
|
|
|
|
2014-06-27 00:39:52 -03:00
|
|
|
// update state
|
2016-11-11 17:58:46 -04:00
|
|
|
void update(void) override {}
|
2013-12-02 07:02:56 -04:00
|
|
|
|
2017-08-08 04:32:53 -03:00
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
|
|
|
|
return MAV_DISTANCE_SENSOR_LASER;
|
|
|
|
}
|
2013-12-02 07:02:56 -04:00
|
|
|
|
2014-06-27 00:39:52 -03:00
|
|
|
private:
|
2016-04-14 17:00:38 -03:00
|
|
|
// constructor
|
2017-08-07 00:41:01 -03:00
|
|
|
AP_RangeFinder_PulsedLightLRF(uint8_t bus,
|
2017-03-01 00:22:32 -04:00
|
|
|
RangeFinder::RangeFinder_State &_state,
|
2018-07-04 11:22:17 -03:00
|
|
|
AP_RangeFinder_Params &_params,
|
2017-03-01 00:22:32 -04:00
|
|
|
RangeFinder::RangeFinder_Type rftype);
|
2016-04-14 17:00:38 -03:00
|
|
|
|
2014-06-27 00:39:52 -03:00
|
|
|
// start a reading
|
2016-11-11 17:58:46 -04:00
|
|
|
bool init(void);
|
2017-01-13 15:26:14 -04:00
|
|
|
void timer(void);
|
2016-11-11 17:58:46 -04:00
|
|
|
bool lidar_transfer(const uint8_t *send, unsigned send_len, uint8_t *recv, unsigned recv_len);
|
|
|
|
|
2016-04-14 17:00:38 -03:00
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> _dev;
|
2016-11-11 17:58:46 -04:00
|
|
|
|
|
|
|
uint8_t sw_version;
|
|
|
|
uint8_t hw_version;
|
|
|
|
uint8_t check_reg_counter;
|
|
|
|
bool v2_hardware;
|
2018-07-27 07:22:26 -03:00
|
|
|
bool v3hp_hardware;
|
2016-11-19 20:31:36 -04:00
|
|
|
uint16_t last_distance_cm;
|
2017-03-01 00:22:32 -04:00
|
|
|
RangeFinder::RangeFinder_Type rftype;
|
2016-11-19 20:31:36 -04:00
|
|
|
|
2016-11-11 17:58:46 -04:00
|
|
|
enum { PHASE_MEASURE, PHASE_COLLECT } phase;
|
2013-12-02 07:02:56 -04:00
|
|
|
};
|