Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update behaviortree_cpp to v4 #21

Merged
merged 4 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion dependencies.repos
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ repositories:
url: https://github.com/sea-bass/py_trees_ros_viewer.git
version: devel

# Groot for visualizing behavior trees from BehaviorTree.CPP.
# BehaviorTree.CPP and Groot for visualizing behavior trees from BehaviorTree.CPP.
behaviortree_cpp:
type: git
url: https://github.com/BehaviorTree/BehaviorTree.CPP.git
version: master
groot:
type: git
url: https://github.com/BehaviorTree/Groot.git
version: master

4 changes: 2 additions & 2 deletions tb3_autonomy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(behaviortree_cpp_v3 REQUIRED)
find_package(behaviortree_cpp REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(OpenCV REQUIRED)
find_package(image_transport REQUIRED)
Expand Down Expand Up @@ -50,7 +50,7 @@ set(AUTONOMY_SOURCES
set(TARGET_DEPENDS
ament_index_cpp rclcpp rclcpp_action
nav2_msgs sensor_msgs cv_bridge image_transport
behaviortree_cpp_v3 tf2 tf2_ros tf2_geometry_msgs yaml-cpp
behaviortree_cpp tf2 tf2_ros tf2_geometry_msgs yaml-cpp
)
include_directories(include)
add_executable(autonomy_node_cpp src/autonomy_node.cpp ${AUTONOMY_SOURCES})
Expand Down
2 changes: 1 addition & 1 deletion tb3_autonomy/bt_xml/nav_tree_naive.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Behavior tree that sequentially navigates locations naively -->
<root main_tree_to_execute = "MainTree" >
<root BTCPP_format="4" >
<BehaviorTree ID="MainTree">
<Sequence name="sequence">
<GoToPose name="go_to_location1" loc="location1" />
Expand Down
2 changes: 1 addition & 1 deletion tb3_autonomy/bt_xml/nav_tree_queue.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Behavior tree that sequentially navigates locations using a queue of locations. -->
<root main_tree_to_execute = "MainTree" >
<root BTCPP_format="4">
<BehaviorTree ID="MainTree">
<Sequence name="main_loop">
<SetLocations name="set_locations" num_locs="{num_locs}"/>
Expand Down
2 changes: 1 addition & 1 deletion tb3_autonomy/bt_xml/tree_naive.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Behavior tree that looks for objects by naively looking through locations. -->
<root main_tree_to_execute = "MainTree" >
<root BTCPP_format="4">
<BehaviorTree ID="MainTree">
<Sequence name="main_loop">
<SetLocations name="set_locations" num_locs="{num_locs}"/>
Expand Down
2 changes: 1 addition & 1 deletion tb3_autonomy/bt_xml/tree_queue.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Behavior tree that looks for objects by using a queue of locations. -->
<root main_tree_to_execute = "MainTree" >
<root BTCPP_format="4">
<BehaviorTree ID="MainTree">
<Sequence name="main_loop">
<SetLocations name="set_locations" num_locs="{num_locs}"/>
Expand Down
8 changes: 4 additions & 4 deletions tb3_autonomy/include/navigation_behaviors.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#include "rclcpp/rclcpp.hpp"
#include "rclcpp_action/rclcpp_action.hpp"
#include "nav2_msgs/action/navigate_to_pose.hpp"
#include "behaviortree_cpp_v3/behavior_tree.h"
#include "behaviortree_cpp/behavior_tree.h"

// Sets number of locations from list.
class SetLocations : public BT::SyncActionNode
{
public:
SetLocations(const std::string& name, const BT::NodeConfiguration& config);
SetLocations(const std::string& name, const BT::NodeConfig& config);
BT::NodeStatus tick() override;
static BT::PortsList providedPorts();
};
Expand All @@ -22,7 +22,7 @@ class GetLocationFromQueue : public BT::SyncActionNode
std::deque<std::string> location_queue_;

GetLocationFromQueue(
const std::string& name, const BT::NodeConfiguration& config,
const std::string& name, const BT::NodeConfig& config,
rclcpp::Node::SharedPtr node_ptr);
BT::NodeStatus tick() override;
static BT::PortsList providedPorts();
Expand All @@ -41,7 +41,7 @@ class GoToPose : public BT::StatefulActionNode
rclcpp_action::Client<NavigateToPose>::SharedPtr client_ptr_;

// Method overrides
GoToPose(const std::string& name, const BT::NodeConfiguration& config,
GoToPose(const std::string& name, const BT::NodeConfig& config,
rclcpp::Node::SharedPtr node_ptr);
BT::NodeStatus onStart() override;
BT::NodeStatus onRunning() override;
Expand Down
4 changes: 2 additions & 2 deletions tb3_autonomy/include/vision_behaviors.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "rclcpp/rclcpp.hpp"
#include "image_transport/image_transport.hpp"
#include "sensor_msgs/msg/image.hpp"
#include "behaviortree_cpp_v3/behavior_tree.h"
#include "behaviortree_cpp/behavior_tree.h"

// HSV Thresholding parameters
// The convention is {H_MIN, H_MAX, S_MIN, S_MAX, V_MIN, V_MAX}
Expand All @@ -27,7 +27,7 @@ class LookForObject : public BT::StatefulActionNode
image_transport::Subscriber image_sub_;

// Method overrides
LookForObject(const std::string& name, const BT::NodeConfiguration& config,
LookForObject(const std::string& name, const BT::NodeConfig& config,
rclcpp::Node::SharedPtr node_ptr);
BT::NodeStatus onStart() override;
BT::NodeStatus onRunning() override;
Expand Down
2 changes: 1 addition & 1 deletion tb3_autonomy/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<depend>rclcpp</depend>
<depend>rclcpp_action</depend>
<depend>ament_index_cpp</depend>
<depend>behaviortree_cpp_v3</depend>
<depend>behaviortree_cpp</depend>
<depend>nav2_msgs</depend>
<depend>sensor_msgs</depend>
<depend>tb3_worlds</depend>
Expand Down
8 changes: 4 additions & 4 deletions tb3_autonomy/src/autonomy_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include "rclcpp/rclcpp.hpp"
#include "ament_index_cpp/get_package_share_directory.hpp"
#include "behaviortree_cpp_v3/bt_factory.h"
#include "behaviortree_cpp_v3/loggers/bt_zmq_publisher.h"
#include "behaviortree_cpp/bt_factory.h"
#include "behaviortree_cpp/loggers/bt_zmq_publisher.h"
#include "yaml-cpp/yaml.h"

#include "navigation_behaviors.h"
Expand All @@ -31,7 +31,7 @@ void registerRosNodeType(BT::BehaviorTreeFactory& factory,
const std::string& registration_ID,
rclcpp::Node::SharedPtr node_ptr) {
BT::NodeBuilder builder = [=](const std::string& name,
const BT::NodeConfiguration& config) {
const BT::NodeConfig& config) {
return std::make_unique<NodeBehaviorT>(name, config, node_ptr);
};
factory.registerBuilder<NodeBehaviorT>(registration_ID, builder);
Expand Down Expand Up @@ -111,7 +111,7 @@ class AutonomyNode : public rclcpp::Node {

void update_behavior_tree() {
// Tick the behavior tree.
BT::NodeStatus tree_status = tree_.tickRoot();
BT::NodeStatus tree_status = tree_.tickOnce();
if (tree_status == BT::NodeStatus::RUNNING) {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions tb3_autonomy/src/navigation_behaviors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// SETLOCATIONS
// Gets a list of locations from a YAML file and ensures they are not empty
SetLocations::SetLocations(const std::string& name, const BT::NodeConfiguration& config) :
SetLocations::SetLocations(const std::string& name, const BT::NodeConfig& config) :
BT::SyncActionNode(name, config)
{
std::cout << "[" << this->name() << "] Initialized" << std::endl;
Expand Down Expand Up @@ -41,7 +41,7 @@ BT::PortsList SetLocations::providedPorts()
// Gets a location name from a queue of locations to visit.
// If the queue is empty, this behavior fails.
GetLocationFromQueue::GetLocationFromQueue(const std::string& name,
const BT::NodeConfiguration& config,
const BT::NodeConfig& config,
rclcpp::Node::SharedPtr node_ptr) :
BT::SyncActionNode(name, config), node_ptr_{node_ptr}
{
Expand Down Expand Up @@ -83,7 +83,7 @@ BT::PortsList GetLocationFromQueue::providedPorts()
// GOTOPOSE
// Wrapper behavior around the `navigate_to_pose` action client,
// whose status reflects the status of the ROS action.
GoToPose::GoToPose(const std::string& name, const BT::NodeConfiguration& config,
GoToPose::GoToPose(const std::string& name, const BT::NodeConfig& config,
rclcpp::Node::SharedPtr node_ptr) :
BT::StatefulActionNode(name, config), node_ptr_{node_ptr} {}

Expand All @@ -95,7 +95,7 @@ BT::NodeStatus GoToPose::onStart() {
}

// Read the YAML file
BT::Optional<std::string> loc = getInput<std::string>("loc");
BT::Expected<std::string> loc = getInput<std::string>("loc");
const std::string location_file =
node_ptr_->get_parameter("location_file").as_string();
YAML::Node locations = YAML::LoadFile(location_file);
Expand Down
2 changes: 1 addition & 1 deletion tb3_autonomy/src/vision_behaviors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using std::placeholders::_1;
// LOOKFOROBJECT
// Looks for an object of a certain color, specified by a parameter
LookForObject::LookForObject(const std::string& name,
const BT::NodeConfiguration& config,
const BT::NodeConfig& config,
rclcpp::Node::SharedPtr node_ptr) :
BT::StatefulActionNode(name, config), node_ptr_{node_ptr}
{
Expand Down