From 2039fadfb786eb7a273a7c754e9943013d7a1513 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 18 Feb 2019 20:33:09 +1100 Subject: [PATCH] AP_Rally: do not take reference to AHRS in constructor --- libraries/AP_Rally/AP_Rally.cpp | 10 +++++----- libraries/AP_Rally/AP_Rally.h | 10 +++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/libraries/AP_Rally/AP_Rally.cpp b/libraries/AP_Rally/AP_Rally.cpp index 7e159c3a0c..27fe045f74 100644 --- a/libraries/AP_Rally/AP_Rally.cpp +++ b/libraries/AP_Rally/AP_Rally.cpp @@ -2,7 +2,9 @@ /// @brief Handles rally point storage and retrieval. #include "AP_Rally.h" +#include #include +#include // storage object StorageAccess AP_Rally::_storage(StorageManager::StorageRally); @@ -47,9 +49,7 @@ const AP_Param::GroupInfo AP_Rally::var_info[] = { }; // constructor -AP_Rally::AP_Rally(AP_AHRS &ahrs) - : _ahrs(ahrs) - , _last_change_time_ms(0xFFFFFFFF) +AP_Rally::AP_Rally() { #if CONFIG_HAL_BOARD == HAL_BOARD_SITL if (_singleton != nullptr) { @@ -107,7 +107,7 @@ Location AP_Rally::rally_location_to_location(const RallyLocation &rally_loc) co //Currently can't do true AGL on the APM. Relative altitudes are //relative to HOME point's altitude. Terrain on the board is inbound //for the PX4, though. This line will need to be updated when that happens: - ret.alt = (rally_loc.alt*100UL) + _ahrs.get_home().alt; + ret.alt = (rally_loc.alt*100UL) + AP::ahrs().get_home().alt; ret.lat = rally_loc.lat; ret.lng = rally_loc.lng; @@ -148,7 +148,7 @@ Location AP_Rally::calc_best_rally_or_home_location(const Location ¤t_loc, { RallyLocation ral_loc = {}; Location return_loc = {}; - const struct Location &home_loc = _ahrs.get_home(); + const struct Location &home_loc = AP::ahrs().get_home(); // no valid rally point, return home position return_loc = home_loc; diff --git a/libraries/AP_Rally/AP_Rally.h b/libraries/AP_Rally/AP_Rally.h index 72cf452e0e..cbe44fd535 100644 --- a/libraries/AP_Rally/AP_Rally.h +++ b/libraries/AP_Rally/AP_Rally.h @@ -15,9 +15,8 @@ #pragma once #include +#include #include -#include -#include #define AP_RALLY_WP_SIZE 15 // eeprom size of rally points @@ -36,7 +35,7 @@ struct PACKED RallyLocation { /// @brief Object managing Rally Points class AP_Rally { public: - AP_Rally(AP_AHRS &ahrs); + AP_Rally(); /* Do not allow copies */ AP_Rally(const AP_Rally &other) = delete; @@ -73,15 +72,12 @@ private: static StorageAccess _storage; - // internal variables - const AP_AHRS& _ahrs; // used only for home position - // parameters AP_Int8 _rally_point_total_count; AP_Float _rally_limit_km; AP_Int8 _rally_incl_home; - uint32_t _last_change_time_ms; + uint32_t _last_change_time_ms = 0xFFFFFFFF; }; namespace AP {