Common
common packages for kyubic
 
Loading...
Searching...
No Matches
lifecycle_manager.hpp
Go to the documentation of this file.
1
10#ifndef _LIFECYCLE_MANAGER_HPP
11#define _LIFECYCLE_MANAGER_HPP
12
13#include <behaviortree_cpp/action_node.h>
14
15#include <lifecycle_msgs/srv/change_state.hpp>
16#include <rclcpp/rclcpp.hpp>
17#include <std_msgs/msg/string.hpp>
18
19namespace behavior_tree
20{
21
27class LifecycleManager : public BT::StatefulActionNode
28{
29public:
37 const std::string & name, const BT::NodeConfig & config,
38 rclcpp::Publisher<std_msgs::msg::String>::SharedPtr logger_pub,
39 rclcpp::Node::SharedPtr ros_node);
40
45 static BT::PortsList providedPorts();
46
51 BT::NodeStatus onStart() override;
52
57 BT::NodeStatus onRunning() override;
58
62 void onHalted() override;
63
64private:
65 rclcpp::Node::SharedPtr ros_node_;
66 rclcpp::Publisher<std_msgs::msg::String>::SharedPtr logger_pub_;
67 rclcpp::Client<lifecycle_msgs::srv::ChangeState>::SharedPtr change_state_client_;
68
69 std::shared_future<lifecycle_msgs::srv::ChangeState::Response::SharedPtr> future_response_;
70
71 std::string last_service_name_;
72 std::map<std::string, uint8_t> transition_map_;
73};
74
75} // namespace behavior_tree
76
77#endif
ROS 2 Lifecycle Node Management Action for BehaviorTree.CPP.
Definition: lifecycle_manager.hpp:28
BT::NodeStatus onStart() override
Called first when the node is ticked (starts async operation)
Definition: lifecycle_manager.cpp:41
void onHalted() override
Called when the node is halted.
Definition: lifecycle_manager.cpp:128
BT::NodeStatus onRunning() override
Called continuously after onStart() until async operation completes.
Definition: lifecycle_manager.cpp:102
static BT::PortsList providedPorts()
Defines the ports used by this node.
Definition: lifecycle_manager.cpp:33