mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 07:43:34 +08:00
vtol_att_control vtol_type enum -> enum class
This commit is contained in:
@@ -47,7 +47,7 @@
|
||||
Tiltrotor::Tiltrotor(VtolAttitudeControl *attc) :
|
||||
VtolType(attc)
|
||||
{
|
||||
_vtol_schedule.flight_mode = MC_MODE;
|
||||
_vtol_schedule.flight_mode = vtol_mode::MC_MODE;
|
||||
_vtol_schedule.transition_start = 0;
|
||||
|
||||
_mc_roll_weight = 1.0f;
|
||||
@@ -96,29 +96,29 @@ void Tiltrotor::update_vtol_state()
|
||||
|
||||
// plane is in multicopter mode
|
||||
switch (_vtol_schedule.flight_mode) {
|
||||
case MC_MODE:
|
||||
case vtol_mode::MC_MODE:
|
||||
break;
|
||||
|
||||
case FW_MODE:
|
||||
_vtol_schedule.flight_mode = TRANSITION_BACK;
|
||||
case vtol_mode::FW_MODE:
|
||||
_vtol_schedule.flight_mode = vtol_mode::TRANSITION_BACK;
|
||||
_vtol_schedule.transition_start = hrt_absolute_time();
|
||||
break;
|
||||
|
||||
case TRANSITION_FRONT_P1:
|
||||
case vtol_mode::TRANSITION_FRONT_P1:
|
||||
// failsafe into multicopter mode
|
||||
_vtol_schedule.flight_mode = MC_MODE;
|
||||
_vtol_schedule.flight_mode = vtol_mode::MC_MODE;
|
||||
break;
|
||||
|
||||
case TRANSITION_FRONT_P2:
|
||||
case vtol_mode::TRANSITION_FRONT_P2:
|
||||
// failsafe into multicopter mode
|
||||
_vtol_schedule.flight_mode = MC_MODE;
|
||||
_vtol_schedule.flight_mode = vtol_mode::MC_MODE;
|
||||
break;
|
||||
|
||||
case TRANSITION_BACK:
|
||||
case vtol_mode::TRANSITION_BACK:
|
||||
float time_since_trans_start = (float)(hrt_absolute_time() - _vtol_schedule.transition_start) * 1e-6f;
|
||||
|
||||
if (_tilt_control <= _params_tiltrotor.tilt_mc && time_since_trans_start > _params->back_trans_duration) {
|
||||
_vtol_schedule.flight_mode = MC_MODE;
|
||||
_vtol_schedule.flight_mode = vtol_mode::MC_MODE;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -127,16 +127,16 @@ void Tiltrotor::update_vtol_state()
|
||||
} else {
|
||||
|
||||
switch (_vtol_schedule.flight_mode) {
|
||||
case MC_MODE:
|
||||
case vtol_mode::MC_MODE:
|
||||
// initialise a front transition
|
||||
_vtol_schedule.flight_mode = TRANSITION_FRONT_P1;
|
||||
_vtol_schedule.flight_mode = vtol_mode::TRANSITION_FRONT_P1;
|
||||
_vtol_schedule.transition_start = hrt_absolute_time();
|
||||
break;
|
||||
|
||||
case FW_MODE:
|
||||
case vtol_mode::FW_MODE:
|
||||
break;
|
||||
|
||||
case TRANSITION_FRONT_P1: {
|
||||
case vtol_mode::TRANSITION_FRONT_P1: {
|
||||
// allow switch if we are not armed for the sake of bench testing
|
||||
bool transition_to_p2 = can_transition_on_ground();
|
||||
|
||||
@@ -153,46 +153,46 @@ void Tiltrotor::update_vtol_state()
|
||||
time_since_trans_start > _params->front_trans_time_openloop;
|
||||
|
||||
if (transition_to_p2) {
|
||||
_vtol_schedule.flight_mode = TRANSITION_FRONT_P2;
|
||||
_vtol_schedule.flight_mode = vtol_mode::TRANSITION_FRONT_P2;
|
||||
_vtol_schedule.transition_start = hrt_absolute_time();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case TRANSITION_FRONT_P2:
|
||||
case vtol_mode::TRANSITION_FRONT_P2:
|
||||
|
||||
// if the rotors have been tilted completely we switch to fw mode
|
||||
if (_tilt_control >= _params_tiltrotor.tilt_fw) {
|
||||
_vtol_schedule.flight_mode = FW_MODE;
|
||||
_vtol_schedule.flight_mode = vtol_mode::FW_MODE;
|
||||
_tilt_control = _params_tiltrotor.tilt_fw;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TRANSITION_BACK:
|
||||
case vtol_mode::TRANSITION_BACK:
|
||||
// failsafe into fixed wing mode
|
||||
_vtol_schedule.flight_mode = FW_MODE;
|
||||
_vtol_schedule.flight_mode = vtol_mode::FW_MODE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// map tiltrotor specific control phases to simple control modes
|
||||
switch (_vtol_schedule.flight_mode) {
|
||||
case MC_MODE:
|
||||
case vtol_mode::MC_MODE:
|
||||
_vtol_mode = mode::ROTARY_WING;
|
||||
break;
|
||||
|
||||
case FW_MODE:
|
||||
case vtol_mode::FW_MODE:
|
||||
_vtol_mode = mode::FIXED_WING;
|
||||
break;
|
||||
|
||||
case TRANSITION_FRONT_P1:
|
||||
case TRANSITION_FRONT_P2:
|
||||
case vtol_mode::TRANSITION_FRONT_P1:
|
||||
case vtol_mode::TRANSITION_FRONT_P2:
|
||||
_vtol_mode = mode::TRANSITION_TO_FW;
|
||||
break;
|
||||
|
||||
case TRANSITION_BACK:
|
||||
case vtol_mode::TRANSITION_BACK:
|
||||
_vtol_mode = mode::TRANSITION_TO_MC;
|
||||
break;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ void Tiltrotor::update_transition_state()
|
||||
_flag_was_in_trans_mode = true;
|
||||
}
|
||||
|
||||
if (_vtol_schedule.flight_mode == TRANSITION_FRONT_P1) {
|
||||
if (_vtol_schedule.flight_mode == vtol_mode::TRANSITION_FRONT_P1) {
|
||||
// for the first part of the transition the rear rotors are enabled
|
||||
if (_motor_state != motor_state::ENABLED) {
|
||||
_motor_state = set_motor_state(_motor_state, motor_state::ENABLED);
|
||||
@@ -263,7 +263,7 @@ void Tiltrotor::update_transition_state()
|
||||
|
||||
_thrust_transition = -_mc_virtual_att_sp->thrust_body[2];
|
||||
|
||||
} else if (_vtol_schedule.flight_mode == TRANSITION_FRONT_P2) {
|
||||
} else if (_vtol_schedule.flight_mode == vtol_mode::TRANSITION_FRONT_P2) {
|
||||
// the plane is ready to go into fixed wing mode, tilt the rotors forward completely
|
||||
_tilt_control = _params_tiltrotor.tilt_transition +
|
||||
fabsf(_params_tiltrotor.tilt_fw - _params_tiltrotor.tilt_transition) * time_since_trans_start /
|
||||
@@ -282,7 +282,7 @@ void Tiltrotor::update_transition_state()
|
||||
|
||||
_thrust_transition = -_mc_virtual_att_sp->thrust_body[2];
|
||||
|
||||
} else if (_vtol_schedule.flight_mode == TRANSITION_BACK) {
|
||||
} else if (_vtol_schedule.flight_mode == vtol_mode::TRANSITION_BACK) {
|
||||
if (_motor_state != motor_state::ENABLED) {
|
||||
_motor_state = set_motor_state(_motor_state, motor_state::ENABLED);
|
||||
}
|
||||
@@ -345,7 +345,7 @@ void Tiltrotor::fill_actuator_outputs()
|
||||
_actuators_out_0->control[actuator_controls_s::INDEX_YAW] =
|
||||
_actuators_mc_in->control[actuator_controls_s::INDEX_YAW] * _mc_yaw_weight;
|
||||
|
||||
if (_vtol_schedule.flight_mode == FW_MODE) {
|
||||
if (_vtol_schedule.flight_mode == vtol_mode::FW_MODE) {
|
||||
_actuators_out_0->control[actuator_controls_s::INDEX_THROTTLE] =
|
||||
_actuators_fw_in->control[actuator_controls_s::INDEX_THROTTLE];
|
||||
|
||||
@@ -366,7 +366,7 @@ void Tiltrotor::fill_actuator_outputs()
|
||||
|
||||
_actuators_out_1->control[4] = _tilt_control;
|
||||
|
||||
if (_params->elevons_mc_lock && _vtol_schedule.flight_mode == MC_MODE) {
|
||||
if (_params->elevons_mc_lock && _vtol_schedule.flight_mode == vtol_mode::MC_MODE) {
|
||||
_actuators_out_1->control[actuator_controls_s::INDEX_ROLL] = 0.0f;
|
||||
_actuators_out_1->control[actuator_controls_s::INDEX_PITCH] = 0.0f;
|
||||
_actuators_out_1->control[actuator_controls_s::INDEX_YAW] = 0.0f;
|
||||
|
||||
Reference in New Issue
Block a user