mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-03-11 17:13:56 -03:00
Copter: Add support for Force Flying
This commit is contained in:
parent
0c42b890e6
commit
23711b7b10
@ -365,7 +365,8 @@ private:
|
|||||||
|
|
||||||
ap_t ap;
|
ap_t ap;
|
||||||
|
|
||||||
AirMode air_mode; // air mode is 0 = not-configured ; 1 = disabled; 2 = enabled
|
AirMode air_mode; // air mode is 0 = not-configured ; 1 = disabled; 2 = enabled;
|
||||||
|
bool force_flying; // force flying is enabled when true;
|
||||||
|
|
||||||
static_assert(sizeof(uint32_t) == sizeof(ap), "ap_t must be uint32_t");
|
static_assert(sizeof(uint32_t) == sizeof(ap), "ap_t must be uint32_t");
|
||||||
|
|
||||||
|
@ -118,6 +118,7 @@ void RC_Channel_Copter::init_aux_function(const aux_func_t ch_option, const AuxS
|
|||||||
case AUX_FUNC::SURFACE_TRACKING:
|
case AUX_FUNC::SURFACE_TRACKING:
|
||||||
case AUX_FUNC::WINCH_ENABLE:
|
case AUX_FUNC::WINCH_ENABLE:
|
||||||
case AUX_FUNC::AIRMODE:
|
case AUX_FUNC::AIRMODE:
|
||||||
|
case AUX_FUNC::FORCEFLYING:
|
||||||
run_aux_function(ch_option, ch_flag, AuxFuncTriggerSource::INIT);
|
run_aux_function(ch_option, ch_flag, AuxFuncTriggerSource::INIT);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -565,6 +566,10 @@ bool RC_Channel_Copter::do_aux_function(const aux_func_t ch_option, const AuxSwi
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case AUX_FUNC::FORCEFLYING:
|
||||||
|
do_aux_function_change_force_flying(ch_flag);
|
||||||
|
break;
|
||||||
|
|
||||||
case AUX_FUNC::AUTO_RTL:
|
case AUX_FUNC::AUTO_RTL:
|
||||||
#if MODE_AUTO_ENABLED == ENABLED
|
#if MODE_AUTO_ENABLED == ENABLED
|
||||||
do_aux_function_change_mode(Mode::Number::AUTO_RTL, ch_flag);
|
do_aux_function_change_mode(Mode::Number::AUTO_RTL, ch_flag);
|
||||||
@ -612,6 +617,21 @@ void RC_Channel_Copter::do_aux_function_change_air_mode(const AuxSwitchPos ch_fl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// change force flying status
|
||||||
|
void RC_Channel_Copter::do_aux_function_change_force_flying(const AuxSwitchPos ch_flag)
|
||||||
|
{
|
||||||
|
switch (ch_flag) {
|
||||||
|
case AuxSwitchPos::HIGH:
|
||||||
|
copter.force_flying = true;
|
||||||
|
break;
|
||||||
|
case AuxSwitchPos::MIDDLE:
|
||||||
|
break;
|
||||||
|
case AuxSwitchPos::LOW:
|
||||||
|
copter.force_flying = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// save_trim - adds roll and pitch trims from the radio to ahrs
|
// save_trim - adds roll and pitch trims from the radio to ahrs
|
||||||
void Copter::save_trim()
|
void Copter::save_trim()
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,7 @@ private:
|
|||||||
void do_aux_function_change_mode(const Mode::Number mode,
|
void do_aux_function_change_mode(const Mode::Number mode,
|
||||||
const AuxSwitchPos ch_flag);
|
const AuxSwitchPos ch_flag);
|
||||||
void do_aux_function_change_air_mode(const AuxSwitchPos ch_flag);
|
void do_aux_function_change_air_mode(const AuxSwitchPos ch_flag);
|
||||||
|
void do_aux_function_change_force_flying(const AuxSwitchPos ch_flag);
|
||||||
|
|
||||||
// called when the mode switch changes position:
|
// called when the mode switch changes position:
|
||||||
void mode_switch_changed(modeswitch_pos_t new_pos) override;
|
void mode_switch_changed(modeswitch_pos_t new_pos) override;
|
||||||
|
@ -35,6 +35,12 @@ void Copter::crash_check()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// exit immediately if in force flying
|
||||||
|
if (force_flying && !flightmode->is_landing()) {
|
||||||
|
crash_counter = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// return immediately if we are not in an angle stabilize flight mode or we are flipping
|
// return immediately if we are not in an angle stabilize flight mode or we are flipping
|
||||||
if (flightmode->mode_number() == Mode::Number::ACRO || flightmode->mode_number() == Mode::Number::FLIP) {
|
if (flightmode->mode_number() == Mode::Number::ACRO || flightmode->mode_number() == Mode::Number::FLIP) {
|
||||||
crash_counter = 0;
|
crash_counter = 0;
|
||||||
|
@ -196,7 +196,7 @@ void Copter::update_throttle_mix()
|
|||||||
// check if landing
|
// check if landing
|
||||||
const bool landing = flightmode->is_landing();
|
const bool landing = flightmode->is_landing();
|
||||||
|
|
||||||
if ((large_angle_request && !landing) || large_angle_error || accel_moving || descent_not_demanded) {
|
if (((large_angle_request || force_flying) && !landing) || large_angle_error || accel_moving || descent_not_demanded) {
|
||||||
attitude_control->set_throttle_mix_max(pos_control->get_vel_z_control_ratio());
|
attitude_control->set_throttle_mix_max(pos_control->get_vel_z_control_ratio());
|
||||||
} else {
|
} else {
|
||||||
attitude_control->set_throttle_mix_min();
|
attitude_control->set_throttle_mix_min();
|
||||||
|
Loading…
Reference in New Issue
Block a user