Browse Source

AP_Rally: do not take reference to AHRS in constructor

master
Peter Barker 6 years ago committed by Peter Barker
parent
commit
2039fadfb7
  1. 10
      libraries/AP_Rally/AP_Rally.cpp
  2. 10
      libraries/AP_Rally/AP_Rally.h

10
libraries/AP_Rally/AP_Rally.cpp

@ -2,7 +2,9 @@ @@ -2,7 +2,9 @@
/// @brief Handles rally point storage and retrieval.
#include "AP_Rally.h"
#include <AP_AHRS/AP_AHRS.h>
#include <AP_Logger/AP_Logger.h>
#include <StorageManager/StorageManager.h>
// storage object
StorageAccess AP_Rally::_storage(StorageManager::StorageRally);
@ -47,9 +49,7 @@ const AP_Param::GroupInfo AP_Rally::var_info[] = { @@ -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 @@ -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 &current_loc, @@ -148,7 +148,7 @@ Location AP_Rally::calc_best_rally_or_home_location(const Location &current_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;

10
libraries/AP_Rally/AP_Rally.h

@ -15,9 +15,8 @@ @@ -15,9 +15,8 @@
#pragma once
#include <AP_Common/AP_Common.h>
#include <AP_Common/Location.h>
#include <AP_Param/AP_Param.h>
#include <AP_AHRS/AP_AHRS.h>
#include <StorageManager/StorageManager.h>
#define AP_RALLY_WP_SIZE 15 // eeprom size of rally points
@ -36,7 +35,7 @@ struct PACKED RallyLocation { @@ -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: @@ -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 {

Loading…
Cancel
Save