mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-07 19:01:36 +08:00
Omni Pos-Ctrl: Roll/Pitch airmode implemented for Omni vehicles
- For MC_AIRMODE = 1
This commit is contained in:
@@ -303,6 +303,30 @@ MultirotorMixer::mix_airmode_rp(float roll, float pitch, float yaw, float thrust
|
||||
mix_yaw(yaw, outputs);
|
||||
}
|
||||
|
||||
void
|
||||
MultirotorMixer::mix_airmode_rp(float roll, float pitch, float yaw, float x_thrust, float y_thrust, float z_thrust,
|
||||
float *outputs)
|
||||
{
|
||||
// Airmode for roll and pitch, but not yaw in 6-DoF vehicles
|
||||
|
||||
// Mix without yaw
|
||||
for (unsigned i = 0; i < _rotor_count; i++) {
|
||||
outputs[i] = roll * _rotors_6dof[i].roll_scale +
|
||||
pitch * _rotors_6dof[i].pitch_scale +
|
||||
x_thrust * _rotors_6dof[i].x_scale +
|
||||
y_thrust * _rotors_6dof[i].y_scale +
|
||||
z_thrust * _rotors_6dof[i].z_scale;
|
||||
|
||||
// Z thrust will be used to unsaturate if needed
|
||||
_tmp_array[i] = math::abs_t<float>(_rotors_6dof[i].z_scale);
|
||||
}
|
||||
|
||||
minimize_saturation(_tmp_array, outputs, _saturation_status);
|
||||
|
||||
// Mix yaw independently
|
||||
mix_yaw(yaw, outputs);
|
||||
}
|
||||
|
||||
void
|
||||
MultirotorMixer::mix_airmode_rpy(float roll, float pitch, float yaw, float thrust, float *outputs)
|
||||
{
|
||||
@@ -458,11 +482,21 @@ MultirotorMixer::mix(float *outputs, unsigned space)
|
||||
}
|
||||
|
||||
} else { // if is 6-DoF vehicle
|
||||
// Do the mixing using the strategy given by the current Airmode configuration
|
||||
float x_thrust = math::constrain(get_control(0, 8), -1.0f, 1.0f);
|
||||
float y_thrust = math::constrain(get_control(0, 9), -1.0f, 1.0f);
|
||||
float z_thrust = math::constrain(get_control(0, 10), -1.0f, 1.0f);
|
||||
|
||||
mix_airmode_disabled(roll, pitch, yaw, x_thrust, y_thrust, z_thrust, outputs);
|
||||
switch (_airmode) {
|
||||
case Airmode::roll_pitch:
|
||||
mix_airmode_rp(roll, pitch, yaw, x_thrust, y_thrust, z_thrust, outputs);
|
||||
break;
|
||||
|
||||
case Airmode::disabled:
|
||||
default: // just in case: default to disabled
|
||||
mix_airmode_disabled(roll, pitch, yaw, x_thrust, y_thrust, z_thrust, outputs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply thrust model and scale outputs to range [idle_speed, 1].
|
||||
|
||||
@@ -257,6 +257,16 @@ private:
|
||||
*/
|
||||
inline void mix_airmode_rp(float roll, float pitch, float yaw, float thrust, float *outputs);
|
||||
|
||||
/**
|
||||
* Mix roll, pitch, yaw, x_thrust, y_thrust, z_thrust and set the outputs vector for 6-DoF vehicles.
|
||||
*
|
||||
* Desaturation behavior: airmode for roll/pitch:
|
||||
* thrust is increased/decreased as much as required to meet the demanded roll/pitch.
|
||||
* Yaw is not allowed to increase the thrust, @see mix_yaw() for the exact behavior.
|
||||
*/
|
||||
inline void mix_airmode_rp(float roll, float pitch, float yaw, float x_thrust, float y_thrust, float z_thrust,
|
||||
float *outputs);
|
||||
|
||||
/**
|
||||
* Mix roll, pitch, yaw, thrust and set the outputs vector.
|
||||
*
|
||||
@@ -282,7 +292,6 @@ private:
|
||||
* Desaturation behavior: no airmode, thrust is NEVER increased to meet the demanded
|
||||
* roll/pitch/yaw. Instead roll/pitch/yaw is reduced as much as needed.
|
||||
* Thrust can be reduced to unsaturate the upper side.
|
||||
* This is the only airmode available for 6-DoF vehicles.
|
||||
* @see mix_yaw() for the exact yaw behavior.
|
||||
*/
|
||||
inline void mix_airmode_disabled(float roll, float pitch, float yaw, float x_thrust, float y_thrust, float z_thrust,
|
||||
|
||||
Reference in New Issue
Block a user