2019-04-08 06:42:46 -03:00
|
|
|
#pragma once
|
|
|
|
|
2019-11-10 22:47:38 -04:00
|
|
|
#include "AP_RangeFinder_Backend.h"
|
2019-04-08 06:42:46 -03:00
|
|
|
|
2022-03-12 06:37:29 -04:00
|
|
|
#ifndef AP_RANGEFINDER_UAVCAN_ENABLED
|
|
|
|
#define AP_RANGEFINDER_UAVCAN_ENABLED (HAL_CANMANAGER_ENABLED && AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if AP_RANGEFINDER_UAVCAN_ENABLED
|
|
|
|
|
2019-04-08 06:42:46 -03:00
|
|
|
#include <AP_UAVCAN/AP_UAVCAN.h>
|
|
|
|
|
|
|
|
class MeasurementCb;
|
|
|
|
|
|
|
|
class AP_RangeFinder_UAVCAN : public AP_RangeFinder_Backend {
|
|
|
|
public:
|
2021-10-28 13:21:38 -03:00
|
|
|
//constructor - registers instance at top RangeFinder driver
|
|
|
|
using AP_RangeFinder_Backend::AP_RangeFinder_Backend;
|
2019-04-08 06:42:46 -03:00
|
|
|
|
|
|
|
void update() override;
|
|
|
|
|
|
|
|
static void subscribe_msgs(AP_UAVCAN* ap_uavcan);
|
|
|
|
static AP_RangeFinder_UAVCAN* get_uavcan_backend(AP_UAVCAN* ap_uavcan, uint8_t node_id, uint8_t address, bool create_new);
|
|
|
|
static AP_RangeFinder_Backend* detect(RangeFinder::RangeFinder_State &_state, AP_RangeFinder_Params &_params);
|
|
|
|
|
|
|
|
static void handle_measurement(AP_UAVCAN* ap_uavcan, uint8_t node_id, const MeasurementCb &cb);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
|
|
|
|
return _sensor_type;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
uint8_t _instance;
|
2019-11-01 02:10:52 -03:00
|
|
|
RangeFinder::Status _status;
|
2019-04-08 06:42:46 -03:00
|
|
|
uint16_t _distance_cm;
|
|
|
|
uint32_t _last_reading_ms;
|
|
|
|
AP_UAVCAN* _ap_uavcan;
|
|
|
|
uint8_t _node_id;
|
|
|
|
bool new_data;
|
|
|
|
MAV_DISTANCE_SENSOR _sensor_type;
|
|
|
|
};
|
2022-03-12 06:37:29 -04:00
|
|
|
#endif // AP_RANGEFINDER_UAVCAN_ENABLED
|