From 89bc68e12b9eb613db62004a7e8b49394a9d390d Mon Sep 17 00:00:00 2001
From: bresch <brescianimathieu@gmail.com>
Date: Thu, 25 Apr 2019 10:17:46 +0200
Subject: [PATCH] Auto - Rename MC_YAWRAUTO_MAX -> MPC_YAWRAUTO_MAX

---
 .../init.d/airframes/13005_vtol_AAERT_quad        |  3 ++-
 .../init.d/airframes/13006_vtol_standard_delta    |  2 +-
 .../init.d/airframes/13007_vtol_AAVVT_quad        |  3 ++-
 .../init.d/airframes/13008_QuadRanger             |  2 +-
 .../init.d/airframes/13009_vtol_spt_ranger        |  2 +-
 .../init.d/airframes/13013_deltaquad              |  2 +-
 .../init.d/airframes/13014_vtol_babyshark         |  2 +-
 src/lib/FlightTasks/tasks/Auto/FlightTaskAuto.cpp |  4 ++--
 src/lib/FlightTasks/tasks/Auto/FlightTaskAuto.hpp |  2 +-
 .../mc_att_control/mc_att_control_params.c        | 15 ---------------
 .../mc_pos_control/mc_pos_control_params.c        | 15 +++++++++++++++
 11 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/ROMFS/px4fmu_common/init.d/airframes/13005_vtol_AAERT_quad b/ROMFS/px4fmu_common/init.d/airframes/13005_vtol_AAERT_quad
index 2c46ca0788..0d4c2b5984 100644
--- a/ROMFS/px4fmu_common/init.d/airframes/13005_vtol_AAERT_quad
+++ b/ROMFS/px4fmu_common/init.d/airframes/13005_vtol_AAERT_quad
@@ -42,7 +42,8 @@ then
 	param set MC_YAWRATE_D 0
 	param set MC_YAWRATE_FF 0
 	param set MC_YAWRATE_MAX 40
-	param set MC_YAWRAUTO_MAX 40
+
+	param set MPC_YAWRAUTO_MAX 40
 
 	param set FW_PR_FF 0.5
 	param set FW_PR_I 0.02
diff --git a/ROMFS/px4fmu_common/init.d/airframes/13006_vtol_standard_delta b/ROMFS/px4fmu_common/init.d/airframes/13006_vtol_standard_delta
index 1e594a63ec..cd9329f35d 100644
--- a/ROMFS/px4fmu_common/init.d/airframes/13006_vtol_standard_delta
+++ b/ROMFS/px4fmu_common/init.d/airframes/13006_vtol_standard_delta
@@ -36,11 +36,11 @@ then
 	param set MC_YAWRATE_D 0
 	param set MC_YAWRATE_FF 0
 	param set MC_YAWRATE_MAX 50
-	param set MC_YAWRAUTO_MAX 20
 
 	param set MPC_XY_P 0.8
 	param set MPC_XY_VEL_P 0.1
 	param set MPC_ACC_HOR_MAX 2
+	param set MPC_YAWRAUTO_MAX 20
 
 	param set PWM_AUX_DIS3 950
 	param set PWM_RATE 400
diff --git a/ROMFS/px4fmu_common/init.d/airframes/13007_vtol_AAVVT_quad b/ROMFS/px4fmu_common/init.d/airframes/13007_vtol_AAVVT_quad
index 5c84469e20..d63467ab27 100644
--- a/ROMFS/px4fmu_common/init.d/airframes/13007_vtol_AAVVT_quad
+++ b/ROMFS/px4fmu_common/init.d/airframes/13007_vtol_AAVVT_quad
@@ -28,7 +28,8 @@ then
 	param set MC_YAWRATE_D 0
 	param set MC_YAWRATE_FF 0
 	param set MC_YAWRATE_MAX 40
-	param set MC_YAWRAUTO_MAX 40
+
+	param set MPC_YAWRAUTO_MAX 40
 
 	param set PWM_AUX_DIS5 950
 	param set PWM_RATE 400
diff --git a/ROMFS/px4fmu_common/init.d/airframes/13008_QuadRanger b/ROMFS/px4fmu_common/init.d/airframes/13008_QuadRanger
index b2e1a35c72..61f9ab4678 100644
--- a/ROMFS/px4fmu_common/init.d/airframes/13008_QuadRanger
+++ b/ROMFS/px4fmu_common/init.d/airframes/13008_QuadRanger
@@ -36,12 +36,12 @@ then
 	param set MC_YAWRATE_D 0
 	param set MC_YAWRATE_FF 0
 	param set MC_YAWRATE_MAX 40
-	param set MC_YAWRAUTO_MAX 40
 
 	param set MPC_ACC_HOR_MAX 2
 	param set MPC_Z_VEL_MAX_DN 1.5
 	param set MPC_TKO_SPEED 1.5
 	param set MPC_LAND_SPEED 0.8
+	param set MPC_YAWRAUTO_MAX 40
 
 	param set PWM_AUX_DIS5 950
 	param set PWM_AUX_REV1 1
diff --git a/ROMFS/px4fmu_common/init.d/airframes/13009_vtol_spt_ranger b/ROMFS/px4fmu_common/init.d/airframes/13009_vtol_spt_ranger
index c9121a5817..376837da5c 100644
--- a/ROMFS/px4fmu_common/init.d/airframes/13009_vtol_spt_ranger
+++ b/ROMFS/px4fmu_common/init.d/airframes/13009_vtol_spt_ranger
@@ -36,7 +36,6 @@ then
 	param set MC_YAWRATE_I 0.02
 	param set MC_YAWRATE_MAX 40
 	param set MC_YAWRATE_P 0.18
-	param set MC_YAWRAUTO_MAX 40
 
 	param set MIS_TAKEOFF_ALT 2.5
 	param set MIS_YAW_TMT 20
@@ -56,6 +55,7 @@ then
 	param set MPC_XY_VEL_P    0.05
 	param set MPC_Z_P 0.5
 	param set MPC_Z_VEL_P 0.1
+	param set MPC_YAWRAUTO_MAX 40
 
 	param set NAV_ACC_RAD 3
 
diff --git a/ROMFS/px4fmu_common/init.d/airframes/13013_deltaquad b/ROMFS/px4fmu_common/init.d/airframes/13013_deltaquad
index ae87fb89c0..e391bdc693 100644
--- a/ROMFS/px4fmu_common/init.d/airframes/13013_deltaquad
+++ b/ROMFS/px4fmu_common/init.d/airframes/13013_deltaquad
@@ -88,7 +88,6 @@ then
 	param set MC_YAWRATE_D 0
 	param set MC_YAWRATE_FF 0
 	param set MC_YAWRATE_MAX 20
-	param set MC_YAWRAUTO_MAX 20
 	param set MC_AIRMODE 1
 
 	param set MIS_DIST_1WP 100
@@ -111,6 +110,7 @@ then
 	param set MPC_XY_CRUISE 5
 	param set MPC_TILTMAX_AIR 25
 	param set MPC_TILTMAX_LND 25
+	param set MPC_YAWRAUTO_MAX 20
 
 	param set NAV_DLL_ACT 0
 	param set NAV_LOITER_RAD 100
diff --git a/ROMFS/px4fmu_common/init.d/airframes/13014_vtol_babyshark b/ROMFS/px4fmu_common/init.d/airframes/13014_vtol_babyshark
index 7752145b5b..68e07b0689 100644
--- a/ROMFS/px4fmu_common/init.d/airframes/13014_vtol_babyshark
+++ b/ROMFS/px4fmu_common/init.d/airframes/13014_vtol_babyshark
@@ -42,7 +42,6 @@ then
 	param set MC_YAWRATE_I 0.15
 	param set MC_YAWRATE_MAX 40
 	param set MC_YAWRATE_P 0.3
-	param set MC_YAWRAUTO_MAX 40
 
 	param set MPC_MAN_TILT_MAX 25
 	param set MPC_MAN_Y_MAX 40
@@ -53,6 +52,7 @@ then
 	param set MPC_VEL_MANUAL 3
 	param set MPC_XY_VEL_MAX 3.5
 	param set MPC_Z_VEL_MAX_UP 2
+	param set MPC_YAWRAUTO_MAX 40
 
 	param set PWM_MAIN_DIS3 1000
 	param set PWM_MAIN_MIN3 1120
