10 for (
int i = 0; i < static_cast<int>(FlightTaskIndex::Count); i++) {
11 _initTask(static_cast<FlightTaskIndex>(i));
93 if (static_cast<int>(FlightTaskIndex::None) <= new_task_index &&
94 static_cast<int>(FlightTaskIndex::Count) > new_task_index) {
95 return switchTask(FlightTaskIndex(new_task_index));
112 if (static_cast<FlightTaskError>(e.error) == error) {
117 return "This error is not mapped to a string or is unknown.";
143 if (desired_task == FlightTaskIndex::None) {
150 uint8_t cmd_result = vehicle_command_ack_s::VEHICLE_RESULT_FAILED;
154 cmd_result = vehicle_command_ack_s::VEHICLE_RESULT_ACCEPTED;
158 cmd_result = vehicle_command_ack_s::VEHICLE_RESULT_DENIED;
163 cmd_result = vehicle_command_ack_s::VEHICLE_RESULT_FAILED;
171 command_ack.command =
command.command;
172 command_ack.result = cmd_result;
173 command_ack.result_param1 =
static_cast<int>(switch_result);
174 command_ack.target_system =
command.source_system;
175 command_ack.target_component =
command.source_component;
static const vehicle_local_position_setpoint_s empty_setpoint
Empty setpoint.
void handleParameterUpdate()
Call this whenever a parameter update notification is received (parameter_update uORB message) ...
const landing_gear_s & getGear()
Get landing gear position.
virtual bool activate(vehicle_local_position_setpoint_s last_setpoint)
Call once on the event where you switch to the task.
const vehicle_local_position_setpoint_s getPositionSetpoint()
Get the output data from the current task.
static const landing_gear_s empty_landing_gear_default_keep
default landing gear state
task_error_t _taskError[_numError]
Map from Error int to user friendly string.
virtual ~FlightTask()=default
const vehicle_constraints_s getConstraints()
Get task dependent constraints.
uORB::PublicationQueued< vehicle_command_ack_s > _pub_vehicle_command_ack
bool publish(const T &data)
Publish the struct.
int _initTask(FlightTaskIndex task_index)
bool update()
Call regularly in the control loop cycle to execute the task.
virtual bool update()=0
To be called regularly in the control loop cycle to execute the task.
FlightTaskIndex switchVehicleCommand(const int command)
const vehicle_constraints_s & getConstraints()
Get vehicle constraints.
virtual bool updateFinalize()
Call after update() to constrain the generated setpoints in order to comply with the constraints of t...
void reActivate()
This method will re-activate current task.
virtual bool updateInitialize()
Call before activate() or update() to initialize time and input data.
bool isAnyTaskActive() const
Check if any task is active.
virtual void reActivate()
Call this to reset an active Flight Task.
void _updateCommand()
Check for vehicle commands (received via MAVLink), evaluate and acknowledge them. ...
bool updated()
Check if there is a new update.
flight_task_t _current_task
virtual bool applyCommandParameters(const vehicle_command_s &command)
To be called to adopt parameters from an arrived vehicle command.
const vehicle_local_position_setpoint_s getPositionSetpoint()
Get the output data.
void handleParameterUpdate()
Call this whenever a parameter update notification is received (parameter_update uORB message) ...
FlightTaskError switchTask()
Switch to the next task in the available list (for testing)
uORB::Subscription _sub_vehicle_command
topic handle on which commands are received
const char * errorToString(const FlightTaskError error)
Call this method to get the description of a task error.
const landing_gear_s getGear()
Get landing gear position.
static const vehicle_constraints_s empty_constraints
Empty constraints.
bool copy(void *dst)
Copy the struct.
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).