Reduced and improved logging

- removed unnecessary logging
- print start date and time when application starts
- use std::cout instead of qDebug()
- better logging in DroneController classes
- renamed Controller states for better readability
This commit is contained in:
Tuomas Järvinen
2024-10-18 21:45:20 +02:00
parent 91257d0ce7
commit 54b7dc41ca
7 changed files with 78 additions and 117 deletions
+39 -73
View File
@@ -16,7 +16,6 @@ AzDroneController::AzDroneController(AzMission &mission, QObject *parent)
, // TODO!! Autopilot or CompanionComputer? , // TODO!! Autopilot or CompanionComputer?
mDroneState(AZ_DRONE_STATE_DISCONNECTED) mDroneState(AZ_DRONE_STATE_DISCONNECTED)
{ {
qDebug() << "AzDroneController::AzDroneController() Thread ID: " << QThread::currentThreadId();
mFirstPosition.relative_altitude_m = -10000; mFirstPosition.relative_altitude_m = -10000;
mMissionController = new AzMissionController(mission, this); mMissionController = new AzMissionController(mission, this);
@@ -69,36 +68,32 @@ bool AzDroneController::stateConnect(void)
return true; return true;
} }
else { else {
std::cerr << "MAVSDK::add_any_connection() failed. Reason: " << result << endl; cout << "[CONTROLLER] MAVSDK::add_any_connection() failed. Reason: " << result << endl;
return false; return false;
} }
} }
bool AzDroneController::stateAutopilot(void) bool AzDroneController::stateGetSystem(void)
{ {
std::vector<std::shared_ptr<System>> systems = mMavsdk.systems(); vector<shared_ptr<System>> systems = mMavsdk.systems();
qDebug() << "AzDroneController::stateAutopilot() Found" << systems.size() << "systems";
if (systems.size() == 0) { if (systems.size() == 0) {
std::cerr << "No system found." << std::endl;
return false; return false;
} }
std::optional<std::shared_ptr<System>> autopilot = mMavsdk.first_autopilot(AZ_GET_AUTOPILOT_TIMEOUT); optional<shared_ptr<System>> autopilot = mMavsdk.first_autopilot(AZ_GET_AUTOPILOT_TIMEOUT);
if (autopilot.has_value()) { if (autopilot.has_value()) {
mSystem = autopilot.value(); mSystem = autopilot.value();
return true; return true;
} }
else {
qCritical() << "MAVSDK::first_autopilot() failed";
return false; return false;
}
} }
bool AzDroneController::stateTelemetryModule(void) bool AzDroneController::stateGetTelemetryModule(void)
{ {
if ((mTelemetry = new Telemetry(mSystem)) == nullptr) { if ((mTelemetry = new Telemetry(mSystem)) == nullptr) {
return false; return false;
@@ -106,7 +101,7 @@ bool AzDroneController::stateTelemetryModule(void)
const auto setRateResult = mTelemetry->set_rate_position(1); // 1 Hz const auto setRateResult = mTelemetry->set_rate_position(1); // 1 Hz
if (setRateResult != Telemetry::Result::Success) { if (setRateResult != Telemetry::Result::Success) {
qCritical() << "Setting rate failed: " << (int) setRateResult; cout << "[CONTROLLER] Setting telemetry rate failed: " << setRateResult << endl;
return false; return false;
} }
@@ -116,16 +111,11 @@ bool AzDroneController::stateTelemetryModule(void)
connect(this, &AzDroneController::newPosition, this, &AzDroneController::newPositionSlot, Qt::QueuedConnection); connect(this, &AzDroneController::newPosition, this, &AzDroneController::newPositionSlot, Qt::QueuedConnection);
mTelemetry->subscribe_position([this](Telemetry::Position position) { emit newPosition(position); }); mTelemetry->subscribe_position([this](Telemetry::Position position) { emit newPosition(position); });
// TODO!! This doesn't work. Check how ArduPilot sets home position.
Telemetry::Position home = mTelemetry->home();
qDebug() << "Home: lat:" << home.latitude_deg << "lon:" << home.longitude_deg
<< "altitude abs:" << home.absolute_altitude_m << "altitude rel:" << home.relative_altitude_m;
return true; return true;
} }
bool AzDroneController::stateActionModule(void) bool AzDroneController::stateGetActionModule(void)
{ {
mAction = new Action(mSystem); mAction = new Action(mSystem);
@@ -133,14 +123,12 @@ bool AzDroneController::stateActionModule(void)
mMissionController->setAction(mAction); mMissionController->setAction(mAction);
return true; return true;
} }
else {
qWarning() << "Creating new MAVSDK::Action failed";
return false; return false;
}
} }
bool AzDroneController::stateReadyForArming(void) bool AzDroneController::stateHealthOk(void)
{ {
bool result = mTelemetry->health_all_ok(); bool result = mTelemetry->health_all_ok();
@@ -160,7 +148,7 @@ bool AzDroneController::stateArm(void)
return true; return true;
} }
else { else {
std::cerr << "MAVSDK::Action::arm() failed. Reason: " << result << endl; cout << "[CONTROLLER] MAVSDK::Action::arm() failed. Reason: " << result << endl;
return false; return false;
} }
} }
@@ -175,15 +163,15 @@ bool AzDroneController::stateTakeoff(void)
mAction->set_takeoff_altitude(AZ_RELATIVE_FLY_ALTITUDE); mAction->set_takeoff_altitude(AZ_RELATIVE_FLY_ALTITUDE);
Action::Result result = mAction->takeoff(); Action::Result result = mAction->takeoff();
std::cerr << "MAVSDK::Action::takeoff() failed. Reason: " << result << endl; cout << "[CONTROLLER] MAVSDK::Action::takeoff() failed. Reason: " << result << endl;
return result == Action::Result::Success; return result == Action::Result::Success;
} }
bool AzDroneController::stateFlyMission(void) bool AzDroneController::stateFlyMission(void)
{ {
if (QCoreApplication::arguments().contains("quadcopter") && mCurrentPosition.relative_altitude_m < AZ_RELATIVE_FLY_ALTITUDE * 0.90) { if (mCurrentPosition.relative_altitude_m < AZ_RELATIVE_FLY_ALTITUDE * 0.90) {
qDebug() << "AzDroneController::stateFlyMission() 90% of set altitide is not reached yet."; cout << "[CONTROLLER] 90% of the takeoff altitide is not reached yet." << endl;
return false; return false;
} }
@@ -196,70 +184,54 @@ bool AzDroneController::stateFlyMission(void)
void AzDroneController::missionFinishedSlot(void) void AzDroneController::missionFinishedSlot(void)
{ {
// TODO!! Maybe use Telemetry::subscribe_landed_state() later to get the state of the landing. // TODO!! Maybe use Telemetry::subscribe_landed_state() later to get the state of the landing.
qDebug() << "AzDroneController::missionFinishedSlot() Mission finished. Landing the drone."; cout << "[CONTROLLER] Mission finished. Landing the drone." << endl;
Action::Result result = mAction->land(); Action::Result result = mAction->land();
if (result != Action::Result::Success) { if (result != Action::Result::Success) {
std::cerr << "mAction->land() failed. Reason: " << result << endl; cout << "[CONTROLLER] MAVSDK::Action::land() failed. Reason: " << result << endl;
} }
} }
void AzDroneController::droneStateMachineSlot(void) void AzDroneController::droneStateMachineSlot(void)
{ {
static const QString states[] = {
"DISCONNECTED",
"CONNECTED",
"AUTOPILOT",
"TELEMETRY_MODULE",
"ACTION_MODULE",
"READY_FOR_ARMING",
"ARMED",
"TAKE_OFF",
"FLY_MISSION",
"LAND",
};
qDebug() << "\nAzDroneController::droneStateMachineSlot() Current state:" << states[(int) mDroneState];
using MethodPtr = bool (AzDroneController::*)(); using MethodPtr = bool (AzDroneController::*)();
struct MethodInfo struct MethodInfo
{ {
AzDroneState currentState; AzDroneState currentState;
MethodPtr nextStateMethodPtr; MethodPtr nextStateMethodPtr;
QString description; string description;
int nextStateDelay; int nextStateDelay;
}; };
static const MethodInfo stateMethods[] static const MethodInfo stateMethods[]
= {{AZ_DRONE_STATE_DISCONNECTED, &AzDroneController::stateConnect, "stateConnect()", 1000}, = {{AZ_DRONE_STATE_DISCONNECTED, &AzDroneController::stateConnect, "Connecting to autopilot", 1000},
{AZ_DRONE_STATE_CONNECTED, &AzDroneController::stateAutopilot, "stateAutopilot()", 1000}, {AZ_DRONE_STATE_CONNECTED, &AzDroneController::stateGetSystem, "Getting MAVSDK system", 1000},
{AZ_DRONE_STATE_AUTOPILOT, &AzDroneController::stateTelemetryModule, "stateTelemetryModule()", 1000}, {AZ_DRONE_STATE_GOT_SYSTEM, &AzDroneController::stateGetTelemetryModule, "Getting telemetry module", 1000},
{AZ_DRONE_STATE_TELEMETRY_MODULE, &AzDroneController::stateActionModule, "stateActionModule()", 1000}, {AZ_DRONE_STATE_GOT_TELEMETRY_MODULE, &AzDroneController::stateGetActionModule, "Getting action module", 1000},
{AZ_DRONE_STATE_ACTION_MODULE, &AzDroneController::stateReadyForArming, "stateReadyForArming()", 1000}, {AZ_DRONE_STATE_GOT_ACTION_MODULE, &AzDroneController::stateHealthOk, "Drone health OK", 1000},
{AZ_DRONE_STATE_READY_FOR_ARMING, &AzDroneController::stateArm, "stateArm()", 1000}, {AZ_DRONE_STATE_HEALTH_OK, &AzDroneController::stateArm, "Arming the drone", 1000},
{AZ_DRONE_STATE_ARMED, &AzDroneController::stateTakeoff, "stateTakeoff()", 10000}, {AZ_DRONE_STATE_ARMED, &AzDroneController::stateTakeoff, "Takeoff the drone", 10000},
{AZ_DRONE_STATE_TAKE_OFF, &AzDroneController::stateFlyMission, "stateFlyMission()", 1000}, {AZ_DRONE_STATE_TAKE_OFF, &AzDroneController::stateFlyMission, "Starting the mission", 1000},
{AZ_DRONE_STATE_FLY_MISSION, nullptr, "No function to call. AzMissionControl running", 0}}; {AZ_DRONE_STATE_FLY_MISSION, nullptr, "Mission started", 0}};
// Iterate through states. If the state function fails, it's repeated until it succeeds. // Iterate through states. If the state function fails, it's repeated until it succeeds.
for (uint i = 0; i < sizeof(stateMethods) / sizeof(MethodInfo); i++) { for (uint i = 0; i < sizeof(stateMethods) / sizeof(MethodInfo); i++) {
if (stateMethods[i].currentState == mDroneState) { if (stateMethods[i].currentState == mDroneState) {
if (mDroneState == AZ_DRONE_STATE_FLY_MISSION) { if (mDroneState == AZ_DRONE_STATE_FLY_MISSION) {
qDebug() << "AzMissionContoroller running. Waiting signals from it."; cout << "[CONTROLLER] Waiting signals from the mission controller." << endl;
return; return;
} }
bool result = (this->*stateMethods[i].nextStateMethodPtr)(); bool result = (this->*stateMethods[i].nextStateMethodPtr)();
if (result) { if (result) {
qDebug() << "AzDroneController::droneStateMachineSlot()" << stateMethods[i].description << "succeeded"; cout << "[CONTROLLER] " << stateMethods[i].description << " succeeded." << endl;
mDroneState = stateMethods[i + 1].currentState; mDroneState = stateMethods[i + 1].currentState;
} }
else { else {
qDebug() << "AzDroneController::droneStateMachineSlot()" << stateMethods[i].description cout << "[CONTROLLER] " << stateMethods[i].description << " failed. Trying again." << endl;
<< "failed. Trying again.";
} }
delayedStateCallSlot(stateMethods[i].nextStateDelay); delayedStateCallSlot(stateMethods[i].nextStateDelay);
@@ -272,14 +244,12 @@ void AzDroneController::droneStateMachineSlot(void)
void AzDroneController::newPositionSlot(Telemetry::Position position) void AzDroneController::newPositionSlot(Telemetry::Position position)
{ {
qDebug() << "AzDroneController::newPositionSlot()" << position.latitude_deg << position.longitude_deg; cout << "[CONTROLLER] GPS position " << position.latitude_deg << ", " << position.longitude_deg << endl;
// Save first position. It will be used later to set altitude for missions. // Save first position. It will be used later to set altitude for missions.
// TODO!! Probably we want to use rangefinder or at least barometer with altitude from the map later. // TODO!! Probably we want to use rangefinder or at least barometer with altitude from the map later.
if (mFirstPosition.relative_altitude_m < -1000) { if (mFirstPosition.relative_altitude_m < -1000) {
qDebug() << "AzDroneController::newPositionSlot()" cout << "[CONTROLLER] First altitude " << mFirstPosition.relative_altitude_m << endl;
<< "First altitude" << mFirstPosition.relative_altitude_m << "lat:" << position.latitude_deg
<< "lon:" << position.longitude_deg;
mFirstPosition = position; mFirstPosition = position;
} }
@@ -289,28 +259,24 @@ void AzDroneController::newPositionSlot(Telemetry::Position position)
if (mDroneState == AZ_DRONE_STATE_FLY_MISSION) { if (mDroneState == AZ_DRONE_STATE_FLY_MISSION) {
mMissionController->newPosition(position); mMissionController->newPosition(position);
} }
else {
qDebug() << "AzDroneController::newPositionSlot() altitude rel:" << position.relative_altitude_m
<< "altitude abs:" << position.absolute_altitude_m;
}
} }
void AzDroneController::missionIndexChangedSlot(int currentIndex, int totalIndexes) void AzDroneController::missionIndexChangedSlot(int currentIndex, int totalIndexes)
{ {
qDebug() << "AzDroneController::missionIndexChanged()" << currentIndex << "/" << totalIndexes; cout << "[CONTROLLER] missionIndexChanged() " << currentIndex << "/" << totalIndexes << endl;
} }
void AzDroneController::newHealthInfoSlot(Telemetry::Health health) void AzDroneController::newHealthInfoSlot(Telemetry::Health health)
{ {
qDebug() << "AzDroneController::newHealthInfoSlot()"; cout << "[CONTROLLER] newHealthInfo:" << endl;
qDebug() << " Gyro calibration: " << (health.is_gyrometer_calibration_ok ? "ok" : "not ok"); cout << "[CONTROLLER] Gyro calibration: " << (health.is_gyrometer_calibration_ok ? "OK" : "FAILED") << endl;
qDebug() << " Accel calibration: " << (health.is_accelerometer_calibration_ok ? "ok" : "not ok"); cout << "[CONTROLLER] Accel calibration: " << (health.is_accelerometer_calibration_ok ? "OK" : "FAILED") << endl;
qDebug() << " Mag calibration: " << (health.is_magnetometer_calibration_ok ? "ok" : "not ok"); cout << "[CONTROLLER] Mag calibration: " << (health.is_magnetometer_calibration_ok ? "OK" : "FAILED") << endl;
qDebug() << " Local position: " << (health.is_local_position_ok ? "ok" : "not ok"); cout << "[CONTROLLER] Local position: " << (health.is_local_position_ok ? "OK" : "FAILED") << endl;
qDebug() << " Global position: " << (health.is_global_position_ok ? "ok" : "not ok"); cout << "[CONTROLLER] Global position: " << (health.is_global_position_ok ? "OK" : "FAILED") << endl;
qDebug() << " Home position: " << (health.is_home_position_ok ? "ok" : "not ok"); cout << "[CONTROLLER] Home position: " << (health.is_home_position_ok ? "OK" : "FAILED") << endl;
// Stop printing healt information if everything in healt is OK. // Stop printing healt information if everything in healt is OK.
if (health.is_gyrometer_calibration_ok && if (health.is_gyrometer_calibration_ok &&
+10 -10
View File
@@ -15,13 +15,13 @@ using namespace mavsdk;
typedef enum { typedef enum {
AZ_DRONE_STATE_DISCONNECTED, AZ_DRONE_STATE_DISCONNECTED,
AZ_DRONE_STATE_CONNECTED, AZ_DRONE_STATE_CONNECTED,
AZ_DRONE_STATE_AUTOPILOT, AZ_DRONE_STATE_GOT_SYSTEM,
AZ_DRONE_STATE_TELEMETRY_MODULE, AZ_DRONE_STATE_GOT_TELEMETRY_MODULE,
AZ_DRONE_STATE_ACTION_MODULE, AZ_DRONE_STATE_GOT_ACTION_MODULE,
AZ_DRONE_STATE_READY_FOR_ARMING, AZ_DRONE_STATE_HEALTH_OK,
AZ_DRONE_STATE_ARMED, AZ_DRONE_STATE_ARMED,
AZ_DRONE_STATE_TAKE_OFF, AZ_DRONE_STATE_TAKE_OFF,
AZ_DRONE_STATE_WAITING_HOLD_MODE, AZ_DRONE_STATE_AUTO_MODE_ACTIVATED,
AZ_DRONE_STATE_FLY_MISSION, AZ_DRONE_STATE_FLY_MISSION,
AZ_DRONE_STATE_LAND, AZ_DRONE_STATE_LAND,
AZ_DRONE_STATE_END, AZ_DRONE_STATE_END,
@@ -39,10 +39,10 @@ public:
protected: protected:
// Specify the methods that will be called one at a time to initialise the drone and fly the mission. // Specify the methods that will be called one at a time to initialise the drone and fly the mission.
bool stateConnect(void); bool stateConnect(void);
bool stateAutopilot(void); bool stateGetSystem(void);
bool stateTelemetryModule(void); bool stateGetTelemetryModule(void);
bool stateActionModule(void); bool stateGetActionModule(void);
bool stateReadyForArming(void); bool stateHealthOk(void);
bool stateArm(void); bool stateArm(void);
bool stateTakeoff(void); bool stateTakeoff(void);
bool stateFlyMission(void); bool stateFlyMission(void);
@@ -82,7 +82,7 @@ signals:
protected: protected:
Mavsdk mMavsdk; Mavsdk mMavsdk;
AzDroneState mDroneState; AzDroneState mDroneState;
std::shared_ptr<System> mSystem; shared_ptr<System> mSystem;
Telemetry *mTelemetry; Telemetry *mTelemetry;
Action *mAction; Action *mAction;
Telemetry::Position mFirstPosition; Telemetry::Position mFirstPosition;
+14 -28
View File
@@ -7,67 +7,53 @@ AzDroneControllerPlane::AzDroneControllerPlane(AzMission &mission, QObject *pare
{} {}
bool AzDroneControllerPlane::stateWaitingMissionMode(void) bool AzDroneControllerPlane::stateWaitAutoSwitch(void)
{ {
Telemetry::FlightMode flight_mode = mTelemetry->flight_mode(); Telemetry::FlightMode flight_mode = mTelemetry->flight_mode();
std::cout << "azDroneControllerPlane::stateWaitingHoldMode() Current mode: " << flight_mode << std::endl; cout << "[CONTROLLER] Current flight mode: " << flight_mode << endl;
return flight_mode == Telemetry::FlightMode::Mission; return flight_mode == Telemetry::FlightMode::Mission;
} }
void AzDroneControllerPlane::droneStateMachineSlot(void) void AzDroneControllerPlane::droneStateMachineSlot(void)
{ {
static const QString states[] = {
"DISCONNECTED",
"CONNECTED",
"AUTOPILOT",
"TELEMETRY_MODULE",
"ACTION_MODULE",
"READY_FOR_ARMING",
"AZ_DRONE_STATE_WAITING_MISSION_MODE",
"FLY_MISSION"
};
qDebug() << "\nAzDroneControllerPlane::droneStateMachineSlot() Current state:" << states[(int) mDroneState];
using MethodPtr = bool (AzDroneControllerPlane::*)(); using MethodPtr = bool (AzDroneControllerPlane::*)();
struct MethodInfo struct MethodInfo
{ {
AzDroneState currentState; AzDroneState currentState;
MethodPtr nextStateMethodPtr; MethodPtr nextStateMethodPtr;
QString description; string description;
int nextStateDelay; int nextStateDelay;
}; };
// Plane type will pass arming and taking off states and wait for auto mode from the RC controller instead. // Plane type will pass arming and taking off states and wait for auto mode from the RC controller instead.
static const MethodInfo stateMethods[] static const MethodInfo stateMethods[]
= {{AZ_DRONE_STATE_DISCONNECTED, &AzDroneControllerPlane::stateConnect, "stateConnect()", 1000}, = {{AZ_DRONE_STATE_DISCONNECTED, &AzDroneControllerPlane::stateConnect, "Connecting to autopilot", 1000},
{AZ_DRONE_STATE_CONNECTED, &AzDroneControllerPlane::stateAutopilot, "stateAutopilot()", 1000}, {AZ_DRONE_STATE_CONNECTED, &AzDroneControllerPlane::stateGetSystem, "Getting MAVSDK system", 1000},
{AZ_DRONE_STATE_AUTOPILOT, &AzDroneControllerPlane::stateTelemetryModule, "stateTelemetryModule()", 1000}, {AZ_DRONE_STATE_GOT_SYSTEM, &AzDroneControllerPlane::stateGetTelemetryModule, "Getting telemetry module", 1000},
{AZ_DRONE_STATE_TELEMETRY_MODULE, &AzDroneControllerPlane::stateActionModule, "stateActionModule()", 1000}, {AZ_DRONE_STATE_GOT_TELEMETRY_MODULE, &AzDroneControllerPlane::stateGetActionModule, "Getting action module", 1000},
{AZ_DRONE_STATE_ACTION_MODULE, &AzDroneControllerPlane::stateReadyForArming, "stateReadyForArming()", 1000}, {AZ_DRONE_STATE_GOT_ACTION_MODULE, &AzDroneControllerPlane::stateHealthOk, "Drone health OK", 1000},
{AZ_DRONE_STATE_ARMED, &AzDroneControllerPlane::stateWaitingMissionMode, "stateWaitingMissionMode()", 1000}, {AZ_DRONE_STATE_HEALTH_OK, &AzDroneControllerPlane::stateWaitAutoSwitch, "User switched to AUTO mode", 1000},
{AZ_DRONE_STATE_WAITING_HOLD_MODE, &AzDroneControllerPlane::stateFlyMission, "stateFlyMission()", 1000}, {AZ_DRONE_STATE_AUTO_MODE_ACTIVATED, &AzDroneControllerPlane::stateFlyMission, "Starting the mission", 1000},
{AZ_DRONE_STATE_FLY_MISSION, nullptr, "No function to call. AzMissionControl running", 0}}; {AZ_DRONE_STATE_FLY_MISSION, nullptr, "Mission started", 0}};
// Iterate through states. If the state function fails, it's repeated until it succeeds. // Iterate through states. If the state function fails, it's repeated until it succeeds.
for (uint i = 0; i < sizeof(stateMethods) / sizeof(MethodInfo); i++) { for (uint i = 0; i < sizeof(stateMethods) / sizeof(MethodInfo); i++) {
if (stateMethods[i].currentState == mDroneState) { if (stateMethods[i].currentState == mDroneState) {
if (mDroneState == AZ_DRONE_STATE_FLY_MISSION) { if (mDroneState == AZ_DRONE_STATE_FLY_MISSION) {
qDebug() << "AzMissionContoroller running. Waiting signals from it."; cout << "[CONTROLLER] Waiting signals from the mission controller." << endl;
return; return;
} }
bool result = (this->*stateMethods[i].nextStateMethodPtr)(); bool result = (this->*stateMethods[i].nextStateMethodPtr)();
if (result) { if (result) {
qDebug() << "AzDroneControllerPlane::droneStateMachineSlot()" << stateMethods[i].description << "succeeded"; cout << "[CONTROLLER] " << stateMethods[i].description << " succeeded." << endl;
mDroneState = stateMethods[i + 1].currentState; mDroneState = stateMethods[i + 1].currentState;
} }
else { else {
qDebug() << "AzDroneControllerPlane::droneStateMachineSlot()" << stateMethods[i].description cout << "[CONTROLLER] " << stateMethods[i].description << " failed. Trying again." << endl;
<< "failed. Trying again.";
} }
delayedStateCallSlot(stateMethods[i].nextStateDelay); delayedStateCallSlot(stateMethods[i].nextStateDelay);
+1 -1
View File
@@ -11,5 +11,5 @@ public:
protected: protected:
void droneStateMachineSlot(void) override; void droneStateMachineSlot(void) override;
bool stateWaitingMissionMode(void); bool stateWaitAutoSwitch(void);
}; };
+1 -1
View File
@@ -33,7 +33,7 @@ public:
AzCoordinate getReturnPoint(void) const; AzCoordinate getReturnPoint(void) const;
friend std::ostream &operator<<(std::ostream &os, const AzMission &obj); friend ostream &operator<<(ostream &os, const AzMission &obj);
private: private:
void parse(void); void parse(void);
+2 -2
View File
@@ -51,7 +51,7 @@ bool AzMissionController::flyToNextMissionItem(void)
return true; return true;
} }
else { else {
std::cerr << "mAction->goto_location() failed. Reason: " << result << endl; cerr << "mAction->goto_location() failed. Reason: " << result << endl;
return false; return false;
} }
} }
@@ -71,7 +71,7 @@ bool AzMissionController::flyToNextMissionItem(void)
return true; return true;
} }
else { else {
std::cerr << "mAction->goto_location() failed. Reason: " << result << endl; cerr << "mAction->goto_location() failed. Reason: " << result << endl;
return false; return false;
} }
} }
+9
View File
@@ -1,3 +1,5 @@
#include <ctime>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
@@ -8,6 +10,13 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// Add current data and time for easier log handling.
std::cout << "\n#################################################\n";
std::time_t currentTime = std::time(nullptr);
std::tm* localTime = std::localtime(&currentTime);
std::cout << "Starting autopilot program at " << std::put_time(localTime, "%Y-%m-%d %H:%M:%S") << std::endl;
std::cout << "#################################################\n";
// This is needed to have main event loop and signal-slot events in the AzDroneController. // This is needed to have main event loop and signal-slot events in the AzDroneController.
QCoreApplication a(argc, argv); QCoreApplication a(argc, argv);