mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 08:06:35 +00:00
Changed directory structure and renamed applications
- autopilot -> drone_controller - rtsp_ai_player -> ai_controller - added top level qmake project file - updated documentation - moved small demo applications from tmp/ to misc/
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#include <ctime>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
|
||||
#include "az_drone_controller.h"
|
||||
#include "az_drone_controller_plane.h"
|
||||
#include "az_mission.h"
|
||||
|
||||
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(¤tTime);
|
||||
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.
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
if (a.arguments().size() != 4) {
|
||||
qCritical() << "\nProgram needs three command line parameters.";
|
||||
qCritical() << "\tFirst argument: mission JSON file.";
|
||||
qCritical() << "\tSecond argument: \"quadcopter\" or \"plane\".";
|
||||
qCritical() << "\tThird argument: \"udp\" or \"serial\" for connection type.";
|
||||
qCritical() << "\tFor example ./autopilot mission.json plane udp";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (QFile::exists(a.arguments().at(1)) == false) {
|
||||
qCritical() << "\nMission file doesn't exist";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (a.arguments().at(2) != "plane" && a.arguments().at(2) != "quadcopter") {
|
||||
qCritical() << "\nPass \"quadcopter\" or \"plane\" for drone type as second argument";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (a.arguments().at(3) != "udp" && a.arguments().at(3) != "serial") {
|
||||
qCritical() << "Pass \"udp\" or \"serial\" for connection type as third argument";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Reads mission from the JSON file which is given as command line option.
|
||||
AzMission mission(argv[1]);
|
||||
cout << mission;
|
||||
|
||||
// Launch a drone controller using the MAVSDK for ArduPilot-based flight controllers.
|
||||
bool isPlane = a.arguments().at(2) == "plane";
|
||||
AzDroneController *controller = isPlane ? new AzDroneControllerPlane(mission) : new AzDroneController(mission);
|
||||
controller->start();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user