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

ROS 2 component that hosts a BehaviorModeExecutor and its owned mode on an in-process behavior tree executor node. More...

#include <auto_apms_px4/behavior_mode_executor.hpp>

Inheritance diagram for BehaviorModeExecutorNode:

Additional Inherited Members

- Public Types inherited from TreeExecutorBase
enum class  ExecutionState : uint8_t {
  IDLE , STARTING , RUNNING , PAUSED ,
  HALTED
}
 Enum representing possible behavior tree execution states. More...
 
enum class  ControlCommand : uint8_t { RUN , PAUSE , HALT , TERMINATE }
 Enum representing possible commands for controlling the behavior tree execution routine. More...
 
enum class  TreeExitBehavior : uint8_t { TERMINATE , RESTART }
 Enum representing possible options for what to do when a behavior tree is completed. More...
 
enum class  ExecutionResult : uint8_t { TREE_SUCCEEDED , TREE_FAILED , TERMINATED_PREMATURELY , ERROR }
 Enum representing possible behavior tree execution results. More...
 
- Public Member Functions inherited from GenericTreeExecutorNode
 GenericTreeExecutorNode (rclcpp::Node::SharedPtr node_ptr, Options options)
 Constructor using an existing ROS 2 node.
 
 GenericTreeExecutorNode (const std::string &name, Options options)
 Constructor which creates a new ROS 2 node.
 
 GenericTreeExecutorNode (const std::string &name)
 Constructor with default executor options.
 
std::shared_future< ExecutionResultstartExecution (const std::string &build_request, const std::string &entry_point="", const core::NodeManifest &node_manifest={})
 Start the behavior tree specified by a particular build request.
 
ExecutorParameters getExecutorParameters () const
 Get a copy of the current executor parameters.
 
std::map< std::string, rclcpp::ParameterValue > getParameterValuesWithPrefix (const std::string &prefix)
 Assemble all parameters of this node that have a specific prefix.
 
bool updateScriptingEnumsWithParameterValues (const std::map< std::string, rclcpp::ParameterValue > &value_map, bool simulate=false)
 Update the internal buffer of scripting enums.
 
bool updateGlobalBlackboardWithParameterValues (const std::map< std::string, rclcpp::ParameterValue > &value_map, bool simulate=false)
 Update the global blackboard using parameter values.
 
void loadBuildHandler (const std::string &name)
 Load a particular behavior tree build handler plugin.
 
TreeConstructor makeTreeConstructor (const std::string &build_request, const std::string &entry_point="", const core::NodeManifest &node_manifest={})
 Create a callback that builds a behavior tree according to a specific request.
 
core::TreeBuilder::SharedPtr createTreeBuilder ()
 Create a tree builder for building the behavior tree.
 
virtual bool clearGlobalBlackboard () override
 Reset the global blackboard and clear all entries.
 
std::shared_future< ExecutionResultstartExecution (TreeConstructor make_tree, double tick_rate_sec=0.1, int groot2_port=-1)
 Start a behavior tree that is built using a callback.
 
template<typename TimeRepT = int64_t, typename TimeT = std::milli>
std::shared_future< ExecutionResultstartExecution (TreeConstructor make_tree, const std::chrono::duration< TimeRepT, TimeT > &tick_rate, int groot2_port=-1)
 Start a behavior tree that is built using a callback.
 
std::shared_future< ExecutionResultstartExecution (std::unique_ptr< Tree > tree, double tick_rate_sec=0.1, int groot2_port=-1)
 Start executing a behavior tree that has already been created.
 
template<typename TimeRepT = int64_t, typename TimeT = std::milli>
std::shared_future< ExecutionResultstartExecution (std::unique_ptr< Tree > tree, const std::chrono::duration< TimeRepT, TimeT > &tick_rate, int groot2_port=-1)
 Start executing a behavior tree that has already been created.
 
- Public Member Functions inherited from TreeExecutorBase
 TreeExecutorBase (rclcpp::Node::SharedPtr node_ptr, rclcpp::CallbackGroup::SharedPtr tree_node_callback_group_ptr=nullptr)
 Constructor.
 
std::shared_future< ExecutionResultstartExecution (TreeConstructor make_tree, double tick_rate_sec=0.1, int groot2_port=-1)
 Start a behavior tree that is built using a callback.
 
template<typename TimeRepT = int64_t, typename TimeT = std::milli>
std::shared_future< ExecutionResultstartExecution (TreeConstructor make_tree, const std::chrono::duration< TimeRepT, TimeT > &tick_rate, int groot2_port=-1)
 Start a behavior tree that is built using a callback.
 
