mirror of https://github.com/ArduPilot/ardupilot
Copter: add turtle mode safety features.
This commit is contained in:
parent
356b2a9656
commit
1f4f8df30f
|
@ -1641,6 +1641,9 @@ protected:
|
||||||
const char *name4() const override { return "TRTL"; }
|
const char *name4() const override { return "TRTL"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void arm_motors();
|
||||||
|
void disarm_motors();
|
||||||
|
|
||||||
float motors_output;
|
float motors_output;
|
||||||
Vector2f motors_input;
|
Vector2f motors_input;
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,12 +18,29 @@ bool ModeTurtle::init(bool ignore_checks)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not enter the mode if sticks are not centered
|
// do not enter the mode if sticks are not centered or throttle is not at zero
|
||||||
if (!is_zero(channel_pitch->norm_input_dz())
|
if (!is_zero(channel_pitch->norm_input_dz())
|
||||||
|| !is_zero(channel_roll->norm_input_dz())
|
|| !is_zero(channel_roll->norm_input_dz())
|
||||||
|| !is_zero(channel_yaw->norm_input_dz())) {
|
|| !is_zero(channel_yaw->norm_input_dz())
|
||||||
|
|| !is_zero(channel_throttle->norm_input_dz())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// turn on notify leds
|
||||||
|
AP_Notify::flags.esc_calibration = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModeTurtle::arm_motors()
|
||||||
|
{
|
||||||
|
if (hal.util->get_soft_armed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stop the spoolup block activating
|
||||||
|
motors->set_spoolup_block(false);
|
||||||
|
|
||||||
// reverse the motors
|
// reverse the motors
|
||||||
hal.rcout->disable_channel_mask_updates();
|
hal.rcout->disable_channel_mask_updates();
|
||||||
change_motor_direction(true);
|
change_motor_direction(true);
|
||||||
|
@ -36,8 +53,6 @@ bool ModeTurtle::init(bool ignore_checks)
|
||||||
// arm
|
// arm
|
||||||
motors->armed(true);
|
motors->armed(true);
|
||||||
hal.util->set_soft_armed(true);
|
hal.util->set_soft_armed(true);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModeTurtle::allows_arming(AP_Arming::Method method) const
|
bool ModeTurtle::allows_arming(AP_Arming::Method method) const
|
||||||
|
@ -47,6 +62,18 @@ bool ModeTurtle::allows_arming(AP_Arming::Method method) const
|
||||||
|
|
||||||
void ModeTurtle::exit()
|
void ModeTurtle::exit()
|
||||||
{
|
{
|
||||||
|
disarm_motors();
|
||||||
|
|
||||||
|
// turn off notify leds
|
||||||
|
AP_Notify::flags.esc_calibration = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModeTurtle::disarm_motors()
|
||||||
|
{
|
||||||
|
if (!hal.util->get_soft_armed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// disarm
|
// disarm
|
||||||
motors->armed(false);
|
motors->armed(false);
|
||||||
hal.util->set_soft_armed(false);
|
hal.util->set_soft_armed(false);
|
||||||
|
@ -142,6 +169,14 @@ void ModeTurtle::run()
|
||||||
// actually write values to the motors
|
// actually write values to the motors
|
||||||
void ModeTurtle::output_to_motors()
|
void ModeTurtle::output_to_motors()
|
||||||
{
|
{
|
||||||
|
// throttle needs to be raised
|
||||||
|
if (is_zero(channel_throttle->norm_input_dz())) {
|
||||||
|
disarm_motors();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
arm_motors();
|
||||||
|
|
||||||
// check if motor are allowed to spin
|
// check if motor are allowed to spin
|
||||||
const bool allow_output = motors->armed() && motors->get_interlock();
|
const bool allow_output = motors->armed() && motors->get_interlock();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue