AP_RangeFinder: rename AP_UAVCAN to AP_DroneCAN
This commit is contained in:
parent
739fb91439
commit
ac809c84f2
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <AP_HAL/AP_HAL.h>
|
#include <AP_HAL/AP_HAL.h>
|
||||||
#include <AP_CANManager/AP_CANManager.h>
|
#include <AP_CANManager/AP_CANManager.h>
|
||||||
#include <AP_UAVCAN/AP_UAVCAN.h>
|
#include <AP_DroneCAN/AP_DroneCAN.h>
|
||||||
#include <GCS_MAVLink/GCS.h>
|
#include <GCS_MAVLink/GCS.h>
|
||||||
#include <AP_BoardConfig/AP_BoardConfig.h>
|
#include <AP_BoardConfig/AP_BoardConfig.h>
|
||||||
|
|
||||||
@ -13,20 +13,20 @@ extern const AP_HAL::HAL& hal;
|
|||||||
#define debug_range_finder_uavcan(level_debug, can_driver, fmt, args...) do { if ((level_debug) <= AP::can().get_debug_level_driver(can_driver)) { hal.console->printf(fmt, ##args); }} while (0)
|
#define debug_range_finder_uavcan(level_debug, can_driver, fmt, args...) do { if ((level_debug) <= AP::can().get_debug_level_driver(can_driver)) { hal.console->printf(fmt, ##args); }} while (0)
|
||||||
|
|
||||||
//links the rangefinder uavcan message to this backend
|
//links the rangefinder uavcan message to this backend
|
||||||
void AP_RangeFinder_UAVCAN::subscribe_msgs(AP_UAVCAN* ap_uavcan)
|
void AP_RangeFinder_UAVCAN::subscribe_msgs(AP_DroneCAN* ap_dronecan)
|
||||||
{
|
{
|
||||||
if (ap_uavcan == nullptr) {
|
if (ap_dronecan == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Canard::allocate_sub_arg_callback(ap_uavcan, &handle_measurement, ap_uavcan->get_driver_index()) == nullptr) {
|
if (Canard::allocate_sub_arg_callback(ap_dronecan, &handle_measurement, ap_dronecan->get_driver_index()) == nullptr) {
|
||||||
AP_BoardConfig::allocation_error("measurement_sub");
|
AP_BoardConfig::allocation_error("measurement_sub");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Method to find the backend relating to the node id
|
//Method to find the backend relating to the node id
|
||||||
AP_RangeFinder_UAVCAN* AP_RangeFinder_UAVCAN::get_uavcan_backend(AP_UAVCAN* ap_uavcan, uint8_t node_id, uint8_t address, bool create_new)
|
AP_RangeFinder_UAVCAN* AP_RangeFinder_UAVCAN::get_uavcan_backend(AP_DroneCAN* ap_dronecan, uint8_t node_id, uint8_t address, bool create_new)
|
||||||
{
|
{
|
||||||
if (ap_uavcan == nullptr) {
|
if (ap_dronecan == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
AP_RangeFinder_UAVCAN* driver = nullptr;
|
AP_RangeFinder_UAVCAN* driver = nullptr;
|
||||||
@ -39,7 +39,7 @@ AP_RangeFinder_UAVCAN* AP_RangeFinder_UAVCAN::get_uavcan_backend(AP_UAVCAN* ap_u
|
|||||||
}
|
}
|
||||||
//Double check if the driver was initialised as UAVCAN Type
|
//Double check if the driver was initialised as UAVCAN Type
|
||||||
if (driver != nullptr && (driver->_backend_type == RangeFinder::Type::UAVCAN)) {
|
if (driver != nullptr && (driver->_backend_type == RangeFinder::Type::UAVCAN)) {
|
||||||
if (driver->_ap_uavcan == ap_uavcan &&
|
if (driver->_ap_dronecan == ap_dronecan &&
|
||||||
driver->_node_id == node_id) {
|
driver->_node_id == node_id) {
|
||||||
return driver;
|
return driver;
|
||||||
} else {
|
} else {
|
||||||
@ -68,8 +68,8 @@ AP_RangeFinder_UAVCAN* AP_RangeFinder_UAVCAN::get_uavcan_backend(AP_UAVCAN* ap_u
|
|||||||
gcs().send_text(MAV_SEVERITY_INFO, "RangeFinder[%u]: added UAVCAN node %u addr %u",
|
gcs().send_text(MAV_SEVERITY_INFO, "RangeFinder[%u]: added UAVCAN node %u addr %u",
|
||||||
unsigned(i), unsigned(node_id), unsigned(address));
|
unsigned(i), unsigned(node_id), unsigned(address));
|
||||||
//Assign node id and respective uavcan driver, for identification
|
//Assign node id and respective uavcan driver, for identification
|
||||||
if (driver->_ap_uavcan == nullptr) {
|
if (driver->_ap_dronecan == nullptr) {
|
||||||
driver->_ap_uavcan = ap_uavcan;
|
driver->_ap_dronecan = ap_dronecan;
|
||||||
driver->_node_id = node_id;
|
driver->_node_id = node_id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -100,10 +100,10 @@ void AP_RangeFinder_UAVCAN::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//RangeFinder message handler
|
//RangeFinder message handler
|
||||||
void AP_RangeFinder_UAVCAN::handle_measurement(AP_UAVCAN *ap_uavcan, const CanardRxTransfer& transfer, const uavcan_equipment_range_sensor_Measurement &msg)
|
void AP_RangeFinder_UAVCAN::handle_measurement(AP_DroneCAN *ap_dronecan, const CanardRxTransfer& transfer, const uavcan_equipment_range_sensor_Measurement &msg)
|
||||||
{
|
{
|
||||||
//fetch the matching uavcan driver, node id and sensor id backend instance
|
//fetch the matching uavcan driver, node id and sensor id backend instance
|
||||||
AP_RangeFinder_UAVCAN* driver = get_uavcan_backend(ap_uavcan, transfer.source_node_id, msg.sensor_id, true);
|
AP_RangeFinder_UAVCAN* driver = get_uavcan_backend(ap_dronecan, transfer.source_node_id, msg.sensor_id, true);
|
||||||
if (driver == nullptr) {
|
if (driver == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#if AP_RANGEFINDER_UAVCAN_ENABLED
|
#if AP_RANGEFINDER_UAVCAN_ENABLED
|
||||||
|
|
||||||
#include <AP_UAVCAN/AP_UAVCAN.h>
|
#include <AP_DroneCAN/AP_DroneCAN.h>
|
||||||
|
|
||||||
class MeasurementCb;
|
class MeasurementCb;
|
||||||
|
|
||||||
@ -19,11 +19,11 @@ public:
|
|||||||
|
|
||||||
void update() override;
|
void update() override;
|
||||||
|
|
||||||
static void subscribe_msgs(AP_UAVCAN* ap_uavcan);
|
static void subscribe_msgs(AP_DroneCAN* ap_dronecan);
|
||||||
static AP_RangeFinder_UAVCAN* get_uavcan_backend(AP_UAVCAN* ap_uavcan, uint8_t node_id, uint8_t address, bool create_new);
|
static AP_RangeFinder_UAVCAN* get_uavcan_backend(AP_DroneCAN* ap_dronecan, uint8_t node_id, uint8_t address, bool create_new);
|
||||||
static AP_RangeFinder_Backend* detect(RangeFinder::RangeFinder_State &_state, AP_RangeFinder_Params &_params);
|
static AP_RangeFinder_Backend* detect(RangeFinder::RangeFinder_State &_state, AP_RangeFinder_Params &_params);
|
||||||
|
|
||||||
static void handle_measurement(AP_UAVCAN *ap_uavcan, const CanardRxTransfer& transfer, const uavcan_equipment_range_sensor_Measurement &msg);
|
static void handle_measurement(AP_DroneCAN *ap_dronecan, const CanardRxTransfer& transfer, const uavcan_equipment_range_sensor_Measurement &msg);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
|
virtual MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
|
||||||
@ -34,7 +34,7 @@ private:
|
|||||||
RangeFinder::Status _status;
|
RangeFinder::Status _status;
|
||||||
uint16_t _distance_cm;
|
uint16_t _distance_cm;
|
||||||
uint32_t _last_reading_ms;
|
uint32_t _last_reading_ms;
|
||||||
AP_UAVCAN* _ap_uavcan;
|
AP_DroneCAN* _ap_dronecan;
|
||||||
uint8_t _node_id;
|
uint8_t _node_id;
|
||||||
bool new_data;
|
bool new_data;
|
||||||
MAV_DISTANCE_SENSOR _sensor_type;
|
MAV_DISTANCE_SENSOR _sensor_type;
|
||||||
|
Loading…
Reference in New Issue
Block a user