std::shared_future< ExecutionResultstartExecution (std::unique_ptr< Tree > tree, double tick_rate_sec=0.1, int groot2_port=-1)
 Start executing a behavior tree that has already been created.
 
template<typename TimeRepT = int64_t, typename TimeT = std::milli>
std::shared_future< ExecutionResultstartExecution (std::unique_ptr< Tree > tree, const std::chrono::duration< TimeRepT, TimeT > &tick_rate, int groot2_port=-1)
 Start executing a behavior tree that has already been created.
 
void setControlCommand (ControlCommand cmd)
 Set the command that handles the control flow of the execution routine.
 
bool isBusy ()
 Determine whether this executor is currently executing a behavior tree.
 
ExecutionState getExecutionState ()
 Get a status code indicating the current state of execution.
 
std::string getTreeName ()
 Get the name of the tree that is currently executing.
 
TreeBlackboardSharedPtr getGlobalBlackboardPtr ()
 Get a shared pointer to the global blackboard instance.
 
TreeStateObservergetStateObserver ()
 Get a reference to the current behavior tree state observer.
 
rclcpp::Node::SharedPtr getNodePtr ()
 Get a shared pointer to the parent ROS 2 node.
 
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_base_interface ()
 Get the node's base interface. Is required to be able to register derived classes as ROS2 components.
 
rclcpp::CallbackGroup::SharedPtr getTreeNodeWaitablesCallbackGroupPtr ()
 Get the callback group used for all waitables registered by behavior tree nodes.
 
rclcpp::executors::SingleThreadedExecutor::SharedPtr getTreeNodeWaitablesExecutorPtr ()
 Get the ROS 2 executor instance used for spinning waitables registered by behavior tree nodes.
 
- Static Public Member Functions inherited from GenericTreeExecutorNode
static std::string stripPrefixFromParameterName (const std::string &prefix, const std::string &param_name)
 Get the name of a parameter without its prefix.
 
- Static Public Attributes inherited from GenericTreeExecutorNode
static const std::string PARAM_VALUE_NO_BUILD_HANDLER = "none"
 Value indicating that no build handler is loaded.
 
- Protected Member Functions inherited from GenericTreeExecutorNode
virtual void preBuild (core::TreeBuilder &builder, const std::string &build_request, const std::string &entry_point, const core::NodeManifest &node_manifest, TreeBlackboard &bb)
 Callback invoked before building the behavior tree.
 
virtual void postBuild (Tree &tree)
 Callback invoked after the behavior tree has been instantiated.
 
- Protected Attributes inherited from TreeExecutorBase
rclcpp::Node::SharedPtr node_ptr_
 Shared pointer to the parent ROS 2 node.
 
const rclcpp::Logger logger_
 Logger associated with the parent ROS 2 node.
 

Detailed Description

ROS 2 component that hosts a BehaviorModeExecutor and its owned mode on an in-process behavior tree executor node.

Configuration is entirely parameter driven. Registration-time parameters are read once here in the constructor and are declared read only; the remaining parameters are dynamic and re-read on each activation, so they can be changed at runtime (e.g. via ros2 param set) and take effect the next time the executor is put in charge:

  • activation (string, read only): armed, always or immediately (see px4_ros2::ModeExecutorBase::Settings::Activation). Latched at mode registration.
  • mode_name (string, read only): Registered name of the owned PX4 mode. Latched at mode registration.
  • on_completion / on_failure (string, dynamic): Reaction after the behavior succeeds/fails (hold, rtl, land, disarm, complete, none).
  • defer_failsafes (bool, dynamic): Defer FMU failsafes while a behavior is running.
  • behavior.build_request / behavior.entry_point / behavior.node_manifest (dynamic): Which behavior to run.
  • build_handler (string), tick_rate (double), groot2_port (int): Standard behavior tree executor parameters consumed via inherited GenericTreeExecutorNode.

This node disables GenericTreeExecutorNode's strict unkown parameter removal via TreeExecutorNodeOptions so these behavior-specific parameters can coexist on the same node.

Registration with the FMU (a blocking operation) happens in the constructor and is delegated to a ModeRegistrationHandler. Unlike a plain mode registered via ModeRegistrationFactory, the owned mode is not announced on the registered_modes topic: a mode executor cannot be put in charge by another mode executor, so it is not a target for SendCmdSetNavState-based orchestration from a behavior tree. Mode executors instead serve as a mechanism to trigger automation from PX4 itself (RC switch, GCS, ActivateImmediately); native ROS 2 orchestration should activate modes directly.

Definition at line 192 of file behavior_mode_executor.hpp.


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