File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 2525
2626#include  " behaviortree_cpp/loggers/groot2_publisher.h" 
2727
28+ #include  " btcpp_ros2_interfaces/srv/get_trees.hpp" 
29+ 
2830//  generated file
2931#include  " bt_executor_parameters.hpp" 
3032namespace 
@@ -35,6 +37,8 @@ static const auto kLogger = rclcpp::get_logger("bt_action_server");
3537namespace  BT 
3638{
3739
40+ using  GetTrees = btcpp_ros2_interfaces::srv::GetTrees;
41+ 
3842struct  TreeExecutionServer ::Pimpl
3943{
4044  rclcpp_action::Server<ExecuteTree>::SharedPtr action_server;
@@ -43,6 +47,8 @@ struct TreeExecutionServer::Pimpl
4347  std::shared_ptr<bt_server::ParamListener> param_listener;
4448  bt_server::Params params;
4549
50+   rclcpp::Service<GetTrees>::SharedPtr get_trees_service;
51+ 
4652  BT::BehaviorTreeFactory factory;
4753  std::shared_ptr<BT::Groot2Publisher> groot_publisher;
4854
@@ -88,6 +94,13 @@ TreeExecutionServer::TreeExecutionServer(const rclcpp::Node::SharedPtr& node)
8894    p_->single_shot_timer ->cancel ();
8995  };
9096
97+   p_->get_trees_service  = node_->create_service <GetTrees>(
98+       " get_loaded_trees" 
99+       [this ](const  std::shared_ptr<GetTrees::Request> _,
100+              std::shared_ptr<GetTrees::Response> response) {
101+         response->tree_ids  = p_->factory .registeredBehaviorTrees ();
102+       });
103+ 
91104  p_->single_shot_timer  =
92105      node_->create_wall_timer (std::chrono::milliseconds (1 ), callback);
93106}
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ find_package(rosidl_default_generators REQUIRED)
99
1010rosidl_generate_interfaces(btcpp_ros2_interfaces
1111    "msg/NodeStatus.msg" 
12+     "srv/GetTrees.srv" 
1213    "action/ExecuteTree.action" 
1314    "action/Sleep.action" )
1415
Original file line number Diff line number Diff line change 1+ #### Request #### 
2+ # Empty 
3+ 
4+ --- 
5+ #### Result #### 
6+ 
7+ # Ids of the available trees 
8+ string tree_ids 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments