mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 06:33:33 +08:00
control_allocator: handle thrust allocation for VTOL's properly
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
committed by
Daniel Agar
parent
936f2dff52
commit
0568cff299
@@ -462,21 +462,57 @@ void Tiltrotor::fill_actuator_outputs()
|
||||
auto &mc_out = _actuators_out_0->control;
|
||||
auto &fw_out = _actuators_out_1->control;
|
||||
|
||||
_torque_setpoint_0->timestamp = hrt_absolute_time();
|
||||
_torque_setpoint_0->timestamp_sample = _actuators_mc_in->timestamp_sample;
|
||||
_torque_setpoint_0->xyz[0] = 0.f;
|
||||
_torque_setpoint_0->xyz[1] = 0.f;
|
||||
_torque_setpoint_0->xyz[2] = 0.f;
|
||||
|
||||
_torque_setpoint_1->timestamp = hrt_absolute_time();
|
||||
_torque_setpoint_1->timestamp_sample = _actuators_fw_in->timestamp_sample;
|
||||
_torque_setpoint_1->xyz[0] = 0.f;
|
||||
_torque_setpoint_1->xyz[1] = 0.f;
|
||||
_torque_setpoint_1->xyz[2] = 0.f;
|
||||
|
||||
_thrust_setpoint_0->timestamp = hrt_absolute_time();
|
||||
_thrust_setpoint_0->timestamp_sample = _actuators_mc_in->timestamp_sample;
|
||||
_thrust_setpoint_0->xyz[0] = 0.f;
|
||||
_thrust_setpoint_0->xyz[1] = 0.f;
|
||||
_thrust_setpoint_0->xyz[2] = 0.f;
|
||||
|
||||
_thrust_setpoint_1->timestamp = hrt_absolute_time();
|
||||
_thrust_setpoint_1->timestamp_sample = _actuators_fw_in->timestamp_sample;
|
||||
_thrust_setpoint_1->xyz[0] = 0.f;
|
||||
_thrust_setpoint_1->xyz[1] = 0.f;
|
||||
_thrust_setpoint_1->xyz[2] = 0.f;
|
||||
|
||||
// Multirotor output
|
||||
mc_out[actuator_controls_s::INDEX_ROLL] = mc_in[actuator_controls_s::INDEX_ROLL] * _mc_roll_weight;
|
||||
mc_out[actuator_controls_s::INDEX_PITCH] = mc_in[actuator_controls_s::INDEX_PITCH] * _mc_pitch_weight;
|
||||
mc_out[actuator_controls_s::INDEX_YAW] = mc_in[actuator_controls_s::INDEX_YAW] * _mc_yaw_weight;
|
||||
|
||||
_torque_setpoint_0->xyz[0] = mc_in[actuator_controls_s::INDEX_ROLL] * _mc_roll_weight;
|
||||
_torque_setpoint_0->xyz[1] = mc_in[actuator_controls_s::INDEX_PITCH] * _mc_pitch_weight;
|
||||
_torque_setpoint_0->xyz[2] = mc_in[actuator_controls_s::INDEX_YAW] * _mc_yaw_weight;
|
||||
|
||||
if (_vtol_schedule.flight_mode == vtol_mode::FW_MODE) {
|
||||
|
||||
// for the legacy mixing system pubish FW throttle on the MC output
|
||||
mc_out[actuator_controls_s::INDEX_THROTTLE] = fw_in[actuator_controls_s::INDEX_THROTTLE];
|
||||
|
||||
// FW thrust is allocated on mc_thrust_sp[0] for tiltrotor with dynamic control allocation
|
||||
_thrust_setpoint_0->xyz[0] = fw_in[actuator_controls_s::INDEX_THROTTLE];
|
||||
|
||||
/* allow differential thrust if enabled */
|
||||
if (_params->diff_thrust == 1) {
|
||||
mc_out[actuator_controls_s::INDEX_ROLL] = fw_in[actuator_controls_s::INDEX_YAW] * _params->diff_thrust_scale;
|
||||
_torque_setpoint_0->xyz[2] = fw_in[actuator_controls_s::INDEX_YAW] * _params->diff_thrust_scale;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
mc_out[actuator_controls_s::INDEX_THROTTLE] = mc_in[actuator_controls_s::INDEX_THROTTLE] * _mc_throttle_weight;
|
||||
_thrust_setpoint_0->xyz[2] = -mc_in[actuator_controls_s::INDEX_THROTTLE] * _mc_throttle_weight;
|
||||
}
|
||||
|
||||
// Fixed wing output
|
||||
@@ -491,6 +527,9 @@ void Tiltrotor::fill_actuator_outputs()
|
||||
fw_out[actuator_controls_s::INDEX_ROLL] = fw_in[actuator_controls_s::INDEX_ROLL];
|
||||
fw_out[actuator_controls_s::INDEX_PITCH] = fw_in[actuator_controls_s::INDEX_PITCH];
|
||||
fw_out[actuator_controls_s::INDEX_YAW] = fw_in[actuator_controls_s::INDEX_YAW];
|
||||
_torque_setpoint_1->xyz[0] = fw_in[actuator_controls_s::INDEX_ROLL];
|
||||
_torque_setpoint_1->xyz[1] = fw_in[actuator_controls_s::INDEX_PITCH];
|
||||
_torque_setpoint_1->xyz[2] = fw_in[actuator_controls_s::INDEX_YAW];
|
||||
}
|
||||
|
||||
_actuators_out_0->timestamp_sample = _actuators_mc_in->timestamp_sample;
|
||||
|
||||
Reference in New Issue
Block a user