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

Log and project from external call instead of using callbacks

parent 4f8494f5
......@@ -161,6 +161,27 @@ static int updateProjection(double current_lat, double current_lon) {
);
}
int updateLogAndProjection(void) {
std::ostringstream oss;
Telemetry::RawGps gps;
if(mavsdk_started) {
gps = telemetry->raw_gps ();
oss << (gps.timestamp_us - init_timestamp) / 1000 << ";"
<< gps.latitude_deg << ";" << gps.longitude_deg << ";"
<< gps.absolute_altitude_m << ";" << telemetry->position().relative_altitude_m << ";"
<< telemetry->attitude_euler().yaw_deg << ";"
<< gps.velocity_m_s << ";" << telemetry->fixedwing_metrics().climb_rate_m_s;
log(oss.str());
if (projected_destination.latitude != 0 || targeted_destination.latitude != 0) {
return updateProjection(gps.latitude_deg, gps.longitude_deg);
}
}
return 0;
}
// Connexion management functions
int start(const char * ip, int port, const char * log_file, int timeout) {
......@@ -213,19 +234,6 @@ int start(const char * ip, int port, const char * log_file, int timeout) {
mavsdk_started = 1;
log("timestamp (ms);latitude (°);longitude (°);AMSL (m);rel altitude (m);yaw (°);ground speed (m/s);climb rate (m/s)");
log("Subscribing to raw GPS...");
telemetry->subscribe_raw_gps([](Telemetry::RawGps gps) {
std::ostringstream oss;
oss << (gps.timestamp_us - init_timestamp) / 1000 << ";"
<< gps.latitude_deg << ";" << gps.longitude_deg << ";"
<< gps.absolute_altitude_m << ";" << telemetry->position().relative_altitude_m << ";"
<< telemetry->attitude_euler().yaw_deg << ";"
<< gps.velocity_m_s << ";" << telemetry->fixedwing_metrics().climb_rate_m_s;
log(oss.str());
if (projected_destination.latitude != 0 || targeted_destination.latitude != 0)
updateProjection(gps.latitude_deg, gps.longitude_deg);
});
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