PX4 ROS 2 Interface Library
Library to interface with PX4 from a companion computer using ROS 2
|
Handler passed to custom actions to run modes, actions and trajectories. More...
#include <px4_ros2/mission/mission_executor.hpp>
Public Member Functions | |
ActionHandler (MissionExecutor &mission_executor) | |
void | runMode (ModeBase::ModeID mode_id, const std::function< void()> &on_completed, const std::function< void()> &on_failure=nullptr) |
void | runAction (const std::string &action_name, const ActionArguments &arguments, const std::function< void()> &on_completed) |
void | runTrajectory (const std::shared_ptr< Mission > &trajectory, const std::function< void()> &on_completed, bool stop_at_last_item=true) |
TrajectoryOptions | getTrajectoryOptions () const |
get the current trajectory config options | |
void | clearTrajectoryOptions () |
Reset the current trajectory config options to the mission defaults. | |
void | setTrajectoryOptions (const TrajectoryOptions &options) |
Override the trajectory config options. More... | |
std::optional< int > | getCurrentMissionIndex () const |
void | setCurrentMissionIndex (int index) |
Set the current mission index. More... | |
bool | currentActionSupportsResumeFromLanded () const |
std::unique_ptr< ActionStateKeeper > | storeState (const std::string &action_name, const ActionArguments &arguments) |
store the state of a continuous action More... | |
const Mission & | mission () const |
bool | deferFailsafes (bool enabled, int timeout_s=0) |
enable/disable deferral of failsafes More... | |
void | onFailsafeDeferred (const std::function< void()> &callback) |
register callback for failsafe notification More... | |
bool | isValid () const |
Check if the handler is still valid. More... | |
Friends | |
class | MissionExecutor |
Handler passed to custom actions to run modes, actions and trajectories.
|
inline |
enable/disable deferral of failsafes
enabled | |
timeout_s | 0=system default, -1=no timeout |
|
inline |
Check if the handler is still valid.
If the handler is invalid, it cannot be used anymore. It will be set invalid when the mission is aborted, or deactivated. This is useful for actions that use timers to run actions.
|
inline |
register callback for failsafe notification
The callback is triggerd when a failsafe occurs while deferral is enabled.
void px4_ros2::ActionHandler::setCurrentMissionIndex | ( | int | index | ) |
Set the current mission index.
This is primarily for the onResume action, in case the mission should be resumed at a different index.
When called as part of another action, the index will still be increased, and thus continue at the next item.
|
inline |
Override the trajectory config options.
The values that are not set will be kept as they were before
|
inline |
store the state of a continuous action
This is used to restore the state when the mission is interrupted (e.g. by the user or a failsafe) and continued later on. When restoring, the action will be called with the provided arguments.
This can be used for example, for a camera trigger command that continuous to run in the background.
action_name | Name of the calling action |
arguments | Arguments to the action for restoring the action |