From 87b30b45526efcdd992e802c32e79ebc53eaf2f9 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Tue, 8 Aug 2017 08:18:19 -0700 Subject: [PATCH] global: use static method to construct AP_InertialSensor --- APMrover2/Rover.h | 2 +- AntennaTracker/Tracker.h | 2 +- ArduCopter/Copter.h | 2 +- ArduPlane/Plane.h | 2 +- ArduSub/Sub.h | 2 +- Tools/Replay/Replay.h | 2 +- libraries/AP_AHRS/examples/AHRS_Test/AHRS_Test.cpp | 3 +-- .../AP_InertialSensor/examples/INS_generic/INS_generic.cpp | 2 +- .../AP_Mission/examples/AP_Mission_test/AP_Mission_test.cpp | 2 +- libraries/AP_Module/examples/ModuleTest/ModuleTest.cpp | 2 +- .../examples/AP_OpticalFlow_test/AP_OpticalFlow_test.cpp | 2 +- .../AP_Scheduler/examples/Scheduler_test/Scheduler_test.cpp | 2 +- 12 files changed, 12 insertions(+), 13 deletions(-) diff --git a/APMrover2/Rover.h b/APMrover2/Rover.h index e84cfceda2..1340084746 100644 --- a/APMrover2/Rover.h +++ b/APMrover2/Rover.h @@ -154,7 +154,7 @@ private: AP_GPS gps; AP_Baro barometer = AP_Baro::create(); Compass compass = Compass::create(); - AP_InertialSensor ins; + AP_InertialSensor ins = AP_InertialSensor::create(); RangeFinder rangefinder { serial_manager, ROTATION_NONE }; AP_Button button; diff --git a/AntennaTracker/Tracker.h b/AntennaTracker/Tracker.h index 9763e84f25..5551e22654 100644 --- a/AntennaTracker/Tracker.h +++ b/AntennaTracker/Tracker.h @@ -110,7 +110,7 @@ private: Compass compass = Compass::create(); - AP_InertialSensor ins; + AP_InertialSensor ins = AP_InertialSensor::create(); RangeFinder rng {serial_manager, ROTATION_NONE}; diff --git a/ArduCopter/Copter.h b/ArduCopter/Copter.h index 3ab2593e6b..47f134f622 100644 --- a/ArduCopter/Copter.h +++ b/ArduCopter/Copter.h @@ -199,7 +199,7 @@ private: AP_Baro barometer = AP_Baro::create(); Compass compass = Compass::create(); - AP_InertialSensor ins; + AP_InertialSensor ins = AP_InertialSensor::create(); RangeFinder rangefinder {serial_manager, ROTATION_PITCH_270}; struct { diff --git a/ArduPlane/Plane.h b/ArduPlane/Plane.h index 5dc5691efa..ada463605d 100644 --- a/ArduPlane/Plane.h +++ b/ArduPlane/Plane.h @@ -203,7 +203,7 @@ private: AP_Baro barometer = AP_Baro::create(); Compass compass = Compass::create(); - AP_InertialSensor ins; + AP_InertialSensor ins = AP_InertialSensor::create(); RangeFinder rangefinder {serial_manager, ROTATION_PITCH_270}; diff --git a/ArduSub/Sub.h b/ArduSub/Sub.h index 436ae13151..fe4461580d 100644 --- a/ArduSub/Sub.h +++ b/ArduSub/Sub.h @@ -168,7 +168,7 @@ private: TSYS01 celsius; AP_Baro barometer = AP_Baro::create(); Compass compass = Compass::create(); - AP_InertialSensor ins; + AP_InertialSensor ins = AP_InertialSensor::create(); RangeFinder rangefinder {serial_manager, ROTATION_PITCH_270}; struct { diff --git a/Tools/Replay/Replay.h b/Tools/Replay/Replay.h index 4579c31e96..3b356347d2 100644 --- a/Tools/Replay/Replay.h +++ b/Tools/Replay/Replay.h @@ -58,7 +58,7 @@ public: void setup(); void load_parameters(void); - AP_InertialSensor ins; + AP_InertialSensor ins = AP_InertialSensor::create(); AP_Baro barometer = AP_Baro::create(); AP_GPS gps; Compass compass = Compass::create(); diff --git a/libraries/AP_AHRS/examples/AHRS_Test/AHRS_Test.cpp b/libraries/AP_AHRS/examples/AHRS_Test/AHRS_Test.cpp index 4c0f961007..28e6425b38 100644 --- a/libraries/AP_AHRS/examples/AHRS_Test/AHRS_Test.cpp +++ b/libraries/AP_AHRS/examples/AHRS_Test/AHRS_Test.cpp @@ -13,8 +13,7 @@ void loop(); const AP_HAL::HAL& hal = AP_HAL::get_HAL(); -// INS and Baro declaration -AP_InertialSensor ins; +static AP_InertialSensor ins = AP_InertialSensor::create(); static Compass compass = Compass::create(); diff --git a/libraries/AP_InertialSensor/examples/INS_generic/INS_generic.cpp b/libraries/AP_InertialSensor/examples/INS_generic/INS_generic.cpp index f41a0fb5b8..fe1d38e280 100644 --- a/libraries/AP_InertialSensor/examples/INS_generic/INS_generic.cpp +++ b/libraries/AP_InertialSensor/examples/INS_generic/INS_generic.cpp @@ -8,7 +8,7 @@ const AP_HAL::HAL &hal = AP_HAL::get_HAL(); -AP_InertialSensor ins; +static AP_InertialSensor ins = AP_InertialSensor::create(); static void display_offsets_and_scaling(); static void run_test(); diff --git a/libraries/AP_Mission/examples/AP_Mission_test/AP_Mission_test.cpp b/libraries/AP_Mission/examples/AP_Mission_test/AP_Mission_test.cpp index d832e8270e..70cbacf338 100644 --- a/libraries/AP_Mission/examples/AP_Mission_test/AP_Mission_test.cpp +++ b/libraries/AP_Mission/examples/AP_Mission_test/AP_Mission_test.cpp @@ -14,7 +14,7 @@ public: void loop(); private: - AP_InertialSensor ins; + AP_InertialSensor ins = AP_InertialSensor::create(); AP_Baro baro = AP_Baro::create(); AP_GPS gps; Compass compass = Compass::create(); diff --git a/libraries/AP_Module/examples/ModuleTest/ModuleTest.cpp b/libraries/AP_Module/examples/ModuleTest/ModuleTest.cpp index cbccf86b39..ebda17251c 100644 --- a/libraries/AP_Module/examples/ModuleTest/ModuleTest.cpp +++ b/libraries/AP_Module/examples/ModuleTest/ModuleTest.cpp @@ -13,7 +13,7 @@ void loop(); const AP_HAL::HAL& hal = AP_HAL::get_HAL(); // sensor declaration -AP_InertialSensor ins; +static AP_InertialSensor ins = AP_InertialSensor::create(); AP_GPS gps; static AP_Baro baro = AP_Baro::create(); AP_SerialManager serial_manager; diff --git a/libraries/AP_OpticalFlow/examples/AP_OpticalFlow_test/AP_OpticalFlow_test.cpp b/libraries/AP_OpticalFlow/examples/AP_OpticalFlow_test/AP_OpticalFlow_test.cpp index 74d8e4386a..6ded4a5e92 100644 --- a/libraries/AP_OpticalFlow/examples/AP_OpticalFlow_test/AP_OpticalFlow_test.cpp +++ b/libraries/AP_OpticalFlow/examples/AP_OpticalFlow_test/AP_OpticalFlow_test.cpp @@ -24,7 +24,7 @@ public: AP_GPS gps; AP_Baro barometer = AP_Baro::create(); Compass compass = Compass::create(); - AP_InertialSensor ins; + AP_InertialSensor ins = AP_InertialSensor::create(); AP_SerialManager serial_manager; RangeFinder sonar {serial_manager, ROTATION_PITCH_270}; AP_AHRS_NavEKF ahrs{ins, barometer, gps, sonar, EKF2, EKF3, diff --git a/libraries/AP_Scheduler/examples/Scheduler_test/Scheduler_test.cpp b/libraries/AP_Scheduler/examples/Scheduler_test/Scheduler_test.cpp index 7724c42b2d..8e0d139ea2 100644 --- a/libraries/AP_Scheduler/examples/Scheduler_test/Scheduler_test.cpp +++ b/libraries/AP_Scheduler/examples/Scheduler_test/Scheduler_test.cpp @@ -16,7 +16,7 @@ public: private: - AP_InertialSensor ins; + AP_InertialSensor ins = AP_InertialSensor::create(); AP_Scheduler scheduler; uint32_t ins_counter;