mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-10 09:58:28 -04:00
Plane: It is possible to disarm with left rudder.
Using is_flying() avoid accidentally disarming while flying.
This commit is contained in:
parent
8240e5ae65
commit
da41d85433
@ -786,7 +786,7 @@ private:
|
|||||||
void set_control_channels(void);
|
void set_control_channels(void);
|
||||||
void init_rc_in();
|
void init_rc_in();
|
||||||
void init_rc_out();
|
void init_rc_out();
|
||||||
void rudder_arm_check();
|
void rudder_arm_disarm_check();
|
||||||
void read_radio();
|
void read_radio();
|
||||||
void control_failsafe(uint16_t pwm);
|
void control_failsafe(uint16_t pwm);
|
||||||
void trim_control_surfaces();
|
void trim_control_surfaces();
|
||||||
|
@ -76,8 +76,8 @@ void Plane::init_rc_out()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for pilot input on rudder stick for arming
|
// check for pilot input on rudder stick for arming/disarming
|
||||||
void Plane::rudder_arm_check()
|
void Plane::rudder_arm_disarm_check()
|
||||||
{
|
{
|
||||||
//TODO: ensure rudder arming disallowed during radio calibration
|
//TODO: ensure rudder arming disallowed during radio calibration
|
||||||
|
|
||||||
@ -85,45 +85,60 @@ void Plane::rudder_arm_check()
|
|||||||
|
|
||||||
static uint32_t rudder_arm_timer;
|
static uint32_t rudder_arm_timer;
|
||||||
|
|
||||||
if (arming.is_armed()) {
|
|
||||||
//already armed, no need to run remainder of this function
|
|
||||||
rudder_arm_timer = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! arming.rudder_arming_enabled()) {
|
if (! arming.rudder_arming_enabled()) {
|
||||||
//parameter disallows rudder arming
|
//parameter disallows rudder arming/disabling
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if throttle is not down, then pilot cannot rudder arm
|
//if throttle is not down, then pilot cannot rudder arm/disarm
|
||||||
if (channel_throttle->control_in > 0) {
|
if (channel_throttle->control_in > 0) {
|
||||||
rudder_arm_timer = 0;
|
rudder_arm_timer = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if not in a 'manual' mode then disallow rudder arming
|
//if not in a 'manual' mode then disallow rudder arming/disarming
|
||||||
if (auto_throttle_mode ) {
|
if (auto_throttle_mode ) {
|
||||||
rudder_arm_timer = 0;
|
rudder_arm_timer = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// full right rudder starts arming counter
|
if (!arming.is_armed()) {
|
||||||
if (channel_rudder->control_in > 4000) {
|
// when not armed, full right rudder starts arming counter
|
||||||
uint32_t now = millis();
|
if (channel_rudder->control_in > 4000) {
|
||||||
|
uint32_t now = millis();
|
||||||
|
|
||||||
if (rudder_arm_timer == 0 ||
|
if (rudder_arm_timer == 0 ||
|
||||||
now - rudder_arm_timer < 3000) {
|
now - rudder_arm_timer < 3000) {
|
||||||
|
|
||||||
if (rudder_arm_timer == 0) rudder_arm_timer = now;
|
if (rudder_arm_timer == 0) rudder_arm_timer = now;
|
||||||
} else {
|
} else {
|
||||||
//time to arm!
|
//time to arm!
|
||||||
arm_motors(AP_Arming::RUDDER);
|
arm_motors(AP_Arming::RUDDER);
|
||||||
}
|
rudder_arm_timer = 0;
|
||||||
} else {
|
}
|
||||||
// not at full right rudder
|
} else {
|
||||||
rudder_arm_timer = 0;
|
// not at full right rudder
|
||||||
}
|
rudder_arm_timer = 0;
|
||||||
|
}
|
||||||
|
} else if (!is_flying()) {
|
||||||
|
// when armed and not flying, full left rudder starts disarming counter
|
||||||
|
if (channel_rudder->control_in < -4000) {
|
||||||
|
uint32_t now = millis();
|
||||||
|
|
||||||
|
if (rudder_arm_timer == 0 ||
|
||||||
|
now - rudder_arm_timer < 3000) {
|
||||||
|
|
||||||
|
if (rudder_arm_timer == 0) rudder_arm_timer = now;
|
||||||
|
} else {
|
||||||
|
//time to disarm!
|
||||||
|
disarm_motors();
|
||||||
|
rudder_arm_timer = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// not at full left rudder
|
||||||
|
rudder_arm_timer = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plane::read_radio()
|
void Plane::read_radio()
|
||||||
@ -177,7 +192,7 @@ void Plane::read_radio()
|
|||||||
throttle_nudge = 0;
|
throttle_nudge = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rudder_arm_check();
|
rudder_arm_disarm_check();
|
||||||
|
|
||||||
if (g.rudder_only != 0) {
|
if (g.rudder_only != 0) {
|
||||||
// in rudder only mode we discard rudder input and get target
|
// in rudder only mode we discard rudder input and get target
|
||||||
|
Loading…
Reference in New Issue
Block a user