From 3c2087a69d3dc91e434222fb26d6f1f95cf05186 Mon Sep 17 00:00:00 2001 From: Azarakhsh Keipour Date: Sat, 28 Dec 2019 19:35:16 -0500 Subject: [PATCH] Omni MC: Changed the parameter name MC_OMNI_MODE to OMNI_ATT_MODE - To be more descriptive and similar to other (future) OMNI_ parameters --- ROMFS/px4fmu_common/init.d-posix/6101_hexa_x_tilt | 2 +- .../init.d/airframes/6100_hexa_tilt_x | 2 +- ROMFS/px4fmu_common/init.d/rc.mc_defaults | 2 +- src/modules/mc_att_control/mc_att_control.hpp | 2 +- src/modules/mc_att_control/mc_att_control_main.cpp | 2 +- .../mc_pos_control/PositionControl/ControlMath.cpp | 5 +++-- src/modules/mc_pos_control/mc_pos_control_main.cpp | 4 ++-- src/modules/mc_pos_control/mc_pos_control_params.c | 14 +++++++++++--- 8 files changed, 21 insertions(+), 12 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d-posix/6101_hexa_x_tilt b/ROMFS/px4fmu_common/init.d-posix/6101_hexa_x_tilt index ccf9bbad8c..4ff8fa0457 100644 --- a/ROMFS/px4fmu_common/init.d-posix/6101_hexa_x_tilt +++ b/ROMFS/px4fmu_common/init.d-posix/6101_hexa_x_tilt @@ -38,7 +38,7 @@ then param set SDLOG_PROFILE 179 - param set MC_OMNI_MODE 2 + param set OMNI_ATT_MODE 2 fi set MAV_TYPE 13 diff --git a/ROMFS/px4fmu_common/init.d/airframes/6100_hexa_tilt_x b/ROMFS/px4fmu_common/init.d/airframes/6100_hexa_tilt_x index 2248abeeb9..018ac2ecd0 100644 --- a/ROMFS/px4fmu_common/init.d/airframes/6100_hexa_tilt_x +++ b/ROMFS/px4fmu_common/init.d/airframes/6100_hexa_tilt_x @@ -46,7 +46,7 @@ then param set BAT_N_CELLS 4 - param set MC_OMNI_MODE 2 + param set OMNI_ATT_MODE 2 fi # Set mixer diff --git a/ROMFS/px4fmu_common/init.d/rc.mc_defaults b/ROMFS/px4fmu_common/init.d/rc.mc_defaults index b311f07749..8ae2fc994b 100644 --- a/ROMFS/px4fmu_common/init.d/rc.mc_defaults +++ b/ROMFS/px4fmu_common/init.d/rc.mc_defaults @@ -19,7 +19,7 @@ then param set PWM_MIN 1075 param set PWM_RATE 400 - param set MC_OMNI_MODE 0 + param set OMNI_ATT_MODE 0 fi # diff --git a/src/modules/mc_att_control/mc_att_control.hpp b/src/modules/mc_att_control/mc_att_control.hpp index bcfec33d84..eb56a4a299 100644 --- a/src/modules/mc_att_control/mc_att_control.hpp +++ b/src/modules/mc_att_control/mc_att_control.hpp @@ -159,7 +159,7 @@ private: (ParamInt) _param_mc_airmode, - (ParamInt) _param_mc_omni_mode + (ParamInt) _param_omni_att_mode ) bool _is_tailsitter{false}; diff --git a/src/modules/mc_att_control/mc_att_control_main.cpp b/src/modules/mc_att_control/mc_att_control_main.cpp index f7b9e2b97c..92dedbf0a6 100644 --- a/src/modules/mc_att_control/mc_att_control_main.cpp +++ b/src/modules/mc_att_control/mc_att_control_main.cpp @@ -219,7 +219,7 @@ MulticopterAttitudeControl::generate_attitude_setpoint(float dt, bool reset_yaw_ attitude_setpoint.thrust_body[2] = -throttle_curve(_manual_control_sp.z); /* modify roll/pitch if we're in omni-directional mode */ - if (_param_mc_omni_mode.get() == 2) { + if (_param_omni_att_mode.get() == 2) { // set the euler angles, for logging only, must not be used for control attitude_setpoint.roll_body = 0; attitude_setpoint.pitch_body = 0; diff --git a/src/modules/mc_pos_control/PositionControl/ControlMath.cpp b/src/modules/mc_pos_control/PositionControl/ControlMath.cpp index e2b52c6880..592edbaa57 100644 --- a/src/modules/mc_pos_control/PositionControl/ControlMath.cpp +++ b/src/modules/mc_pos_control/PositionControl/ControlMath.cpp @@ -47,8 +47,9 @@ namespace ControlMath void thrustToAttitude(const Vector3f &thr_sp, const float yaw_sp, const int omni_att_mode, vehicle_attitude_setpoint_s &att_sp) { + // Print an error if the omni_att_mode parameter is out of range if (omni_att_mode > 2 || omni_att_mode < 0) { - PX4_ERR("omni_att_mode set to unknown value!"); + PX4_ERR("OMNI_ATT_MODE parameter set to unknown value!"); } switch (omni_att_mode) { @@ -56,7 +57,7 @@ void thrustToAttitude(const Vector3f &thr_sp, const float yaw_sp, const int omni thrustToZeroTiltAttitude(thr_sp, yaw_sp, att_sp); break; - default: + default: // Attitude is calculated from the desired thrust direction bodyzToAttitude(-thr_sp, yaw_sp, att_sp); att_sp.thrust_body[2] = -thr_sp.length(); } diff --git a/src/modules/mc_pos_control/mc_pos_control_main.cpp b/src/modules/mc_pos_control/mc_pos_control_main.cpp index dc798dd320..d31638aea8 100644 --- a/src/modules/mc_pos_control/mc_pos_control_main.cpp +++ b/src/modules/mc_pos_control/mc_pos_control_main.cpp @@ -173,7 +173,7 @@ private: (ParamFloat) _param_mpc_tiltmax_lnd, /**< maximum tilt for landing and smooth takeoff */ (ParamFloat) _param_mpc_thr_min, (ParamFloat) _param_mpc_thr_max, - (ParamInt) _param_mc_omni_mode + (ParamInt) _param_omni_att_mode ); control::BlockDerivative _vel_x_deriv; /**< velocity derivative in x */ @@ -656,7 +656,7 @@ MulticopterPositionControl::Run() vehicle_attitude_setpoint_s attitude_setpoint{}; attitude_setpoint.timestamp = time_stamp_now; - _control.getAttitudeSetpoint(_param_mc_omni_mode.get(), attitude_setpoint); + _control.getAttitudeSetpoint(_param_omni_att_mode.get(), attitude_setpoint); // Part of landing logic: if ground-contact/maybe landed was detected, turn off // controller. This message does not have to be logged as part of the vehicle_local_position_setpoint topic. 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 5a1b2e9cd1..7f85d600ec 100644 --- a/src/modules/mc_pos_control/mc_pos_control_params.c +++ b/src/modules/mc_pos_control/mc_pos_control_params.c @@ -747,9 +747,17 @@ PARAM_DEFINE_FLOAT(MPC_SPOOLUP_TIME, 1.0f); PARAM_DEFINE_INT32(MPC_YAW_MODE, 0); /** - * Omni-directional Controller mode. + * Omni-directional attitude setpoint mode * - * Specifies the heading in Auto. + * Specifies the type of attitude setpoint sent to the attitude controller. + * The parameter can be set to a normal attitude setpoint, where the tilt + * of the vehicle (roll and pitch) are calculated from the desired thrust + * vector. This should be the behavior for the non-omnidirectional vehicles, + * such as quadrotors and other multirotors with coplanar rotors. + * The "constant zero tilt" mode enforces zero roll and pitch and can only be + * used for omnidirectional vehicles. The daisy-chain mode enforces zero tilt + * up to a maximum set acceleration (thrust) and tilts the vehicle as small + * as possible if the thrust vector is larger than the maximum. * * @min 0 * @max 2 @@ -758,4 +766,4 @@ PARAM_DEFINE_INT32(MPC_YAW_MODE, 0); * @value 2 constant zero tilt * @group Multicopter Attitude Control */ -PARAM_DEFINE_INT32(MC_OMNI_MODE, 0); +PARAM_DEFINE_INT32(OMNI_ATT_MODE, 0);