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

Do not check if user started mavsdk

It is now up to the user to check if mavsdk has been started before calling
commands.
parent a8a8f6cd
......@@ -44,7 +44,6 @@ static const float ADDED_DISTANCE = (2 * DEFAULT_RADIUS) / EARTH_RADIUS;
static const double COS_ADDED_DISTANCE = cos(ADDED_DISTANCE);
static const double SIN_ADDED_DISTANCE = sin(ADDED_DISTANCE);
static int mavsdk_started = 0;
static Telemetry::Position origin;
static int64_t current_position[POSITION_ARRAY_SIZE] = {0};
static int64_t timestamp_difference = 0;
......@@ -76,11 +75,6 @@ static void log_error_from_result(std::string message, Enumeration result) {
// Action functions
static int doAction(Action::Result (Action::*toDo)(void) const, std::string failure_message) {
if(!mavsdk_started) {
log_error("Mavsdk not started");
return -1;
}
const Action::Result result = (action->*toDo)();
if(result != Action::Result::Success) {
log_error_from_result(failure_message, result);
......@@ -144,9 +138,6 @@ static Coordinates getProjectionCoordinates(Coordinates destination, Coordinates
}
static int doReposition(float la, float lo, float radius, float y) {
if (!mavsdk_started)
return -1;
MavlinkPassthrough::CommandLong command;
command.command = MAV_CMD_DO_REPOSITION;
command.param1 = -1; // Ground speed, -1 for default
......@@ -184,9 +175,6 @@ static long long int getTimestamp() {
}
static int doOverride(float altitude, float airspeed, const char* failure_msg) {
if (!mavsdk_started)
return -1;
MavlinkPassthrough::CommandLong command;
command.command = MAV_CMD_DO_OVERRIDE;
command.param1 = 1 | 2 | 4 | 8;
......@@ -209,28 +197,26 @@ void updateLogAndProjection(void) {
std::ostringstream oss;
Telemetry::FixedwingMetrics metrics;
if(mavsdk_started) {
metrics = telemetry->fixedwing_metrics();
oss << current_position[TIMESTAMP] << ";"
<< current_position[LATITUDE] << ";"
<< current_position[LONGITUDE] << ";"
<< current_position[ABS_ALTITUDE] << ";"
<< current_position[REL_ALTITUDE] << ";"
<< telemetry->attitude_euler().yaw_deg << ";"
<< metrics.airspeed_m_s << ";" << metrics.climb_rate_m_s;
log(oss.str());
if (do_projection) {
updateProjection(current_position[LATITUDE],
current_position[LONGITUDE]);
} else {
doReposition_async(
(float)targeted_destination.latitude,
(float)targeted_destination.longitude,
targeted_radius,
0
);
}
metrics = telemetry->fixedwing_metrics();
oss << current_position[TIMESTAMP] << ";"
<< current_position[LATITUDE] << ";"
<< current_position[LONGITUDE] << ";"
<< current_position[ABS_ALTITUDE] << ";"
<< current_position[REL_ALTITUDE] << ";"
<< telemetry->attitude_euler().yaw_deg << ";"
<< metrics.airspeed_m_s << ";" << metrics.climb_rate_m_s;
log(oss.str());
if (do_projection) {
updateProjection(current_position[LATITUDE],
current_position[LONGITUDE]);
} else {
doReposition_async(
(float)targeted_destination.latitude,
(float)targeted_destination.longitude,
targeted_radius,
0
);
}
}
......@@ -302,8 +288,6 @@ int start(const char * ip, int port, const char * log_file, int timeout) {
origin = telemetry->position();
log("MAVSDK started...");
mavsdk_started = 1;
log("timestamp (ms);latitude (°E7);longitude (°E7);AMSL (mm);rel altitude (mm);yaw (°);air speed (m/s);climb rate (m/s)");
return 0;
......@@ -328,9 +312,6 @@ int reboot() {
// Flight state management functions
int arm(void) {
if(!mavsdk_started)
return -1;
if (telemetry->armed()) {
return 0;
}
......@@ -350,9 +331,6 @@ int takeOff(void) {
}
int triggerParachute(void) {
if (!mavsdk_started)
return -1;
log("Landing...");
MavlinkPassthrough::CommandLong command;
command.command = MAV_CMD_DO_PARACHUTE;
......@@ -378,11 +356,6 @@ void loiter(double latitude, double longitude, float altitude,
void setTargetCoordinates(double latitude, double longitude, float altitude,
float speed) {
if (!mavsdk_started) {
log_error("Mavsdk not started");
return;
}
targeted_destination.latitude = latitude;
targeted_destination.longitude = longitude;
do_projection = true;
......
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