mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-22 20:36:06 +08:00
[rotorcraft] check_in_flight without RC
Closes #464 Changes to make ARDrone2 SDK fly without joystick Still needs to be properly solved as per issue #201
This commit is contained in:
@@ -98,8 +98,8 @@
|
||||
|
||||
<section name="AUTOPILOT">
|
||||
<define name="MODE_MANUAL" value="AP_MODE_RC_DIRECT" />
|
||||
<define name="MODE_AUTO1" value="AP_MODE_HOVER_Z_HOLD" />
|
||||
<define name="MODE_AUTO2" value="AP_MODE_NAV" />
|
||||
<define name="MODE_AUTO1" value="AP_MODE_NAV" />
|
||||
<define name="MODE_AUTO2" value="AP_MODE_HOVER_Z_HOLD" />
|
||||
</section>
|
||||
|
||||
<section name="BAT">
|
||||
|
||||
@@ -92,6 +92,36 @@ void autopilot_init(void) {
|
||||
}
|
||||
|
||||
|
||||
static inline void autopilot_check_in_flight_no_rc( bool_t motors_on ) {
|
||||
if (autopilot_in_flight) {
|
||||
if (autopilot_in_flight_counter > 0) {
|
||||
if (stabilization_cmd[COMMAND_THRUST] == 0) {
|
||||
autopilot_in_flight_counter--;
|
||||
if (autopilot_in_flight_counter == 0) {
|
||||
autopilot_in_flight = FALSE;
|
||||
}
|
||||
}
|
||||
else { /* !THROTTLE_STICK_DOWN */
|
||||
autopilot_in_flight_counter = AUTOPILOT_IN_FLIGHT_TIME;
|
||||
}
|
||||
}
|
||||
}
|
||||
else { /* not in flight */
|
||||
if (autopilot_in_flight_counter < AUTOPILOT_IN_FLIGHT_TIME &&
|
||||
motors_on) {
|
||||
if (stabilization_cmd[COMMAND_THRUST] > 0) {
|
||||
autopilot_in_flight_counter++;
|
||||
if (autopilot_in_flight_counter == AUTOPILOT_IN_FLIGHT_TIME)
|
||||
autopilot_in_flight = TRUE;
|
||||
}
|
||||
else { /* THROTTLE_STICK_DOWN */
|
||||
autopilot_in_flight_counter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void autopilot_periodic(void) {
|
||||
|
||||
RunOnceEvery(NAV_PRESCALER, nav_periodic_task());
|
||||
@@ -118,6 +148,10 @@ INFO("Using FAILSAFE_GROUND_DETECT")
|
||||
SetRotorcraftCommands(stabilization_cmd, autopilot_in_flight, autopilot_motors_on);
|
||||
}
|
||||
|
||||
// when we dont have RC, check in flight by looking at throttle
|
||||
if (radio_control.status != RC_OK) {
|
||||
autopilot_check_in_flight_no_rc(autopilot_motors_on);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user