AutoAPMS
Streamlining behaviors in ROS 2
Loading...
Searching...
No Matches
executor_node.hpp
1// Copyright 2024 Robin Müller
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include "auto_apms_behavior_tree/executor/action_based_executor_node.hpp"
18#include "auto_apms_interfaces/action/start_tree_executor.hpp"
19
21{
22
58class TreeExecutorNode : public ActionBasedTreeExecutorNode<auto_apms_interfaces::action::StartTreeExecutor>
59{
60public:
68 TreeExecutorNode(const std::string & name, const std::string & start_action_name, Options options);
69
76 TreeExecutorNode(const std::string & name, Options options);
77
82 explicit TreeExecutorNode(rclcpp::NodeOptions ros_options);
83
84 virtual ~TreeExecutorNode() override = default;
85
86protected:
87 /* ActionBasedTreeExecutorNode overrides */
88
98 TreeConstructor getTreeConstructorFromGoal(std::shared_ptr<const TriggerGoal> goal_ptr) override;
99
109 bool shouldAcceptGoal(const rclcpp_action::GoalUUID & uuid, std::shared_ptr<const TriggerGoal> goal_ptr) override;
110
117 void onAcceptedGoal(std::shared_ptr<TriggerGoalHandle> goal_handle_ptr) override;
118
126 void onExecutionStarted(std::shared_ptr<TriggerGoalHandle> goal_handle_ptr) override;
127
135 void onGoalExecutionTermination(const ExecutionResult & result, TriggerActionContext & context) override;
136
137 bool afterTick() override;
138};
139
140} // namespace auto_apms_behavior_tree
ActionBasedTreeExecutorNode(const std::string &name, const std::string &action_name, Options options)
ExecutionResult
Enum representing possible behavior tree execution results.
TreeConstructor getTreeConstructorFromGoal(std::shared_ptr< const TriggerGoal > goal_ptr) override
Create a TreeConstructor from a StartTreeExecutor action goal.
void onExecutionStarted(std::shared_ptr< TriggerGoalHandle > goal_handle_ptr) override
Hook called after execution has been started successfully.
TreeExecutorNode(const std::string &name, const std::string &start_action_name, Options options)
Constructor allowing to specify a custom node name and executor options.
void onAcceptedGoal(std::shared_ptr< TriggerGoalHandle > goal_handle_ptr) override
Hook called after a start action goal has been accepted and before execution begins.
void onGoalExecutionTermination(const ExecutionResult &result, TriggerActionContext &context) override
Handle the execution result for the StartTreeExecutor action client.
bool shouldAcceptGoal(const rclcpp_action::GoalUUID &uuid, std::shared_ptr< const TriggerGoal > goal_ptr) override
Determine whether an incoming start action goal should be accepted.
Powerful tooling for incorporating behavior trees for task development.
Definition behavior.hpp:32