Common
common packages for kyubic
 
Loading...
Searching...
No Matches
behavior_tree::RosActionNode< ActionT > Class Template Referenceabstract

Template for ROS2 Action with Behavior Tree. More...

#include <ros_action_node.hpp>

+ Inheritance diagram for behavior_tree::RosActionNode< ActionT >:
+ Collaboration diagram for behavior_tree::RosActionNode< ActionT >:

Public Types

using Action = ActionT
 
using GoalHandle = rclcpp_action::ClientGoalHandle< Action >
 
using ActionClient = rclcpp_action::Client< Action >
 
using WrappedResult = typename rclcpp_action::ClientGoalHandle< Action >::WrappedResult
 
using Feedback = typename Action::Feedback
 

Public Member Functions

 RosActionNode (const std::string &name, const BT::NodeConfig &config, rclcpp::Node::SharedPtr ros_node)
 Create action client.
 
virtual bool setGoal (typename Action::Goal &goal)=0
 Configures the Goal message.
 
virtual BT::NodeStatus onResult (const WrappedResult &wr)=0
 Processes the final result received from the server.
 
virtual void onFeedback (const std::shared_ptr< const Feedback > feedback)
 Behavior when recieving feadback.
 
BT::NodeStatus onStart () override
 Called when the node is first ticked. Initiates the ROS 2 action.
 
BT::NodeStatus onRunning () override
 This method manages the asynchronous state machine:
 
void onHalted () override
 Cancels the currently active goal if one exists.
 

Protected Attributes

rclcpp::Node::SharedPtr ros_node_
 
ActionClient::SharedPtr client_
 
std::string action_name
 
std::shared_future< typename GoalHandle::SharedPtr > future_goal_handle_
 
std::shared_future< WrappedResultfuture_result_
 
GoalHandle::SharedPtr active_goal_handle_
 

Detailed Description

template<class ActionT>
class behavior_tree::RosActionNode< ActionT >

Template for ROS2 Action with Behavior Tree.

Template Parameters
ActionTAction Type

behaviortree_ros2パッケージが動かなかったので,自作

Member Typedef Documentation

◆ Action

template<class ActionT >
using behavior_tree::RosActionNode< ActionT >::Action = ActionT

◆ ActionClient

template<class ActionT >
using behavior_tree::RosActionNode< ActionT >::ActionClient = rclcpp_action::Client<Action>

◆ Feedback

template<class ActionT >
using behavior_tree::RosActionNode< ActionT >::Feedback = typename Action::Feedback

◆ GoalHandle

template<class ActionT >
using behavior_tree::RosActionNode< ActionT >::GoalHandle = rclcpp_action::ClientGoalHandle<Action>

◆ WrappedResult

template<class ActionT >
using behavior_tree::RosActionNode< ActionT >::WrappedResult = typename rclcpp_action::ClientGoalHandle<Action>::WrappedResult

Constructor & Destructor Documentation

◆ RosActionNode()

template<class ActionT >
behavior_tree::RosActionNode< ActionT >::RosActionNode ( const std::string &  name,
const BT::NodeConfig &  config,
rclcpp::Node::SharedPtr  ros_node 
)

Create action client.

Parameters
nameNode name
configNode config
ros_nodepointer of ros node

Get action_name from xml, and then create action client

Member Function Documentation

◆ onFeedback()

template<class ActionT >
void behavior_tree::RosActionNode< ActionT >::onFeedback ( const std::shared_ptr< const Feedback feedback)
virtual

Behavior when recieving feadback.

◆ onHalted()

template<class ActionT >
void behavior_tree::RosActionNode< ActionT >::onHalted
override

Cancels the currently active goal if one exists.

◆ onResult()

template<class ActionT >
virtual BT::NodeStatus behavior_tree::RosActionNode< ActionT >::onResult ( const WrappedResult wr)
pure virtual

Processes the final result received from the server.

Parameters
wrThe wrapped result containing the result code and data
Returns
BT::NodeStatus (typically SUCCESS or FAILURE)

◆ onRunning()

template<class ActionT >
BT::NodeStatus behavior_tree::RosActionNode< ActionT >::onRunning
override

This method manages the asynchronous state machine:

Returns
BT::NodeStatus::RUNNING while waiting for the server. Returns the result of onResult() once the action completes.
  1. Checks if the goal was accepted by the server.

Checks if the result has been received.

◆ onStart()

template<class ActionT >
BT::NodeStatus behavior_tree::RosActionNode< ActionT >::onStart
override

Called when the node is first ticked. Initiates the ROS 2 action.

Returns
BT::NodeStatus::RUNNING if the goal is sent successfully, BT::NodeStatus::FAILURE if the server is missing or goal setting fails.

Checks server availability, configures the goal using the derived class's setGoal, and sends the goal asynchronously.

◆ setGoal()

template<class ActionT >
virtual bool behavior_tree::RosActionNode< ActionT >::setGoal ( typename Action::Goal &  goal)
pure virtual

Configures the Goal message.

Parameters
goalThe Goal object to be sent to the server
Returns
true if the goal was set successfully, false otherwise (triggers FAILURE)

Implemented in behavior_tree::FindPingerAction, behavior_tree::QrAction, behavior_tree::FibonacciAction, and behavior_tree::WaypointAction.

Member Data Documentation

◆ action_name

template<class ActionT >
std::string behavior_tree::RosActionNode< ActionT >::action_name
protected

◆ active_goal_handle_

template<class ActionT >
GoalHandle::SharedPtr behavior_tree::RosActionNode< ActionT >::active_goal_handle_
protected

◆ client_

template<class ActionT >
ActionClient::SharedPtr behavior_tree::RosActionNode< ActionT >::client_
protected

◆ future_goal_handle_

template<class ActionT >
std::shared_future<typename GoalHandle::SharedPtr> behavior_tree::RosActionNode< ActionT >::future_goal_handle_
protected

◆ future_result_

template<class ActionT >
std::shared_future<WrappedResult> behavior_tree::RosActionNode< ActionT >::future_result_
protected

◆ ros_node_

template<class ActionT >
rclcpp::Node::SharedPtr behavior_tree::RosActionNode< ActionT >::ros_node_
protected

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