Files
autopilot/src/main.cpp
T
Tuomas Järvinen 05722c0e09 Added initial support for the ArduPlane. Added mandatory command line options.
How to use ArduCopter:
  Launch simulator with command: "./Tools/autotest/sim_vehicle.py --map --console -v ArduCopter"
  Launch autopilot with command: "./autopilot mission.json quadcopter udp"

How to use ArduPlane:
  Launch simulator with command: "./Tools/autotest/sim_vehicle.py --map --console -v ArduPlane"
  Wait 30 seconds and give following commands in the same terminal
    arm throttle
    mode takeoff
  Launch autopilot with command: "./autopilot mission.json plane udp"

Type: New Feature
2024-06-02 09:37:55 +02:00

47 lines
1.5 KiB
C++

#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include "az_drone_controller.h"
#include "az_mission.h"
int main(int argc, char *argv[])
{
// 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.
AzDroneController droneController(mission);
droneController.start();
return a.exec();
}