From 003851a5c1df90d210d01ec44ea368b9cf9a8ee2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Dec 2017 12:06:14 +1100 Subject: [PATCH] AP_SmartRTL: removed create() method for objects See discussion here: https://github.com/ArduPilot/ardupilot/issues/7331 we were getting some uninitialised variables. While it only showed up in AP_SbusOut, it means we can't be sure it won't happen on other objects, so safest to remove the approach Thanks to assistance from Lucas, Peter and Francisco --- .../examples/SmartRTL_test/SmartRTL_test.cpp | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/libraries/AP_SmartRTL/examples/SmartRTL_test/SmartRTL_test.cpp b/libraries/AP_SmartRTL/examples/SmartRTL_test/SmartRTL_test.cpp index 562eb2a81b..863b9c4984 100644 --- a/libraries/AP_SmartRTL/examples/SmartRTL_test/SmartRTL_test.cpp +++ b/libraries/AP_SmartRTL/examples/SmartRTL_test/SmartRTL_test.cpp @@ -12,26 +12,25 @@ const AP_HAL::HAL &hal = AP_HAL::get_HAL(); // INS and Baro declaration -static AP_InertialSensor ins = AP_InertialSensor::create(); -static Compass compass = Compass::create(); -static AP_GPS gps = AP_GPS::create(); -static AP_Baro barometer = AP_Baro::create(); -static AP_SerialManager serial_manager = AP_SerialManager::create(); +static AP_InertialSensor ins; +static Compass compass; +static AP_GPS gps; +static AP_Baro barometer; +static AP_SerialManager serial_manager; class DummyVehicle { public: - RangeFinder rangefinder = RangeFinder::create(serial_manager, ROTATION_PITCH_270); - NavEKF2 EKF2 = NavEKF2::create(&ahrs, barometer, rangefinder); - NavEKF3 EKF3 = NavEKF3::create(&ahrs, barometer, rangefinder); - AP_AHRS_NavEKF ahrs = AP_AHRS_NavEKF::create(ins, barometer, gps, EKF2, EKF3, - AP_AHRS_NavEKF::FLAG_ALWAYS_USE_EKF); + RangeFinder rangefinder{serial_manager, ROTATION_PITCH_270}; + NavEKF2 EKF2{&ahrs, barometer, rangefinder}; + NavEKF3 EKF3{&ahrs, barometer, rangefinder}; + AP_AHRS_NavEKF ahrs{ins, barometer, gps, EKF2, EKF3, AP_AHRS_NavEKF::FLAG_ALWAYS_USE_EKF}; }; static DummyVehicle vehicle; AP_AHRS_NavEKF &ahrs(vehicle.ahrs); AP_SmartRTL smart_rtl{ahrs, true}; -AP_BoardConfig board_config = AP_BoardConfig::create(); +AP_BoardConfig board_config; void setup(); void loop();