[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:
Dino Hensen
2013-06-17 00:11:25 +02:00
committed by Felix Ruess
parent 1931ec6628
commit cf0dba85ef
2 changed files with 36 additions and 2 deletions
+2 -2
View File
@@ -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);
}
}