From e479e353333c9675492ae85354c0fac16c206f33 Mon Sep 17 00:00:00 2001 From: Rahul Date: Sat, 27 Apr 2024 15:42:06 +0530 Subject: [PATCH] copter:acceleration limit in land --- ArduCopter/Parameters.cpp | 9 +++++++++ ArduCopter/Parameters.h | 4 ++-- ArduCopter/mode_auto.cpp | 11 +++++++++-- ArduCopter/mode_land.cpp | 11 +++++++++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index 0d17611056..96f8b93daa 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -188,6 +188,15 @@ const AP_Param::Info Copter::var_info[] = { // @User: Standard GSCALAR(wp_yaw_behavior, "WP_YAW_BEHAVIOR", WP_YAW_BEHAVIOR_DEFAULT), + // @Param: LAND_ACCEL + // @DisplayName: Land acceleration + // @Description: Limits maximum acceleration during landing. WPNAV_ACCEL is used if this parameter is zero + // @Units: cm/s/s + // @Range: 0 100 + // @Increment: 1 + // @User: Advanced + GSCALAR(land_accel_limit, "LAND_ACCEL", 0), + // @Param: LAND_SPEED // @DisplayName: Land speed // @Description: The descent speed for the final stage of landing in cm/s diff --git a/ArduCopter/Parameters.h b/ArduCopter/Parameters.h index 0e3d8920aa..363947b992 100644 --- a/ArduCopter/Parameters.h +++ b/ArduCopter/Parameters.h @@ -381,13 +381,13 @@ public: k_param_vehicle = 257, // vehicle common block of parameters k_param_throw_altitude_min, k_param_throw_altitude_max, - + k_param_land_accel_limit, // the k_param_* space is 9-bits in size // 511: reserved }; AP_Int16 format_version; - + AP_Float land_accel_limit; // Telemetry control // AP_Int16 sysid_this_mav; diff --git a/ArduCopter/mode_auto.cpp b/ArduCopter/mode_auto.cpp index 12233d9f48..a99452ac55 100644 --- a/ArduCopter/mode_auto.cpp +++ b/ArduCopter/mode_auto.cpp @@ -409,8 +409,15 @@ bool ModeAuto::wp_start(const Location& dest_loc) void ModeAuto::land_start() { // set horizontal speed and acceleration limits - pos_control->set_max_speed_accel_xy(wp_nav->get_default_speed_xy(), wp_nav->get_wp_acceleration()); - pos_control->set_correction_speed_accel_xy(wp_nav->get_default_speed_xy(), wp_nav->get_wp_acceleration()); + const float adjusted_acceleration = (float)copter.g.land_accel_limit; + + if (adjusted_acceleration > 0.0f){ + pos_control->set_max_speed_accel_xy(wp_nav->get_default_speed_xy(),adjusted_acceleration ); + pos_control->set_correction_speed_accel_xy(wp_nav->get_default_speed_xy(), adjusted_acceleration); + } else { + pos_control->set_max_speed_accel_xy(wp_nav->get_default_speed_xy(), wp_nav->get_wp_acceleration()); + pos_control->set_correction_speed_accel_xy(wp_nav->get_default_speed_xy(), wp_nav->get_wp_acceleration()); + } // initialise the vertical position controller if (!pos_control->is_active_xy()) { diff --git a/ArduCopter/mode_land.cpp b/ArduCopter/mode_land.cpp index 1f34e20fbf..698873fc8e 100644 --- a/ArduCopter/mode_land.cpp +++ b/ArduCopter/mode_land.cpp @@ -7,8 +7,15 @@ bool ModeLand::init(bool ignore_checks) control_position = copter.position_ok(); // set horizontal speed and acceleration limits - pos_control->set_max_speed_accel_xy(wp_nav->get_default_speed_xy(), wp_nav->get_wp_acceleration()); - pos_control->set_correction_speed_accel_xy(wp_nav->get_default_speed_xy(), wp_nav->get_wp_acceleration()); + const float adjusted_acceleration = (float)copter.g.land_accel_limit; + + if (adjusted_acceleration > 0.0f){ + pos_control->set_max_speed_accel_xy(wp_nav->get_default_speed_xy(),adjusted_acceleration ); + pos_control->set_correction_speed_accel_xy(wp_nav->get_default_speed_xy(), adjusted_acceleration); + } else { + pos_control->set_max_speed_accel_xy(wp_nav->get_default_speed_xy(), wp_nav->get_wp_acceleration()); + pos_control->set_correction_speed_accel_xy(wp_nav->get_default_speed_xy(), wp_nav->get_wp_acceleration()); + } // initialise the horizontal position controller if (control_position && !pos_control->is_active_xy()) {