diff --git a/ArduPlane/Parameters.cpp b/ArduPlane/Parameters.cpp index fb425e6dd6ffa..fc4b0d17e800d 100644 --- a/ArduPlane/Parameters.cpp +++ b/ArduPlane/Parameters.cpp @@ -88,23 +88,23 @@ const AP_Param::Info Plane::var_info[] = { // @User: Advanced GSCALAR(stab_pitch_down, "STAB_PITCH_DOWN", 2.0f), - // @Param: GLIDE_SLOPE_MIN - // @DisplayName: Glide slope minimum - // @Description: This controls the minimum altitude change for a waypoint before a glide slope will be used instead of an immediate altitude change. The default value is 15 meters, which helps to smooth out waypoint missions where small altitude changes happen near waypoints. If you don't want glide slopes to be used in missions then you can set this to zero, which will disable glide slope calculations. Otherwise you can set it to a minimum number of meters of altitude error to the destination waypoint before a glide slope will be used to change altitude. + // @Param: ALT_SLOPE_MIN + // @DisplayName: Altitude slope minimum + // @Description: This controls the minimum altitude change for a waypoint before an altitude slope will be used instead of an immediate altitude change. The default value is 15 meters, which helps to smooth out waypoint missions where small altitude changes happen near waypoints. If you don't want altitude slopes to be used in missions then you can set this to zero, which will disable altitude slope calculations. Otherwise you can set it to a minimum number of meters of altitude error to the destination waypoint before an altitude slope will be used to change altitude. // @Range: 0 1000 // @Increment: 1 // @Units: m // @User: Advanced - GSCALAR(glide_slope_min, "GLIDE_SLOPE_MIN", 15), + GSCALAR(alt_slope_min, "ALT_SLOPE_MIN", 15), - // @Param: GLIDE_SLOPE_THR - // @DisplayName: Glide slope threshold - // @Description: This controls the height above the glide slope the plane may be before rebuilding a glide slope. This is useful for smoothing out an autotakeoff + // @Param: ALT_SLOPE_MAXHGT + // @DisplayName: Altitude slope maximum height + // @Description: This controls the height above the altitude slope the plane may be before rebuilding it. This is useful for smoothing out an auto-takeoff. // @Range: 0 100 // @Increment: 1 // @Units: m // @User: Advanced - GSCALAR(glide_slope_threshold, "GLIDE_SLOPE_THR", 5.0), + GSCALAR(alt_slope_max_height, "ALT_SLOPE_MAXHGT", 5.0), // @Param: STICK_MIXING // @DisplayName: Stick Mixing diff --git a/ArduPlane/Parameters.h b/ArduPlane/Parameters.h index 9945869250b4b..6235e83333c48 100644 --- a/ArduPlane/Parameters.h +++ b/ArduPlane/Parameters.h @@ -118,7 +118,7 @@ class Parameters { k_param_terrain, k_param_terrain_follow, k_param_stab_pitch_down_cd_old, // deprecated - k_param_glide_slope_min, + k_param_alt_slope_min, k_param_stab_pitch_down, k_param_terrain_lookahead, k_param_fbwa_tdrag_chan, // unused - moved to RC option @@ -134,7 +134,7 @@ class Parameters { k_param_trim_rc_at_start, // unused k_param_hil_mode_unused, // unused k_param_land_disarm_delay, // unused - moved to AP_Landing - k_param_glide_slope_threshold, + k_param_alt_slope_max_height, k_param_rudder_only, k_param_gcs3, // 93 k_param_gcs_pid_mask, @@ -467,8 +467,8 @@ class Parameters { AP_Int32 terrain_follow; AP_Int16 terrain_lookahead; #endif - AP_Int16 glide_slope_min; - AP_Float glide_slope_threshold; + AP_Int16 alt_slope_min; + AP_Float alt_slope_max_height; AP_Int8 rangefinder_landing; AP_Int8 flap_slewrate; #if HAL_WITH_IO_MCU diff --git a/ArduPlane/Plane.h b/ArduPlane/Plane.h index 86783bed8c151..70d101aafb45e 100644 --- a/ArduPlane/Plane.h +++ b/ArduPlane/Plane.h @@ -775,7 +775,7 @@ class Plane : public AP_Vehicle { int32_t amsl_cm; // Altitude difference between previous and current waypoint in - // centimeters. Used for glide slope handling + // centimeters. Used for altitude slope handling int32_t offset_cm; #if AP_TERRAIN_AVAILABLE @@ -891,7 +891,7 @@ class Plane : public AP_Vehicle { void adjust_nav_pitch_throttle(void); void update_load_factor(void); void adjust_altitude_target(); - void setup_glide_slope(void); + void setup_alt_slope(void); int32_t get_RTL_altitude_cm() const; float relative_ground_altitude(bool use_rangefinder_if_available); float relative_ground_altitude(bool use_rangefinder_if_available, bool use_terrain_if_available); diff --git a/ArduPlane/altitude.cpp b/ArduPlane/altitude.cpp index 40219f26e6012..f3ba72743110d 100644 --- a/ArduPlane/altitude.cpp +++ b/ArduPlane/altitude.cpp @@ -50,9 +50,9 @@ void Plane::check_home_alt_change(void) } /* - setup for a gradual glide slope to the next waypoint, if appropriate + setup for a gradual altitude slope to the next waypoint, if appropriate */ -void Plane::setup_glide_slope(void) +void Plane::setup_alt_slope(void) { // establish the distance we are travelling to the next waypoint, // for calculating out rate of change of altitude @@ -81,8 +81,7 @@ void Plane::setup_glide_slope(void) break; case Mode::Number::AUTO: - - //climb without doing glide slope if option is enabled + // climb without doing slope if option is enabled if (!above_location_current(next_WP_loc) && plane.flight_option_enabled(FlightOptions::IMMEDIATE_CLIMB_IN_AUTO)) { reset_offset_altitude(); break; @@ -190,7 +189,7 @@ void Plane::set_target_altitude_current(void) // target altitude target_altitude.amsl_cm = current_loc.alt; - // reset any glide slope offset + // reset any altitude slope offset reset_offset_altitude(); #if AP_TERRAIN_AVAILABLE @@ -305,14 +304,15 @@ void Plane::set_target_altitude_proportion(const Location &loc, float proportion set_target_altitude_location(loc); proportion = constrain_float(proportion, 0.0f, 1.0f); change_target_altitude(-target_altitude.offset_cm*proportion); - //rebuild the glide slope if we are above it and supposed to be climbing - if(g.glide_slope_threshold > 0) { - if(target_altitude.offset_cm > 0 && calc_altitude_error_cm() < -100 * g.glide_slope_threshold) { + + // rebuild the altitude slope if we are above it and supposed to be climbing + if (g.alt_slope_max_height > 0) { + if (target_altitude.offset_cm > 0 && calc_altitude_error_cm() < -100 * g.alt_slope_max_height) { set_target_altitude_location(loc); set_offset_altitude_location(current_loc, loc); change_target_altitude(-target_altitude.offset_cm*proportion); - //adjust the new target offset altitude to reflect that we are partially already done - if(proportion > 0.0f) + // adjust the new target offset altitude to reflect that we are partially already done + if (proportion > 0.0f) target_altitude.offset_cm = ((float)target_altitude.offset_cm)/proportion; } } @@ -402,7 +402,7 @@ void Plane::check_fbwb_altitude(void) } /* - reset the altitude offset used for glide slopes + reset the altitude offset used for altitude slopes */ void Plane::reset_offset_altitude(void) { @@ -411,10 +411,9 @@ void Plane::reset_offset_altitude(void) /* - reset the altitude offset used for glide slopes, based on difference - between altitude at a destination and a specified start altitude. If - destination is above the starting altitude then the result is - positive. + reset the altitude offset used for slopes, based on difference between + altitude at a destination and a specified start altitude. If destination is + above the starting altitude then the result is positive. */ void Plane::set_offset_altitude_location(const Location &start_loc, const Location &destination_loc) { @@ -435,20 +434,19 @@ void Plane::set_offset_altitude_location(const Location &start_loc, const Locati #endif if (flight_stage != AP_FixedWing::FlightStage::LAND) { - // if we are within GLIDE_SLOPE_MIN meters of the target altitude - // then reset the offset to not use a glide slope. This allows for - // more accurate flight of missions where the aircraft may lose or - // gain a bit of altitude near waypoint turn points due to local - // terrain changes - if (g.glide_slope_min <= 0 || - labs(target_altitude.offset_cm)*0.01f < g.glide_slope_min) { + // if we are within ALT_SLOPE_MIN meters of the target altitude then + // reset the offset to not use an altitude slope. This allows for more + // accurate flight of missions where the aircraft may lose or gain a bit + // of altitude near waypoint turn points due to local terrain changes + if (g.alt_slope_min <= 0 || + labs(target_altitude.offset_cm)*0.01f < g.alt_slope_min) { target_altitude.offset_cm = 0; } } } /* - return true if current_loc is above loc. Used for glide slope + return true if current_loc is above loc. Used for altitude slope calculations. "above" is simple if we are not terrain following, as it just means diff --git a/ArduPlane/commands.cpp b/ArduPlane/commands.cpp index 84abde3eef7c0..34cdf7db1bee9 100644 --- a/ArduPlane/commands.cpp +++ b/ArduPlane/commands.cpp @@ -57,7 +57,7 @@ void Plane::set_next_WP(const Location &loc) // zero out our loiter vals to watch for missed waypoints loiter_angle_reset(); - setup_glide_slope(); + setup_alt_slope(); setup_turn_angle(); // update plane.target_altitude straight away, or if we are too @@ -89,7 +89,7 @@ void Plane::set_guided_WP(const Location &loc) // ----------------------------------------------- set_target_altitude_current(); - setup_glide_slope(); + setup_alt_slope(); setup_turn_angle(); // disable crosstrack, head directly to the point diff --git a/ArduPlane/commands_logic.cpp b/ArduPlane/commands_logic.cpp index b5f91f89d5b42..ad30553c6f61e 100644 --- a/ArduPlane/commands_logic.cpp +++ b/ArduPlane/commands_logic.cpp @@ -346,7 +346,7 @@ void Plane::do_RTL(int32_t rtl_altitude_AMSL_cm) loiter.direction = 1; } - setup_glide_slope(); + setup_alt_slope(); setup_turn_angle(); } diff --git a/ArduPlane/mode_rtl.cpp b/ArduPlane/mode_rtl.cpp index a6f2fef8927c8..3ea9a69047185 100644 --- a/ArduPlane/mode_rtl.cpp +++ b/ArduPlane/mode_rtl.cpp @@ -62,7 +62,7 @@ void ModeRTL::update() if (!plane.rtl.done_climb && alt_threshold_reached) { plane.prev_WP_loc = plane.current_loc; - plane.setup_glide_slope(); + plane.setup_alt_slope(); plane.rtl.done_climb = true; } if (!plane.rtl.done_climb) { diff --git a/Tools/Frame_params/SkyWalkerX8.param b/Tools/Frame_params/SkyWalkerX8.param index f78cf5c500fb4..ae6586311594c 100644 --- a/Tools/Frame_params/SkyWalkerX8.param +++ b/Tools/Frame_params/SkyWalkerX8.param @@ -7,8 +7,8 @@ FBWA_TDRAG_CHAN,0 FBWB_CLIMB_RATE,3 FBWB_ELEV_REV,0 FENCE_ACTION,0 -GLIDE_SLOPE_MIN,15 -GLIDE_SLOPE_THR,1 +ALT_SLOPE_MIN,15 +ALT_SLOPE_MAXHGT,1 GROUND_STEER_ALT,0 GROUND_STEER_DPS,90 KFF_RDDRMIX,0 diff --git a/Tools/Frame_params/SkyWalkerX8_ReverseThrust.param b/Tools/Frame_params/SkyWalkerX8_ReverseThrust.param index 853b9c533bda2..ae5eee1d21a1a 100644 --- a/Tools/Frame_params/SkyWalkerX8_ReverseThrust.param +++ b/Tools/Frame_params/SkyWalkerX8_ReverseThrust.param @@ -7,8 +7,8 @@ FBWA_TDRAG_CHAN,0 FBWB_CLIMB_RATE,3 FBWB_ELEV_REV,0 FENCE_ACTION,0 -GLIDE_SLOPE_MIN,15 -GLIDE_SLOPE_THR,1 +ALT_SLOPE_MIN,15 +ALT_SLOPE_MAXHGT,1 GROUND_STEER_ALT,0 GROUND_STEER_DPS,90 KFF_RDDRMIX,0 diff --git a/Tools/autotest/ArduPlane_Tests/GlideSlopeThresh/rapid-descent-then-climb.txt b/Tools/autotest/ArduPlane_Tests/AltitudeSlopeMaxHeight/rapid-descent-then-climb.txt similarity index 100% rename from Tools/autotest/ArduPlane_Tests/GlideSlopeThresh/rapid-descent-then-climb.txt rename to Tools/autotest/ArduPlane_Tests/AltitudeSlopeMaxHeight/rapid-descent-then-climb.txt diff --git a/Tools/autotest/arduplane.py b/Tools/autotest/arduplane.py index a05ac4f33c907..b251c66a8f515 100644 --- a/Tools/autotest/arduplane.py +++ b/Tools/autotest/arduplane.py @@ -5184,20 +5184,20 @@ def Hirth(self): '''Test Hirth EFI''' self.EFITest(8, "Hirth", "hirth") - def GlideSlopeThresh(self): - '''Test rebuild glide slope if above and climbing''' + def AltitudeSlopeMaxHeight(self): + '''Test rebuild altitude slope if above and climbing''' - # Test that GLIDE_SLOPE_THRESHOLD correctly controls re-planning glide slope + # Test that ALT_SLOPE_MAXHGT correctly controls re-planning altitude slope # in the scenario that aircraft is above planned slope and slope is positive (climbing). # # - # Behaviour with GLIDE_SLOPE_THRESH = 0 (no slope replanning) + # Behaviour with ALT_SLOPE_MAXHGT = 0 (no slope replanning) # (2).. __(4) # | \..__/ # | __/ # (3) # - # Behaviour with GLIDE_SLOPE_THRESH = 5 (slope replanning when >5m error) + # Behaviour with ALT_SLOPE_MAXHGT = 5 (slope replanning when >5m error) # (2)........__(4) # | __/ # | __/ @@ -5212,9 +5212,9 @@ def GlideSlopeThresh(self): self.arm_vehicle() # - # Initial run with GLIDE_SLOPE_THR = 5 (default). + # Initial run with ALT_SLOPE_MAXHGT = 5 (default). # - self.set_parameter("GLIDE_SLOPE_THR", 5) + self.set_parameter("ALT_SLOPE_MAXHGT", 5) # Wait for waypoint commanding rapid descent, followed by climb. self.wait_current_waypoint(5, timeout=1200) @@ -5240,9 +5240,9 @@ def GlideSlopeThresh(self): self.set_current_waypoint(2) # - # Second run with GLIDE_SLOPE_THR = 0 (no re-plan). + # Second run with ALT_SLOPE_MAXHGT = 0 (no re-plan). # - self.set_parameter("GLIDE_SLOPE_THR", 0) + self.set_parameter("ALT_SLOPE_MAXHGT", 0) # Wait for waypoint commanding rapid descent, followed by climb. self.wait_current_waypoint(5, timeout=1200) @@ -6903,7 +6903,7 @@ def tests1b(self): self.Hirth, self.MSP_DJI, self.SpeedToFly, - self.GlideSlopeThresh, + self.AltitudeSlopeMaxHeight, self.HIGH_LATENCY2, self.MidAirDisarmDisallowed, self.AerobaticsScripting, diff --git a/Tools/autotest/default_params/vee-gull_005.param b/Tools/autotest/default_params/vee-gull_005.param index c5305222954ab..204f51460132f 100644 --- a/Tools/autotest/default_params/vee-gull_005.param +++ b/Tools/autotest/default_params/vee-gull_005.param @@ -216,8 +216,8 @@ FS_LONG_TIMEOUT,5 FS_SHORT_ACTN,0 FS_SHORT_TIMEOUT,1.5 GCS_PID_MASK,0 -GLIDE_SLOPE_MIN,15 -GLIDE_SLOPE_THR,5 +ALT_SLOPE_MIN,15 +ALT_SLOPE_MAXHGT,5 GPS_AUTO_CONFIG,1 GPS_AUTO_SWITCH,1 GPS_BLEND_MASK,5 diff --git a/libraries/SITL/examples/SilentWings/Params/Rolladen-Schneider-LS8b.param b/libraries/SITL/examples/SilentWings/Params/Rolladen-Schneider-LS8b.param index 5bf3c82c55360..c8488b368133b 100644 --- a/libraries/SITL/examples/SilentWings/Params/Rolladen-Schneider-LS8b.param +++ b/libraries/SITL/examples/SilentWings/Params/Rolladen-Schneider-LS8b.param @@ -165,8 +165,8 @@ FS_LONG_TIMEOUT,5 FS_SHORT_ACTN,0 FS_SHORT_TIMEOUT,1.5 GCS_PID_MASK,0 -GLIDE_SLOPE_MIN,15 -GLIDE_SLOPE_THR,5 +ALT_SLOPE_MIN,15 +ALT_SLOPE_MAXHGT,5 GPS_AUTO_CONFIG,1 GPS_AUTO_SWITCH,1 GPS_BLEND_MASK,5 diff --git a/libraries/SITL/examples/SilentWings/Params/Schleicher-ASW27B.param b/libraries/SITL/examples/SilentWings/Params/Schleicher-ASW27B.param index 5eb9fc9cde642..444dc6f5345dd 100644 --- a/libraries/SITL/examples/SilentWings/Params/Schleicher-ASW27B.param +++ b/libraries/SITL/examples/SilentWings/Params/Schleicher-ASW27B.param @@ -169,8 +169,8 @@ FS_LONG_TIMEOUT,5 FS_SHORT_ACTN,0 FS_SHORT_TIMEOUT,1.5 GCS_PID_MASK,0 -GLIDE_SLOPE_MIN,15 -GLIDE_SLOPE_THR,5 +ALT_SLOPE_MIN,15 +ALT_SLOPE_MAXHGT,5 GPS_AUTO_CONFIG,1 GPS_AUTO_SWITCH,1 GPS_BLEND_MASK,5