ardupilot/libraries/AP_RangeFinder/AP_RangeFinder_MAVLink.h
Randy Mackay 1b0f0a7559 AP_RangeFinder: support last_reading_ms
Benewake, LeddarOne, LightWareSerial, MAVLink, MaxsonarI2CXL, MaxsonarSerialLV, NMEA, PX4_PWM, uLanding and Wasp already stored the last read time so for these drivers, this change just moves that storage to the state structure
analog, BBB_PRU, Bebop, LightWareI2C, PulsedLightLRF, TeraRangerI2C, VL53L0X did not store the last read time so this was added
2018-08-28 09:23:38 +09:00

40 lines
815 B
C++

#pragma once
#include "RangeFinder.h"
#include "RangeFinder_Backend.h"
// Data timeout
#define AP_RANGEFINDER_MAVLINK_TIMEOUT_MS 500
class AP_RangeFinder_MAVLink : public AP_RangeFinder_Backend
{
public:
// constructor
AP_RangeFinder_MAVLink(RangeFinder::RangeFinder_State &_state);
// static detection function
static bool detect();
// update state
void update(void);
// Get update from mavlink
void handle_msg(mavlink_message_t *msg);
protected:
MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
return sensor_type;
}
private:
uint16_t distance_cm;
// start a reading
static bool start_reading(void);
static bool get_reading(uint16_t &reading_cm);
MAV_DISTANCE_SENSOR sensor_type = MAV_DISTANCE_SENSOR_UNKNOWN;
};