diff --git a/libraries/AP_Proximity/AP_Proximity_DroneCAN.cpp b/libraries/AP_Proximity/AP_Proximity_DroneCAN.cpp index 80456962bd..a12a075c5c 100644 --- a/libraries/AP_Proximity/AP_Proximity_DroneCAN.cpp +++ b/libraries/AP_Proximity/AP_Proximity_DroneCAN.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include @@ -32,21 +32,21 @@ ObjectBuffer_TS AP_Proximity_DroneCAN::item //links the Proximity DroneCAN message to this backend -void AP_Proximity_DroneCAN::subscribe_msgs(AP_UAVCAN* ap_uavcan) +void AP_Proximity_DroneCAN::subscribe_msgs(AP_DroneCAN* ap_dronecan) { - if (ap_uavcan == nullptr) { + if (ap_dronecan == nullptr) { 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"); } } //Method to find the backend relating to the node id -AP_Proximity_DroneCAN* AP_Proximity_DroneCAN::get_uavcan_backend(AP_UAVCAN* ap_uavcan, uint8_t node_id, uint8_t address, bool create_new) +AP_Proximity_DroneCAN* AP_Proximity_DroneCAN::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; } @@ -64,7 +64,7 @@ AP_Proximity_DroneCAN* AP_Proximity_DroneCAN::get_uavcan_backend(AP_UAVCAN* ap_u } //Double check if the driver was initialised as DroneCAN Type if (driver != nullptr && (driver->_backend_type == AP_Proximity::Type::DroneCAN)) { - if (driver->_ap_uavcan == ap_uavcan && + if (driver->_ap_dronecan == ap_dronecan && driver->_node_id == node_id) { return driver; } else { @@ -99,8 +99,8 @@ AP_Proximity_DroneCAN* AP_Proximity_DroneCAN::get_uavcan_backend(AP_UAVCAN* ap_u unsigned(i), unsigned(i)); } //Assign node id and respective dronecan driver, for identification - if (driver->_ap_uavcan == nullptr) { - driver->_ap_uavcan = ap_uavcan; + if (driver->_ap_dronecan == nullptr) { + driver->_ap_dronecan = ap_dronecan; driver->_node_id = node_id; break; } @@ -154,10 +154,10 @@ float AP_Proximity_DroneCAN::distance_min() const } //Proximity message handler -void AP_Proximity_DroneCAN::handle_measurement(AP_UAVCAN *ap_uavcan, const CanardRxTransfer& transfer, const ardupilot_equipment_proximity_sensor_Proximity &msg) +void AP_Proximity_DroneCAN::handle_measurement(AP_DroneCAN *ap_dronecan, const CanardRxTransfer& transfer, const ardupilot_equipment_proximity_sensor_Proximity &msg) { //fetch the matching DroneCAN driver, node id and sensor id backend instance - AP_Proximity_DroneCAN* driver = get_uavcan_backend(ap_uavcan, transfer.source_node_id, msg.sensor_id, true); + AP_Proximity_DroneCAN* driver = get_uavcan_backend(ap_dronecan, transfer.source_node_id, msg.sensor_id, true); if (driver == nullptr) { return; } diff --git a/libraries/AP_Proximity/AP_Proximity_DroneCAN.h b/libraries/AP_Proximity/AP_Proximity_DroneCAN.h index 00844c18a6..aa85f7169b 100644 --- a/libraries/AP_Proximity/AP_Proximity_DroneCAN.h +++ b/libraries/AP_Proximity/AP_Proximity_DroneCAN.h @@ -2,7 +2,7 @@ #include "AP_Proximity_Backend.h" -#include +#include #ifndef AP_PROXIMITY_DRONECAN_ENABLED #define AP_PROXIMITY_DRONECAN_ENABLED (HAL_ENABLE_LIBUAVCAN_DRIVERS && HAL_PROXIMITY_ENABLED) @@ -24,18 +24,18 @@ public: float distance_min() const override; - static AP_Proximity_DroneCAN* get_uavcan_backend(AP_UAVCAN* ap_uavcan, uint8_t node_id, uint8_t address, bool create_new); + static AP_Proximity_DroneCAN* get_uavcan_backend(AP_DroneCAN* ap_dronecan, uint8_t node_id, uint8_t address, bool create_new); - static void subscribe_msgs(AP_UAVCAN* ap_uavcan); + static void subscribe_msgs(AP_DroneCAN* ap_dronecan); - static void handle_measurement(AP_UAVCAN *ap_uavcan, const CanardRxTransfer& transfer, const ardupilot_equipment_proximity_sensor_Proximity &msg); + static void handle_measurement(AP_DroneCAN *ap_dronecan, const CanardRxTransfer& transfer, const ardupilot_equipment_proximity_sensor_Proximity &msg); private: uint32_t _last_update_ms; // system time of last message received - AP_UAVCAN* _ap_uavcan; + AP_DroneCAN* _ap_dronecan; uint8_t _node_id; struct ObstacleItem {