Compare commits

...

4 Commits

Author SHA1 Message Date
Thomas Stastny a38ec6aed2 update quad vtol tailsitter mixer 2022-05-19 15:32:12 -07:00
Thomas Stastny fd78164ea2 enable optional differential thrust for pitch and roll in fw mode 2022-05-19 15:31:13 -07:00
Silvan Fuhrer cbac0e8b8c tailsitter: use differential thrust to control pitch and roll in FW
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-05-18 19:10:40 +02:00
Silvan Fuhrer 8e6976a404 tailsitter: reduce tilt to switch to FW in front transition
This is to allow transitions in stabilized mode, where the tilt is set directly with
    stick inputs. For Position control / Auto mode it was fine because there the pitch
    is set by the transition logic.

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-05-18 19:09:49 +02:00
5 changed files with 85 additions and 9 deletions
@@ -3,6 +3,7 @@ Mixer for the gazebo tailsitter model
R: 4x
Z:
Z:
# left elevon
@@ -8,12 +8,15 @@ are mixed 100%.
R: 4x
Z:
Z:
# left elevon
M: 2
S: 1 0 -5000 -5000 0 -10000 10000
S: 1 0 5000 5000 0 -10000 10000
S: 1 1 5000 5000 0 -10000 10000
# right elevon
M: 2
S: 1 0 -5000 -5000 0 -10000 10000
S: 1 0 5000 5000 0 -10000 10000
S: 1 1 -5000 -5000 0 -10000 10000
+34 -6
View File
@@ -44,7 +44,7 @@
#include <uORB/topics/landing_gear.h>
#define PITCH_TRANSITION_FRONT_P1 -1.1f // pitch angle to switch to TRANSITION_P2
#define PITCH_TRANSITION_FRONT_P1 -0.5f // pitch angle to switch to TRANSITION_P2 (28°)
#define PITCH_TRANSITION_BACK -0.25f // pitch angle to switch to MC
using namespace matrix;
@@ -146,6 +146,7 @@ void Tailsitter::update_vtol_state()
if (transition_to_fw) {
_vtol_schedule.flight_mode = vtol_mode::FW_MODE;
printf("transition to FW completed\n");
}
// check front transition timeout
@@ -335,12 +336,24 @@ void Tailsitter::fill_actuator_outputs()
// FW thrust is allocated on mc_thrust_sp[0] for tailsitter with dynamic control allocation
_thrust_setpoint_0->xyz[2] = -fw_in[actuator_controls_s::INDEX_THROTTLE];
/* allow differential thrust if enabled */
/* allow differential thrust for yaw if enabled */
if (_param_vt_fw_difthr_en.get()) {
mc_out[actuator_controls_s::INDEX_ROLL] = fw_in[actuator_controls_s::INDEX_YAW] * _param_vt_fw_difthr_sc.get() ;
_torque_setpoint_0->xyz[0] = fw_in[actuator_controls_s::INDEX_YAW] * _param_vt_fw_difthr_sc.get() ;
}
if (_param_vt_fw_difthr_r.get()) {
// enable differential thrust for fixed-wing roll control
mc_out[actuator_controls_s::INDEX_YAW] = -fw_in[actuator_controls_s::INDEX_ROLL];
_torque_setpoint_0->xyz[2] = fw_in[actuator_controls_s::INDEX_ROLL];
}
if (_param_vt_fw_difthr_p.get()) {
// enable differential thrust for fixed-wing pitch control
mc_out[actuator_controls_s::INDEX_PITCH] = fw_in[actuator_controls_s::INDEX_PITCH];
_torque_setpoint_0->xyz[1] = fw_in[actuator_controls_s::INDEX_PITCH];
}
} else {
_torque_setpoint_0->xyz[0] = mc_in[actuator_controls_s::INDEX_ROLL];
_torque_setpoint_0->xyz[1] = mc_in[actuator_controls_s::INDEX_PITCH];
@@ -363,10 +376,25 @@ void Tailsitter::fill_actuator_outputs()
fw_out[actuator_controls_s::INDEX_PITCH] = 0;
} else {
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];
_torque_setpoint_1->xyz[1] = fw_in[actuator_controls_s::INDEX_PITCH];
_torque_setpoint_1->xyz[2] = -fw_in[actuator_controls_s::INDEX_ROLL];
if (_param_vt_elev_lock.get()) {
// lock the elevator always
fw_out[actuator_controls_s::INDEX_PITCH] = 0.0f;
_torque_setpoint_1->xyz[1] = 0.0f;
} else {
fw_out[actuator_controls_s::INDEX_PITCH] = fw_in[actuator_controls_s::INDEX_PITCH];
_torque_setpoint_1->xyz[1] = fw_in[actuator_controls_s::INDEX_PITCH];
}
if (_param_vt_ail_fw_lock.get() && _vtol_schedule.flight_mode != vtol_mode::MC_MODE) {
// lock the ailerons in transition and fixed-wing
fw_out[actuator_controls_s::INDEX_ROLL] = 0.0f;
_torque_setpoint_1->xyz[2] = 0.0f;
} else {
fw_out[actuator_controls_s::INDEX_ROLL] = fw_in[actuator_controls_s::INDEX_ROLL];
_torque_setpoint_1->xyz[2] = -fw_in[actuator_controls_s::INDEX_ROLL];
}
}
_actuators_out_0->timestamp_sample = _actuators_mc_in->timestamp_sample;
+5 -1
View File
@@ -81,7 +81,11 @@ private:
void parameters_update() override;
DEFINE_PARAMETERS_CUSTOM_PARENT(VtolType,
(ParamFloat<px4::params::FW_PSP_OFF>) _param_fw_psp_off
(ParamFloat<px4::params::FW_PSP_OFF>) _param_fw_psp_off,
(ParamInt<px4::params::VT_FW_DIFTHR_P>) _param_vt_fw_difthr_p,
(ParamInt<px4::params::VT_FW_DIFTHR_R>) _param_vt_fw_difthr_r,
(ParamInt<px4::params::VT_ELEV_LOCK>) _param_vt_elev_lock,
(ParamInt<px4::params::VT_AIL_FW_LOCK>) _param_vt_ail_fw_lock
)
@@ -75,6 +75,22 @@ PARAM_DEFINE_INT32(VT_TYPE, 0);
*/
PARAM_DEFINE_INT32(VT_ELEV_MC_LOCK, 1);
/**
* Lock elevator action always
*
* @boolean
* @group VTOL Attitude Control
*/
PARAM_DEFINE_INT32(VT_ELEV_LOCK, 1);
/**
* Lock ailerons in transition and fixed-wing modes
*
* @boolean
* @group VTOL Attitude Control
*/
PARAM_DEFINE_INT32(VT_AIL_FW_LOCK, 0);
/**
* Duration of a front transition
*
@@ -297,6 +313,30 @@ PARAM_DEFINE_INT32(VT_MOT_ID, 0);
*/
PARAM_DEFINE_INT32(VT_FW_DIFTHR_EN, 0);
/**
* Differential thrust in forwards flight for pitch.
*
* Set to 1 to enable differential thrust in fixed-wing flight.
*
* @min 0
* @max 1
* @decimal 0
* @group VTOL Attitude Control
*/
PARAM_DEFINE_INT32(VT_FW_DIFTHR_P, 1);
/**
* Differential thrust in forwards flight for roll.
*
* Set to 1 to enable differential thrust in fixed-wing flight.
*
* @min 0
* @max 1
* @decimal 0
* @group VTOL Attitude Control
*/
PARAM_DEFINE_INT32(VT_FW_DIFTHR_R, 1);
/**
* Differential thrust scaling factor
*