Commit a8a8f6cd authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

Add isReadyToFly function

Provide isReadyToFly boolean instead of waiting for takeoff to finish.
It is now up to the user to check if the drone is ready to receive commands.
parent 76fbaa6e
......@@ -290,6 +290,7 @@ int start(const char * ip, int port, const char * log_file, int timeout) {
telemetry->subscribe_landed_state([](const Telemetry::LandedState landed_state) {
if (landed_state == Telemetry::LandedState::InAir) {
is_in_air = true;
doAction(&Action::transition_to_fixedwing, "Transition to fixedwing failed");
}
});
......@@ -345,23 +346,7 @@ int arm(void) {
int takeOff(void) {
action->set_takeoff_altitude(DEFAULT_OVERRIDE_ALTITUDE);
if (doAction(&Action::takeoff, "Takeoff failed"))
return -1;
return 0;
}
int takeOffAndWait(void) {
if (takeOff() < 0)
return -1;
while (telemetry->flight_mode() != Telemetry::FlightMode::Takeoff)
sleep_for(seconds(1));
while (telemetry->flight_mode() == Telemetry::FlightMode::Takeoff)
sleep_for(seconds(1));
return doAction(&Action::transition_to_fixedwing,
"Transition to fixedwing failed");
return doAction(&Action::takeoff, "Takeoff failed");
}
int triggerParachute(void) {
......@@ -471,6 +456,10 @@ int healthAllOk(void) {
return telemetry->health_all_ok();
}
int isReadyToFly(void) {
return is_in_air;
}
int isLanding(void) {
if (is_in_air && telemetry->landed_state() != Telemetry::LandedState::InAir)
return 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment