mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 12:06:34 +00:00
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
This commit is contained in:
@@ -179,7 +179,7 @@ void AzDroneController::missionFinishedSlot(void)
|
||||
|
||||
void AzDroneController::droneStateMachineSlot(void)
|
||||
{
|
||||
static QString states[] = {
|
||||
static const QString states[] = {
|
||||
"DISCONNECTED",
|
||||
"CONNECTED",
|
||||
"AUTOPILOT",
|
||||
@@ -205,7 +205,7 @@ void AzDroneController::droneStateMachineSlot(void)
|
||||
int nextStateDelay;
|
||||
};
|
||||
|
||||
const MethodInfo stateMethods[]
|
||||
static const MethodInfo stateMethods[]
|
||||
= {{AZ_DRONE_STATE_DISCONNECTED, &AzDroneController::stateConnect, "stateConnect()", 1000},
|
||||
{AZ_DRONE_STATE_CONNECTED, &AzDroneController::stateAutopilot, "stateAutopilot()", 1000},
|
||||
{AZ_DRONE_STATE_AUTOPILOT, &AzDroneController::stateTelemetryModule, "stateTelemetryModule()", 1000},
|
||||
@@ -216,10 +216,10 @@ void AzDroneController::droneStateMachineSlot(void)
|
||||
{AZ_DRONE_STATE_TAKE_OFF, &AzDroneController::stateFlyMission, "stateFlyMission()", 1000},
|
||||
{AZ_DRONE_STATE_FLY_MISSION, nullptr, "No function to call. AzMissionControl running", 0}};
|
||||
|
||||
// Iterate through states. If state function fails, then it's tried again 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++) {
|
||||
if (stateMethods[i].currentState == mDroneState) {
|
||||
if ((int) mDroneState == (int) AZ_DRONE_STATE_FLY_MISSION) {
|
||||
if (mDroneState == AZ_DRONE_STATE_FLY_MISSION) {
|
||||
qDebug() << "AzMissionContoroller running. Waiting signals from it.";
|
||||
return;
|
||||
}
|
||||
@@ -228,10 +228,17 @@ void AzDroneController::droneStateMachineSlot(void)
|
||||
|
||||
if (result) {
|
||||
qDebug() << "AzDroneController::droneStateMachineSlot()" << stateMethods[i].description << "succeeded";
|
||||
qDebug() << "AzDroneController::droneStateMachineSlot() calling next state function in"
|
||||
<< stateMethods[i].nextStateDelay << "ms.";
|
||||
|
||||
mDroneState = stateMethods[i + 1].currentState;
|
||||
qDebug() << "AzDroneController::droneStateMachineSlot() New state:" << states[(int) mDroneState];
|
||||
|
||||
// Quadcopter needs to iterate all states - plane will skip arming and takeoff
|
||||
if (mDroneState == AZ_DRONE_STATE_READY_FOR_ARMING && QCoreApplication::arguments().contains("plane")) {
|
||||
mDroneState = AZ_DRONE_STATE_TAKE_OFF;
|
||||
qDebug() << "AzDroneController::droneStateMachineSlot() Skipping arming and takeoff for planes.";
|
||||
}
|
||||
else {
|
||||
qDebug() << "AzDroneController::droneStateMachineSlot() New state:" << states[(int) mDroneState];
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug() << "AzDroneController::droneStateMachineSlot()" << stateMethods[i].description
|
||||
@@ -247,6 +254,8 @@ void AzDroneController::droneStateMachineSlot(void)
|
||||
|
||||
void AzDroneController::newPositionSlot(Telemetry::Position position)
|
||||
{
|
||||
qDebug() << "AzDroneController::newPositionSlot()" << position.latitude_deg << position.longitude_deg;
|
||||
|
||||
// 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.
|
||||
if (mFirstPosition.relative_altitude_m < -1000) {
|
||||
|
||||
Reference in New Issue
Block a user