diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_BBB_PRU.cpp b/libraries/AP_RangeFinder/AP_RangeFinder_BBB_PRU.cpp index 372bab31de..dca89c814d 100644 --- a/libraries/AP_RangeFinder/AP_RangeFinder_BBB_PRU.cpp +++ b/libraries/AP_RangeFinder/AP_RangeFinder_BBB_PRU.cpp @@ -34,22 +34,13 @@ extern const AP_HAL::HAL& hal; volatile struct range *rangerpru; -/* - The constructor also initialises the rangefinder. Note that this - constructor is not called until detect() returns true, so we - already know that we should setup the rangefinder -*/ -AP_RangeFinder_BBB_PRU::AP_RangeFinder_BBB_PRU(RangeFinder::RangeFinder_State &_state, AP_RangeFinder_Params &_params) : - AP_RangeFinder_Backend(_state, _params) -{ -} - /* Stop PRU, load firmware (check if firmware is present), start PRU. If we get a result the sensor seems to be there. */ bool AP_RangeFinder_BBB_PRU::detect() { + //The constructor is called when the detect() method returns true, more on this in the header file bool result = true; uint32_t mem_fd; uint32_t *ctrl; diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_BBB_PRU.h b/libraries/AP_RangeFinder/AP_RangeFinder_BBB_PRU.h index bf60c4d4b6..0335928d02 100644 --- a/libraries/AP_RangeFinder/AP_RangeFinder_BBB_PRU.h +++ b/libraries/AP_RangeFinder/AP_RangeFinder_BBB_PRU.h @@ -20,8 +20,13 @@ struct range { class AP_RangeFinder_BBB_PRU : public AP_RangeFinder_Backend { public: - // constructor - AP_RangeFinder_BBB_PRU(RangeFinder::RangeFinder_State &_state, AP_RangeFinder_Params &_params); + /* + Constructor: + The constructor also initialises the rangefinder. Note that this + constructor is not called until detect() returns true, so we + already know that we should setup the rangefinder + */ + using AP_RangeFinder_Backend::AP_RangeFinder_Backend; // static detection function static bool detect(); diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_UAVCAN.cpp b/libraries/AP_RangeFinder/AP_RangeFinder_UAVCAN.cpp index 41a396374e..252e672058 100644 --- a/libraries/AP_RangeFinder/AP_RangeFinder_UAVCAN.cpp +++ b/libraries/AP_RangeFinder/AP_RangeFinder_UAVCAN.cpp @@ -16,13 +16,6 @@ extern const AP_HAL::HAL& hal; //UAVCAN Frontend Registry Binder UC_REGISTRY_BINDER(MeasurementCb, uavcan::equipment::range_sensor::Measurement); -/* - constructor - registers instance at top RangeFinder driver - */ -AP_RangeFinder_UAVCAN::AP_RangeFinder_UAVCAN(RangeFinder::RangeFinder_State &_state, AP_RangeFinder_Params &_params) : - AP_RangeFinder_Backend(_state, _params) -{} - //links the rangefinder uavcan message to this backend void AP_RangeFinder_UAVCAN::subscribe_msgs(AP_UAVCAN* ap_uavcan) { diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_UAVCAN.h b/libraries/AP_RangeFinder/AP_RangeFinder_UAVCAN.h index ec200b3962..2f48c260c8 100644 --- a/libraries/AP_RangeFinder/AP_RangeFinder_UAVCAN.h +++ b/libraries/AP_RangeFinder/AP_RangeFinder_UAVCAN.h @@ -9,7 +9,8 @@ class MeasurementCb; class AP_RangeFinder_UAVCAN : public AP_RangeFinder_Backend { public: - AP_RangeFinder_UAVCAN(RangeFinder::RangeFinder_State &_state, AP_RangeFinder_Params &_params); + //constructor - registers instance at top RangeFinder driver + using AP_RangeFinder_Backend::AP_RangeFinder_Backend; void update() override;