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

Add isLanding function

Checking for landing is used for a security purpose. If landing procedure is
triggered but not by the swarm management script, it means it has been triggered
externally most probably for emergency reason.
parent 02fe0274
......@@ -56,8 +56,9 @@ static const float DEFAULT_SPEED = 17;
static float last_override_altitude;
static float last_override_speed;
static bool first_coordinate_entered = false;
static bool do_projection = false;
static bool first_coordinate_entered = false;
static bool is_in_air = false;
// Logs functions
......@@ -300,6 +301,12 @@ int start(const char * ip, int port, const char * log_file, int timeout) {
current_position[4] = position.time_boot_ms + timestamp_difference;
});
telemetry->subscribe_landed_state([](const Telemetry::LandedState landed_state) {
if (landed_state == Telemetry::LandedState::InAir) {
is_in_air = true;
}
});
do {
log("Waiting for first telemetry");
sleep_for(seconds(1));
......@@ -479,11 +486,17 @@ float getClimbRate(void) {
return telemetry->fixedwing_metrics().climb_rate_m_s;
}
int gpsIsOk(void) {
Telemetry::FixType fixType = telemetry->gps_info().fix_type;
return (fixType != Telemetry::FixType::NoGps) && (fixType != Telemetry::FixType::NoFix);
}
int healthAllOk(void) {
return telemetry->health_all_ok();
}
int gpsIsOk(void) {
Telemetry::FixType fixType = telemetry->gps_info().fix_type;
return (fixType != Telemetry::FixType::NoGps) && (fixType != Telemetry::FixType::NoFix);
int isLanding(void) {
if (is_in_air && telemetry->landed_state() != Telemetry::LandedState::InAir)
return 1;
return 0;
}
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