From 1f5d948fdda2df5f5f5f64a6d1fcba80a64732b5 Mon Sep 17 00:00:00 2001 From: Xenofon Karamanos Date: Thu, 1 Jun 2023 13:28:12 +0000 Subject: [PATCH] Usage with BT V3 --- CMakeLists.txt | 4 ++-- include/ros2_behavior_tree_example/bt_ros_node.hpp | 4 ++-- .../plugins/log_status_bt_node.hpp | 4 ++-- .../ros2_behavior_tree_example/plugins/ping_bt_node.hpp | 4 ++-- .../plugins/pong_received_bt_node.hpp | 4 ++-- .../plugins/pong_received_executor_bt_node.hpp | 4 ++-- package.xml | 7 ++++--- src/bt_ros_node.cpp | 4 ++-- src/plugins/log_status_bt_node.cpp | 2 +- src/plugins/ping_bt_node.cpp | 2 +- src/plugins/pong_received_bt_node.cpp | 2 +- src/plugins/pong_received_executor_bt_node.cpp | 2 +- 12 files changed, 22 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7abf45b..600a354 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ endif() # find dependencies find_package(ament_cmake REQUIRED) -find_package(behaviortree_cpp REQUIRED) +find_package(behaviortree_cpp_v3 REQUIRED) find_package(rclcpp REQUIRED) find_package(rclcpp_action REQUIRED) find_package(rclcpp_lifecycle REQUIRED) @@ -41,7 +41,7 @@ set(dependencies nav2_msgs std_srvs tf2_ros - behaviortree_cpp + behaviortree_cpp_v3 ) set(executable_name behavior_tree_example) diff --git a/include/ros2_behavior_tree_example/bt_ros_node.hpp b/include/ros2_behavior_tree_example/bt_ros_node.hpp index 39e1c3b..74d1682 100644 --- a/include/ros2_behavior_tree_example/bt_ros_node.hpp +++ b/include/ros2_behavior_tree_example/bt_ros_node.hpp @@ -6,8 +6,8 @@ #include "rclcpp_lifecycle/lifecycle_node.hpp" #include "rclcpp_lifecycle/lifecycle_publisher.hpp" -#include "behaviortree_cpp/behavior_tree.h" -#include "behaviortree_cpp/bt_factory.h" +#include "behaviortree_cpp_v3/behavior_tree.h" +#include "behaviortree_cpp_v3/bt_factory.h" namespace polymath { diff --git a/include/ros2_behavior_tree_example/plugins/log_status_bt_node.hpp b/include/ros2_behavior_tree_example/plugins/log_status_bt_node.hpp index c65e75a..d71efb1 100644 --- a/include/ros2_behavior_tree_example/plugins/log_status_bt_node.hpp +++ b/include/ros2_behavior_tree_example/plugins/log_status_bt_node.hpp @@ -2,7 +2,7 @@ #define LOG_STATUS_BT_NODE_H_ #include -#include "behaviortree_cpp/behavior_tree.h" +#include "behaviortree_cpp_v3/behavior_tree.h" #include "rclcpp/rclcpp.hpp" #include "rclcpp_lifecycle/lifecycle_node.hpp" #include "std_msgs/msg/int32.hpp" @@ -23,7 +23,7 @@ namespace bt_ros_example /// @param action_name Name for the XML tag for this node /// @param conf BT Node Configuration /// - LogStatusNode(const std::string & action_name, const BT::NodeConfig & conf); + LogStatusNode(const std::string & action_name, const BT::NodeConfiguration & conf); ~LogStatusNode(); diff --git a/include/ros2_behavior_tree_example/plugins/ping_bt_node.hpp b/include/ros2_behavior_tree_example/plugins/ping_bt_node.hpp index 6d37dce..423cd25 100644 --- a/include/ros2_behavior_tree_example/plugins/ping_bt_node.hpp +++ b/include/ros2_behavior_tree_example/plugins/ping_bt_node.hpp @@ -1,7 +1,7 @@ #ifndef PING_BT_NODE_H_ #define PING_BT_NODE_H_ -#include "behaviortree_cpp/behavior_tree.h" +#include "behaviortree_cpp_v3/behavior_tree.h" #include "rclcpp/rclcpp.hpp" #include "rclcpp_lifecycle/lifecycle_node.hpp" #include "std_msgs/msg/int32.hpp" @@ -23,7 +23,7 @@ namespace bt_ros_example /// @param action_name Name for the XML tag for this node /// @param conf BT Node Configuration /// - PingNode(const std::string & action_name, const BT::NodeConfig & conf); + PingNode(const std::string & action_name, const BT::NodeConfiguration & conf); ~PingNode(); /// diff --git a/include/ros2_behavior_tree_example/plugins/pong_received_bt_node.hpp b/include/ros2_behavior_tree_example/plugins/pong_received_bt_node.hpp index e37f977..e4470ff 100644 --- a/include/ros2_behavior_tree_example/plugins/pong_received_bt_node.hpp +++ b/include/ros2_behavior_tree_example/plugins/pong_received_bt_node.hpp @@ -1,7 +1,7 @@ #ifndef PONG_RECEIVED_NODE_H_ #define PONG_RECEIVED_NODE_H_ -#include "behaviortree_cpp/behavior_tree.h" +#include "behaviortree_cpp_v3/behavior_tree.h" #include "rclcpp/rclcpp.hpp" #include "rclcpp_lifecycle/lifecycle_node.hpp" #include "std_msgs/msg/int32.hpp" @@ -22,7 +22,7 @@ namespace bt_ros_example /// @param condition_name Name for the XML tag for this node /// @param conf BT Node Configuration /// - PongReceivedNode(const std::string & condition_name, const BT::NodeConfig & conf); + PongReceivedNode(const std::string & condition_name, const BT::NodeConfiguration & conf); PongReceivedNode() = delete; ~PongReceivedNode(); diff --git a/include/ros2_behavior_tree_example/plugins/pong_received_executor_bt_node.hpp b/include/ros2_behavior_tree_example/plugins/pong_received_executor_bt_node.hpp index d1b1231..de6593a 100644 --- a/include/ros2_behavior_tree_example/plugins/pong_received_executor_bt_node.hpp +++ b/include/ros2_behavior_tree_example/plugins/pong_received_executor_bt_node.hpp @@ -1,7 +1,7 @@ #ifndef PONG_RECEIVED_EXECUTOR_NODE_ #define PONG_RECEIVED_EXECUTOR_NODE_ -#include "behaviortree_cpp/behavior_tree.h" +#include "behaviortree_cpp_v3/behavior_tree.h" #include "rclcpp/rclcpp.hpp" #include "rclcpp_lifecycle/lifecycle_node.hpp" #include "std_msgs/msg/int32.hpp" @@ -22,7 +22,7 @@ namespace bt_ros_example /// @param condition_name Name for the XML tag for this node /// @param conf BT Node Configuration /// - PongReceivedExecutorNode(const std::string & condition_name, const BT::NodeConfig & conf); + PongReceivedExecutorNode(const std::string & condition_name, const BT::NodeConfiguration & conf); PongReceivedExecutorNode() = delete; ~PongReceivedExecutorNode(); diff --git a/package.xml b/package.xml index 67f58ad..b54cd19 100644 --- a/package.xml +++ b/package.xml @@ -11,15 +11,16 @@ ament_cmake ament_cmake - behaviortree_cpp + behaviortree_cpp_v3 rclcpp rclcpp_action rclcpp_lifecycle rclcpp_components std_msgs lifecycle_msgs - - behaviortree_cpp + nav2_msgs + + behaviortree_cpp_v3 rclcpp rclcpp_action rclcpp_lifecycle diff --git a/src/bt_ros_node.cpp b/src/bt_ros_node.cpp index e09155a..c7038d9 100644 --- a/src/bt_ros_node.cpp +++ b/src/bt_ros_node.cpp @@ -6,7 +6,7 @@ #include "ros2_behavior_tree_example/plugins/ping_bt_node.hpp" #include "ros2_behavior_tree_example/plugins/log_status_bt_node.hpp" -#include "behaviortree_cpp/blackboard.h" +#include "behaviortree_cpp_v3/blackboard.h" #include "rclcpp/publisher.hpp" #include "std_msgs/msg/string.hpp" @@ -124,7 +124,7 @@ namespace bt_ros_example BtRosNode::timer_callback() { RCLCPP_INFO(this->get_logger(), "Ticking the tree"); - tree_.tickOnce(); + tree_.tickRoot(); return; } } diff --git a/src/plugins/log_status_bt_node.cpp b/src/plugins/log_status_bt_node.cpp index 9cf3f4a..0235966 100644 --- a/src/plugins/log_status_bt_node.cpp +++ b/src/plugins/log_status_bt_node.cpp @@ -4,7 +4,7 @@ namespace polymath { namespace bt_ros_example { - LogStatusNode::LogStatusNode(const std::string & action_name, const BT::NodeConfig & conf) + LogStatusNode::LogStatusNode(const std::string & action_name, const BT::NodeConfiguration & conf) : BT::SyncActionNode(action_name, conf), print_ping_pong_(false) { diff --git a/src/plugins/ping_bt_node.cpp b/src/plugins/ping_bt_node.cpp index 66c8464..8cd0772 100644 --- a/src/plugins/ping_bt_node.cpp +++ b/src/plugins/ping_bt_node.cpp @@ -6,7 +6,7 @@ namespace polymath namespace bt_ros_example { - PingNode::PingNode(const std::string &action_name, const BT::NodeConfig &conf) + PingNode::PingNode(const std::string &action_name, const BT::NodeConfiguration &conf) : BT::StatefulActionNode(action_name, conf), pub_topic_("outgoing_ping") { diff --git a/src/plugins/pong_received_bt_node.cpp b/src/plugins/pong_received_bt_node.cpp index 7f4107f..85cc34f 100644 --- a/src/plugins/pong_received_bt_node.cpp +++ b/src/plugins/pong_received_bt_node.cpp @@ -4,7 +4,7 @@ namespace polymath { namespace bt_ros_example { - PongReceivedNode::PongReceivedNode(const std::string & condition_name, const BT::NodeConfig & conf) + PongReceivedNode::PongReceivedNode(const std::string & condition_name, const BT::NodeConfiguration & conf) : BT::ConditionNode(condition_name, conf), sub_topic_("incoming_pong"), pong_id_received_(-1) diff --git a/src/plugins/pong_received_executor_bt_node.cpp b/src/plugins/pong_received_executor_bt_node.cpp index a1b1f34..91cc401 100644 --- a/src/plugins/pong_received_executor_bt_node.cpp +++ b/src/plugins/pong_received_executor_bt_node.cpp @@ -4,7 +4,7 @@ namespace polymath { namespace bt_ros_example { - PongReceivedExecutorNode::PongReceivedExecutorNode(const std::string & condition_name, const BT::NodeConfig & conf) + PongReceivedExecutorNode::PongReceivedExecutorNode(const std::string & condition_name, const BT::NodeConfiguration & conf) : BT::ConditionNode(condition_name, conf), sub_topic_("incoming_pong"), pong_id_received_(-1)