From ea62c24cef7de1019231acfce0d96e6c61fdb89b Mon Sep 17 00:00:00 2001 From: Raouf Date: Wed, 8 Aug 2018 13:48:38 +0900 Subject: [PATCH] Rover: Move set_reverse method to Mode class --- APMrover2/mode.cpp | 8 ++++++++ APMrover2/mode.h | 7 ++++--- APMrover2/mode_auto.cpp | 8 -------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/APMrover2/mode.cpp b/APMrover2/mode.cpp index bba8492f3a..826aee0457 100644 --- a/APMrover2/mode.cpp +++ b/APMrover2/mode.cpp @@ -226,6 +226,14 @@ bool Mode::set_desired_speed(float speed) return false; } +// execute the mission in reverse (i.e. backing up) +void Mode::set_reversed(bool value) +{ + if (_reversed != value) { + _reversed = value; + } +} + void Mode::calc_throttle(float target_speed, bool nudge_allowed, bool avoidance_enabled) { // add in speed nudging diff --git a/APMrover2/mode.h b/APMrover2/mode.h index 8df11a9089..4a75166e23 100644 --- a/APMrover2/mode.h +++ b/APMrover2/mode.h @@ -112,6 +112,9 @@ public: // rtl argument should be true if called from RTL or SmartRTL modes (handled here to avoid duplication) void set_desired_speed_to_default(bool rtl = false); + // execute the mission in reverse (i.e. backing up) + void set_reversed(bool value); + protected: // subclasses override this to perform checks before entering the mode @@ -194,6 +197,7 @@ protected: float _desired_speed_final; // desired speed in m/s when we reach the destination float _speed_error; // ground speed error in m/s uint32_t last_steer_to_wp_ms; // system time of last call to calc_steering_to_waypoint + bool _reversed; // execute the mission by backing up }; @@ -247,8 +251,6 @@ public: // start RTL (within auto) void start_RTL(); - // execute the mission in reverse (i.e. backing up) - void set_reversed(bool value); protected: @@ -272,7 +274,6 @@ private: bool auto_triggered; bool _reached_heading; // true when vehicle has reached desired heading in TurnToHeading sub mode - bool _reversed; // execute the mission by backing up }; diff --git a/APMrover2/mode_auto.cpp b/APMrover2/mode_auto.cpp index 88f2b3501b..b8fc1f754b 100644 --- a/APMrover2/mode_auto.cpp +++ b/APMrover2/mode_auto.cpp @@ -140,14 +140,6 @@ void ModeAuto::start_RTL() } } -// execute the mission in reverse (i.e. backing up) -void ModeAuto::set_reversed(bool value) -{ - if (_reversed != value) { - _reversed = value; - } -} - /* check for triggering of start of auto mode */