From 477f2824b960ca28ce01e980ab5290f47768cde3 Mon Sep 17 00:00:00 2001 From: Shiv Tyagi Date: Wed, 13 Oct 2021 19:43:03 +0530 Subject: [PATCH] Copter : initialise surface to be tracked This sets the surface to be tracked in SurfaceTracking with the value of SURFTRAK_MODE parameter. Co-Authored-By: Peter Hall <33176108+IamPete1@users.noreply.github.com> --- ArduCopter/Copter.h | 4 +++- ArduCopter/system.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ArduCopter/Copter.h b/ArduCopter/Copter.h index c215779810..e2fc0add4d 100644 --- a/ArduCopter/Copter.h +++ b/ArduCopter/Copter.h @@ -285,9 +285,11 @@ private: }; // set surface to track void set_surface(Surface new_surface); + // initialise surface tracking + void init(Surface surf) { surface = surf; } private: - Surface surface = Surface::GROUND; + Surface surface; uint32_t last_update_ms; // system time of last update to target_alt_cm uint32_t last_glitch_cleared_ms; // system time of last handle glitch recovery bool valid_for_logging; // true if target_alt_cm is valid for logging diff --git a/ArduCopter/system.cpp b/ArduCopter/system.cpp index a24ede2761..816559620e 100644 --- a/ArduCopter/system.cpp +++ b/ArduCopter/system.cpp @@ -76,6 +76,10 @@ void Copter::init_ardupilot() init_rc_in(); // sets up rc channels from radio + // initialise surface to be tracked in SurfaceTracking + // must be before rc init to not override inital switch position + surface_tracking.init((SurfaceTracking::Surface)copter.g2.surftrak_mode.get()); + // allocate the motors class allocate_motors();