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