From 5086168b03ea55588dfbfcbd8b2686302ef7e09a Mon Sep 17 00:00:00 2001 From: Jonathan Challinger Date: Mon, 19 Oct 2015 17:19:37 -0700 Subject: [PATCH] Copter: add RTL_SPEED parameter --- ArduCopter/Parameters.cpp | 9 +++++++++ ArduCopter/Parameters.h | 1 + ArduCopter/control_rtl.cpp | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index 34c081514e..06c464f5e3 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -128,6 +128,15 @@ const AP_Param::Info Copter::var_info[] = { // @User: Standard GSCALAR(rtl_altitude, "RTL_ALT", RTL_ALT), + // @Param: RTL_SPEED + // @DisplayName: RTL speed + // @Description: Defines the speed in cm/s which the aircraft will attempt to maintain horizontally while flying home. If this is set to zero, WPNAV_SPEED will be used instead. + // @Units: cm/s + // @Range: 0 2000 + // @Increment: 50 + // @User: Standard + GSCALAR(rtl_speed_cms, "RTL_SPEED", 0), + // @Param: RNGFND_GAIN // @DisplayName: Rangefinder gain // @Description: Used to adjust the speed with which the target altitude is changed when objects are sensed below the copter diff --git a/ArduCopter/Parameters.h b/ArduCopter/Parameters.h index c0b5817dfd..e2362d5cc5 100644 --- a/ArduCopter/Parameters.h +++ b/ArduCopter/Parameters.h @@ -375,6 +375,7 @@ public: AP_Float pilot_takeoff_alt; AP_Int16 rtl_altitude; + AP_Int16 rtl_speed_cms; AP_Float sonar_gain; AP_Int8 failsafe_battery_enabled; // battery failsafe enabled diff --git a/ArduCopter/control_rtl.cpp b/ArduCopter/control_rtl.cpp index 27cbc41baf..bc7a27da09 100644 --- a/ArduCopter/control_rtl.cpp +++ b/ArduCopter/control_rtl.cpp @@ -84,6 +84,11 @@ void Copter::rtl_climb_start() // initialise waypoint and spline controller wp_nav.wp_and_spline_init(); + // RTL_SPEED == 0 means use WPNAV_SPEED + if (!is_zero(g.rtl_speed_cms)) { + wp_nav.set_speed_xy(g.rtl_speed_cms); + } + // get horizontal stopping point Vector3f destination; wp_nav.get_wp_stopping_point_xy(destination);