diff --git a/src/lib/FlightTasks/tasks/Auto/FlightTaskAuto.cpp b/src/lib/FlightTasks/tasks/Auto/FlightTaskAuto.cpp
index 9b7e50fc2e..13277008c6 100644
--- a/src/lib/FlightTasks/tasks/Auto/FlightTaskAuto.cpp
+++ b/src/lib/FlightTasks/tasks/Auto/FlightTaskAuto.cpp
@@ -113,7 +113,7 @@ void FlightTaskAuto::_limitYawRate()
 {
 	if (PX4_ISFINITE(_yaw_setpoint) || PX4_ISFINITE(_yaw_sp_prev)) {
 		// Limit the rate of change of the yaw setpoint
-		float dy_max = math::radians(_param_mc_yawrauto_max.get()) * _deltatime;
+		float dy_max = math::radians(_param_mpc_yawrauto_max.get()) * _deltatime;
 
 		if (fabsf(_yaw_setpoint - _yaw_sp_prev) < M_PI_F) {
 			// Wrap around 0
@@ -134,7 +134,7 @@ void FlightTaskAuto::_limitYawRate()
 	}
 
 	if (PX4_ISFINITE(_yawspeed_setpoint)) {
-		_yawspeed_setpoint = math::constrain(_yawspeed_setpoint, -_param_mc_yawrauto_max.get(), _param_mc_yawrauto_max.get());
+		_yawspeed_setpoint = math::constrain(_yawspeed_setpoint, -_param_mpc_yawrauto_max.get(), _param_mpc_yawrauto_max.get());
 	}
 }
 
diff --git a/src/lib/FlightTasks/tasks/Auto/FlightTaskAuto.hpp b/src/lib/FlightTasks/tasks/Auto/FlightTaskAuto.hpp
index 85a7654144..d68c26571a 100644
--- a/src/lib/FlightTasks/tasks/Auto/FlightTaskAuto.hpp
+++ b/src/lib/FlightTasks/tasks/Auto/FlightTaskAuto.hpp
@@ -113,7 +113,7 @@ protected:
 					_param_nav_mc_alt_rad, //vertical acceptance radius at which waypoints are updated
 					(ParamInt<px4::params::MPC_YAW_MODE>) _param_mpc_yaw_mode, // defines how heading is executed,
 					(ParamInt<px4::params::COM_OBS_AVOID>) _param_com_obs_avoid, // obstacle avoidance active
-					(ParamFloat<px4::params::MC_YAWRAUTO_MAX>) _param_mc_yawrauto_max
+					(ParamFloat<px4::params::MPC_YAWRAUTO_MAX>) _param_mpc_yawrauto_max
 				       );
 
 private:
diff --git a/src/modules/mc_att_control/mc_att_control_params.c b/src/modules/mc_att_control/mc_att_control_params.c
index 7da4662250..fac174dd7f 100644
--- a/src/modules/mc_att_control/mc_att_control_params.c
+++ b/src/modules/mc_att_control/mc_att_control_params.c
@@ -313,21 +313,6 @@ PARAM_DEFINE_FLOAT(MC_PITCHRATE_MAX, 220.0f);
  */
 PARAM_DEFINE_FLOAT(MC_YAWRATE_MAX, 200.0f);
 
-/**
- * Max yaw rate in auto mode
- *
- * Limit for yaw rate, has effect for large rotations in autonomous mode,
- * to avoid large control output and mixer saturation.
- *
- * @unit deg/s
- * @min 0.0
- * @max 360.0
- * @decimal 1
- * @increment 5
- * @group Multicopter Attitude Control
- */
-PARAM_DEFINE_FLOAT(MC_YAWRAUTO_MAX, 45.0f);
-
 /**
  * Max acro roll rate
  * default: 2 turns per second
diff --git a/src/modules/mc_pos_control/mc_pos_control_params.c b/src/modules/mc_pos_control/mc_pos_control_params.c
index 09b65bef50..746f930964 100644
--- a/src/modules/mc_pos_control/mc_pos_control_params.c
+++ b/src/modules/mc_pos_control/mc_pos_control_params.c
@@ -615,6 +615,21 @@ PARAM_DEFINE_FLOAT(MPC_Z_MAN_EXPO, 0.0f);
  */
 PARAM_DEFINE_FLOAT(MPC_YAW_EXPO, 0.0f);
 
+/**
+ * Max yaw rate in auto mode
+ *
+ * Limit the rate of change of the yaw setpoint in autonomous mode
+ * to avoid large control output and mixer saturation.
+ *
+ * @unit deg/s
+ * @min 0.0
+ * @max 360.0
+ * @decimal 1
+ * @increment 5
+ * @group Multicopter Attitude Control
+ */
+PARAM_DEFINE_FLOAT(MPC_YAWRAUTO_MAX, 45.0f);
+
 /**
  * Altitude for 1. step of slow landing (descend)
  *
-- 
GitLab