2022-09-27 16:44:39 -03:00
|
|
|
#pragma once
|
|
|
|
|
2023-04-05 09:25:54 -03:00
|
|
|
#include "AP_Proximity_config.h"
|
2022-09-27 16:44:39 -03:00
|
|
|
|
2023-04-05 09:25:54 -03:00
|
|
|
#if AP_PROXIMITY_DRONECAN_ENABLED
|
2022-09-27 16:44:39 -03:00
|
|
|
|
2023-04-05 09:25:54 -03:00
|
|
|
#include "AP_Proximity_Backend.h"
|
2022-09-27 16:44:39 -03:00
|
|
|
|
2023-04-05 09:25:54 -03:00
|
|
|
#include <AP_DroneCAN/AP_DroneCAN.h>
|
2022-09-27 16:44:39 -03:00
|
|
|
|
|
|
|
class AP_Proximity_DroneCAN : public AP_Proximity_Backend
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
using AP_Proximity_Backend::AP_Proximity_Backend;
|
|
|
|
|
|
|
|
// update state
|
|
|
|
void update(void) override;
|
|
|
|
|
|
|
|
// get maximum and minimum distances (in meters) of sensor
|
|
|
|
float distance_max() const override;
|
|
|
|
float distance_min() const override;
|
|
|
|
|
|
|
|
|
2023-04-08 01:27:51 -03:00
|
|
|
static AP_Proximity_DroneCAN* get_dronecan_backend(AP_DroneCAN* ap_dronecan, uint8_t node_id, uint8_t address, bool create_new);
|
2022-09-27 16:44:39 -03:00
|
|
|
|
|
|
|
|
2023-04-06 21:18:02 -03:00
|
|
|
static void subscribe_msgs(AP_DroneCAN* ap_dronecan);
|
2022-09-27 16:44:39 -03:00
|
|
|
|
2023-04-06 21:18:02 -03:00
|
|
|
static void handle_measurement(AP_DroneCAN *ap_dronecan, const CanardRxTransfer& transfer, const ardupilot_equipment_proximity_sensor_Proximity &msg);
|
2022-09-27 16:44:39 -03:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
uint32_t _last_update_ms; // system time of last message received
|
|
|
|
|
2023-04-06 21:18:02 -03:00
|
|
|
AP_DroneCAN* _ap_dronecan;
|
2022-09-27 16:44:39 -03:00
|
|
|
uint8_t _node_id;
|
|
|
|
|
|
|
|
struct ObstacleItem {
|
|
|
|
float yaw_deg;
|
|
|
|
float pitch_deg;
|
|
|
|
float distance_m;
|
|
|
|
};
|
|
|
|
|
|
|
|
static ObjectBuffer_TS<ObstacleItem> items;
|
|
|
|
|
|
|
|
AP_Proximity::Status _status;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // AP_PROXIMITY_DRONECAN_ENABLED
|