AutoAPMS
Streamlining behaviors in ROS 2
Loading...
Searching...
No Matches
BehaviorModeExecutor Class Reference

PX4 mode executor that runs an AutoAPMS behavior in-process when put in charge by the FMU. More...

#include <auto_apms_px4/behavior_mode_executor.hpp>

Public Types

enum class  CompletionReaction {
  HOLD , RTL , LAND , DISARM ,
  COMPLETE , NONE
}
 Reaction performed when a behavior terminates or fails, using the in-charge executor API. More...
 

Public Member Functions

 BehaviorModeExecutor (BehaviorOwnedMode &owned_mode, const px4_ros2::ModeExecutorBase::Settings &settings, std::function< Config()> config_provider, auto_apms_behavior_tree::GenericTreeExecutorNode &engine)
 Constructor.
 
void onExecutionResult (ExecutionResult result)
 Handle the termination of the behavior running on the in-process executor.
 

Static Public Member Functions

static CompletionReaction reactionFromString (const std::string &str)
 Parse a string into a CompletionReaction.
 

Detailed Description

PX4 mode executor that runs an AutoAPMS behavior in-process when put in charge by the FMU.

When the owned mode is selected (RC switch, GCS or ActivateImmediately), PX4 puts this executor in charge and onActivate() starts the configured behavior on the in-process behavior tree executor (engine). A pilot override or failsafe triggers onDeactivate(), which halts the behavior. When the behavior finishes, a configurable in-charge reaction (hold/RTL/land/disarm/complete/none) is performed.

The behavior itself is built from standard AutoAPMS nodes and drives the vehicle through the regular PX4 skills. Before starting, the executor publishes its VehicleCommand source component on the global blackboard (under the key configured via the AUTO_APMS_PX4_SOURCE_COMPONENT_GLOBAL_KEY compile definition) so that ownership-aware nodes (e.g. SendCmdSetNavState) can attribute their commands to the executor.

Definition at line 90 of file behavior_mode_executor.hpp.

Member Enumeration Documentation

◆ CompletionReaction

enum class CompletionReaction
strong

Reaction performed when a behavior terminates or fails, using the in-charge executor API.

Enumerator
HOLD 

Schedule the owned mode (hold position) and stay in charge.

RTL 

Return to launch.

LAND 

Land at the current position.

DISARM 

Disarm the vehicle.

COMPLETE 

Report the owned mode as completed to the FMU (relinquish charge).

NONE 

Do nothing and stay in charge.

Definition at line 96 of file behavior_mode_executor.hpp.

Constructor & Destructor Documentation

◆ BehaviorModeExecutor()

BehaviorModeExecutor ( BehaviorOwnedMode & owned_mode,
const px4_ros2::ModeExecutorBase::Settings & settings,
std::function< Config()> config_provider,
auto_apms_behavior_tree::GenericTreeExecutorNode & engine )

Constructor.

Parameters
owned_modePlaceholder mode owned by this executor.
settingsPX4 mode executor settings (activation policy).
config_providerCallable returning the current Config. It is invoked once here and again at the start of every activation so runtime parameter changes take effect on the next run (see onActivate). It must stay valid for the lifetime of this executor and is expected to keep any underlying parameter listener alive.
engineIn-process behavior tree executor used to run the behavior.

Definition at line 50 of file behavior_mode_executor.cpp.

Member Function Documentation

◆ reactionFromString()

BehaviorModeExecutor::CompletionReaction reactionFromString ( const std::string & str)
static

Parse a string into a CompletionReaction.

Exceptions
std::invalid_argumentif the value is not a valid reaction.

Definition at line 77 of file behavior_mode_executor.cpp.

◆ onExecutionResult()

void onExecutionResult ( ExecutionResult result)

Handle the termination of the behavior running on the in-process executor.

Translates the tree execution result into a px4_ros2::Result and performs the configured completion reaction. Intended to be called from the owning node's TreeExecutorBase::onTermination override.

Parameters
resultFinal result of the tree execution.

Definition at line 62 of file behavior_mode_executor.cpp.


The documentation for this class was generated from the following files: