mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-03 10:10:34 +08:00
FlightTasks: generate tasks depending on target
- rename flight tasks to use camelCase - add core tasks to flight tasks cmake - add additional tasks in targets (TODO) - add templates - generate hpp and cpp which contain all specified tasks
This commit is contained in:
committed by
Dennis Mannhart
parent
34203f7e8c
commit
8090708f76
@@ -47,73 +47,6 @@ const vehicle_constraints_s FlightTasks::getConstraints()
|
||||
}
|
||||
}
|
||||
|
||||
int FlightTasks::_initTask(FlightTaskIndex task_index)
|
||||
{
|
||||
|
||||
// disable the old task if there is any
|
||||
if (_current_task.task) {
|
||||
_current_task.task->~FlightTask();
|
||||
_current_task.task = nullptr;
|
||||
_current_task.index = FlightTaskIndex::None;
|
||||
}
|
||||
|
||||
switch (task_index) {
|
||||
case FlightTaskIndex::None:
|
||||
// already disabled task
|
||||
break;
|
||||
|
||||
case FlightTaskIndex::Stabilized:
|
||||
_current_task.task = new (&_task_union.stabilized) FlightTaskManualStabilized();
|
||||
break;
|
||||
|
||||
case FlightTaskIndex::Altitude:
|
||||
_current_task.task = new (&_task_union.altitude) FlightTaskManualAltitude();
|
||||
break;
|
||||
|
||||
case FlightTaskIndex::AltitudeSmooth:
|
||||
_current_task.task = new (&_task_union.altitude_smooth) FlightTaskManualAltitudeSmooth();
|
||||
break;
|
||||
|
||||
case FlightTaskIndex::Position:
|
||||
_current_task.task = new (&_task_union.position) FlightTaskManualPosition();
|
||||
break;
|
||||
|
||||
case FlightTaskIndex::PositionSmooth:
|
||||
_current_task.task =
|
||||
new (&_task_union.position_smooth) FlightTaskManualPositionSmooth();
|
||||
break;
|
||||
|
||||
case FlightTaskIndex::Orbit:
|
||||
_current_task.task = new (&_task_union.orbit) FlightTaskOrbit();
|
||||
break;
|
||||
|
||||
case FlightTaskIndex::Sport:
|
||||
_current_task.task = new (&_task_union.sport) FlightTaskSport();
|
||||
break;
|
||||
|
||||
case FlightTaskIndex::AutoLine:
|
||||
_current_task.task = new (&_task_union.autoLine) FlightTaskAutoLine();
|
||||
break;
|
||||
|
||||
case FlightTaskIndex::AutoFollowMe:
|
||||
_current_task.task =
|
||||
new (&_task_union.autoFollowMe) FlightTaskAutoFollowMe();
|
||||
break;
|
||||
|
||||
case FlightTaskIndex::Offboard:
|
||||
_current_task.task = new (&_task_union.offboard) FlightTaskOffboard();
|
||||
break;
|
||||
|
||||
default:
|
||||
// invalid task
|
||||
return 1;
|
||||
}
|
||||
|
||||
// task construction succeeded
|
||||
_current_task.index = task_index;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FlightTasks::switchTask(FlightTaskIndex new_task_index)
|
||||
{
|
||||
// switch to the running task, nothing to do
|
||||
@@ -202,15 +135,11 @@ void FlightTasks::_updateCommand()
|
||||
orb_copy(ORB_ID(vehicle_command), _sub_vehicle_command, &command);
|
||||
|
||||
// check what command it is
|
||||
FlightTaskIndex desired_task = FlightTaskIndex::None;
|
||||
FlightTaskIndex desired_task = switchVehicleCommand(command.command);
|
||||
|
||||
switch (command.command) {
|
||||
case vehicle_command_s::VEHICLE_CMD_DO_ORBIT :
|
||||
desired_task = FlightTaskIndex::Orbit;
|
||||
break;
|
||||
|
||||
// ignore all unkown commands
|
||||
default : return;
|
||||
if (desired_task == FlightTaskIndex::None) {
|
||||
// ignore all unkown commands
|
||||
return;
|
||||
}
|
||||
|
||||
// switch to the commanded task
|
||||
@@ -227,7 +156,7 @@ void FlightTasks::_updateCommand()
|
||||
|
||||
// if we just switched and parameters are not accepted, go to failsafe
|
||||
if (switch_result == 1) {
|
||||
switchTask(FlightTaskIndex::Position);
|
||||
switchTask(FlightTaskIndex::ManualPosition);
|
||||
cmd_result = vehicle_command_ack_s::VEHICLE_RESULT_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user