21#include "auto_apms_behavior_tree/executor/generic_executor_node.hpp"
22#include "auto_apms_px4/mode_registration.hpp"
23#include "px4_ros2/components/mode.hpp"
24#include "px4_ros2/components/mode_executor.hpp"
25#include "px4_ros2/control/setpoint_types/direct_actuators.hpp"
26#include "rclcpp/rclcpp.hpp"
57class BehaviorOwnedMode :
public px4_ros2::ModeBase
60 BehaviorOwnedMode(rclcpp::Node & node,
const px4_ros2::ModeBase::Settings & settings);
62 void onActivate()
override {}
63 void onDeactivate()
override {}
64 void updateSetpoint(
float dt_s)
override;
70 void finish(px4_ros2::Result result) { completed(result); }
73 std::shared_ptr<px4_ros2::DirectActuatorsSetpointType> actuator_setpoint_ptr_;
111 bool defer_failsafes{
false};
124 BehaviorOwnedMode & owned_mode,
const px4_ros2::ModeExecutorBase::Settings & settings,
125 std::function<Config()> config_provider, auto_apms_behavior_tree::GenericTreeExecutorNode & engine);
127 void onActivate()
override;
128 void onDeactivate(DeactivateReason reason)
override;
155 void scheduleLoiter();
157 rclcpp::Node & node_;
158 BehaviorOwnedMode & owned_mode_;
159 auto_apms_behavior_tree::GenericTreeExecutorNode & behavior_executor_;
160 std::function<Config()> config_provider_;
195 explicit BehaviorModeExecutorNode(
const rclcpp::NodeOptions & options);
201 static px4_ros2::ModeExecutorBase::Settings::Activation activationFromString(
const std::string & str);
203 std::unique_ptr<BehaviorOwnedMode> owned_mode_ptr_;
204 std::unique_ptr<BehaviorModeExecutor> executor_ptr_;
Flexible and configurable ROS 2 behavior tree executor node.
ExecutionResult
Enum representing possible behavior tree execution results.
static CompletionReaction reactionFromString(const std::string &str)
Parse a string into a CompletionReaction.
CompletionReaction
Reaction performed when a behavior terminates or fails, using the in-charge executor API.
@ HOLD
Schedule the owned mode (hold position) and stay in charge.
@ DISARM
Disarm the vehicle.
@ COMPLETE
Report the owned mode as completed to the FMU (relinquish charge).
@ LAND
Land at the current position.
@ NONE
Do nothing and stay in charge.
void onExecutionResult(ExecutionResult result)
Handle the termination of the behavior running on the in-process executor.
BehaviorModeExecutor(BehaviorOwnedMode &owned_mode, const px4_ros2::ModeExecutorBase::Settings &settings, std::function< Config()> config_provider, auto_apms_behavior_tree::GenericTreeExecutorNode &engine)
Constructor.
void finish(px4_ros2::Result result)
Report completion of the mode to the FMU. Only takes effect while the mode is active.
Handles the registration of a PX4 mode with the FMU and announces its dynamically assigned nav_state.
Implementation of PX4 mode peers offered by px4_ros2_cpp enabling integration with AutoAPMS.
Which behavior to run and how to build it.
std::string entry_point
Single point of entry for behavior execution.
std::string build_request
Behavior build request (e.g. a registered behavior resource identity or XML).
std::string node_manifest
Encoded node manifest specifying additional nodes to load.