Skip to content

Commit 6a70ccf

Browse files
committed
updated bt_nodes
1 parent a7b2593 commit 6a70ccf

34 files changed

Lines changed: 535 additions & 178 deletions

bt_nodes/configuration/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ find_package(geometry_msgs REQUIRED)
1414
find_package(tf2_geometry_msgs REQUIRED)
1515
find_package(tf2_ros REQUIRED)
1616
find_package(tf2 REQUIRED)
17-
find_package(yolo_msgs REQUIRED)
17+
find_package(yolov8_msgs REQUIRED)
1818

1919
set(CMAKE_CXX_STANDARD 17)
2020

@@ -27,7 +27,7 @@ set(dependencies
2727
tf2_geometry_msgs
2828
tf2
2929
tf2_ros
30-
yolo_msgs
30+
yolov8_msgs
3131
)
3232

3333
include_directories(include)
@@ -88,6 +88,9 @@ list(APPEND plugin_libs sleep_bt_node)
8888
add_library(set_blackboard_int_bt_node SHARED src/configuration/set_blackboard_int.cpp)
8989
list(APPEND plugin_libs set_blackboard_int_bt_node)
9090

91+
add_library(activation_control_bt_node SHARED src/configuration/ActivationControl.cpp)
92+
list(APPEND plugin_libs activation_control_bt_node)
93+
9194
foreach(bt_plugin ${plugin_libs})
9295
ament_target_dependencies(${bt_plugin} ${dependencies})
9396
target_compile_definitions(${bt_plugin} PRIVATE BT_PLUGIN_EXPORT)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2024 Intelligent Robotics Lab - Gentlebots
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef CONFIGURATION__ACTIVATION_CONTROL_HPP_
16+
#define CONFIGURATION__ACTIVATION_CONTROL_HPP_
17+
18+
#include <memory>
19+
#include <string>
20+
21+
#include "behaviortree_cpp_v3/behavior_tree.h"
22+
#include "behaviortree_cpp_v3/bt_factory.h"
23+
24+
#include "rclcpp/rclcpp.hpp"
25+
#include "rclcpp_cascade_lifecycle/rclcpp_cascade_lifecycle.hpp"
26+
27+
namespace configuration
28+
{
29+
30+
class ActivationControl : public BT::ActionNodeBase
31+
{
32+
public:
33+
explicit ActivationControl(const std::string & xml_tag_name, const BT::NodeConfiguration & conf);
34+
35+
void halt();
36+
BT::NodeStatus tick();
37+
38+
static BT::PortsList providedPorts()
39+
{
40+
return BT::PortsList({
41+
BT::InputPort<bool>("deactivate", "If true, remove activation, otherwise add"),
42+
BT::InputPort<std::string>("node_name", "Name of the node to (de)activate")
43+
});
44+
}
45+
46+
private:
47+
std::shared_ptr<rclcpp_cascade_lifecycle::CascadeLifecycleNode> node_;
48+
bool deactivate_ {false};
49+
std::string node_name_;
50+
};
51+
52+
} // namespace configuration
53+
54+
#endif // CONFIGURATION__ACTIVATION_CONTROL_HPP_

bt_nodes/configuration/include/configuration/set_perception_model.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
#include "configuration/bt_service_node.hpp"
2424
#include "rclcpp/rclcpp.hpp"
2525
#include "rclcpp_cascade_lifecycle/rclcpp_cascade_lifecycle.hpp"
26-
#include "yolo_msgs/srv/change_model.hpp"
26+
#include "yolov8_msgs/srv/change_model.hpp"
2727

2828

2929
namespace configuration
3030
{
3131

3232
class SetPerceptionModel
33-
: public configuration::BtServiceNode<yolo_msgs::srv::ChangeModel,
33+
: public configuration::BtServiceNode<yolov8_msgs::srv::ChangeModel,
3434
rclcpp_cascade_lifecycle::CascadeLifecycleNode>
3535
{
3636
public:

bt_nodes/configuration/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<depend>behaviortree_cpp_v3</depend>
1717
<depend>geometry_msgs</depend>
1818
<depend>tf2_geometry_msgs</depend>
19-
<depend>yolo_msgs</depend>
19+
<depend>yolov8_msgs</depend>
2020

2121
<test_depend>ament_lint_auto</test_depend>
2222
<test_depend>ament_lint_common</test_depend>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2024 Intelligent Robotics Lab - Gentlebots
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "configuration/ActivationControl.hpp"
16+
17+
namespace configuration
18+
{
19+
20+
ActivationControl::ActivationControl(const std::string & xml_tag_name, const BT::NodeConfiguration & conf)
21+
: BT::ActionNodeBase(xml_tag_name, conf)
22+
{
23+
config().blackboard->get("node", node_);
24+
}
25+
26+
BT::NodeStatus ActivationControl::tick()
27+
{
28+
RCLCPP_DEBUG(node_->get_logger(), "ActivationControl ticked");
29+
30+
// Read inputs
31+
if (!getInput("deactivate", deactivate_)) {
32+
RCLCPP_WARN(node_->get_logger(), "ActivationControl: missing 'deactivate' input, defaulting to false");
33+
deactivate_ = false;
34+
}
35+
if (!getInput("node_name", node_name_)) {
36+
RCLCPP_ERROR(node_->get_logger(), "ActivationControl: missing 'node_name' input");
37+
return BT::NodeStatus::FAILURE;
38+
}
39+
40+
if (deactivate_) {
41+
RCLCPP_INFO(node_->get_logger(), "ActivationControl: removing activation for %s", node_name_.c_str());
42+
node_->remove_activation(node_name_);
43+
} else {
44+
RCLCPP_INFO(node_->get_logger(), "ActivationControl: adding activation for %s", node_name_.c_str());
45+
node_->add_activation(node_name_);
46+
}
47+
48+
return BT::NodeStatus::SUCCESS;
49+
}
50+
51+
void ActivationControl::halt()
52+
{
53+
RCLCPP_DEBUG(node_->get_logger(), "ActivationControl halted");
54+
}
55+
56+
} // namespace configuration
57+
58+
BT_REGISTER_NODES(factory) {
59+
factory.registerNodeType<configuration::ActivationControl>("ActivationControl");
60+
}

bt_nodes/configuration/src/configuration/Deferred.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ BT::NodeStatus Deferred::tick()
8282
// publisher_zmq_ = std::make_unique<BT::PublisherZMQ>(subtree_, 10, 2666, 2667);
8383
}
8484

85+
std::cerr << "[DeferredBT] Executing tick to the subtree!!" << std::endl;
8586
auto state = subtree_.rootNode()->executeTick();
87+
std::cerr << "[DeferredBT] Executed tick " << std::endl;
8688

8789
// if (state == BT::NodeStatus::FAILURE || state == BT::NodeStatus::SUCCESS) {
8890
// publisher_zmq_.reset();

bt_nodes/configuration/src/configuration/init_carry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ InitCarry::InitCarry(const std::string & xml_tag_name, const BT::NodeConfigurati
2121
: BT::ActionNodeBase(xml_tag_name, conf)
2222
{
2323
config().blackboard->get("node", node_);
24-
node_->declare_parameter("cam_frame", "head_front_camera_rgb_optical_frame");
24+
node_->declare_parameter("cam_frame", "camera_color_optical_frame");
2525
node_->declare_parameter("home_position", std::vector<double>{0.0, 0.0, 0.0});
2626
node_->declare_parameter("home_pose", "home");
2727
node_->declare_parameter("offer_pose", "offer");

bt_nodes/configuration/src/configuration/init_groceries.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ InitGroceries::InitGroceries(const std::string & xml_tag_name, const BT::NodeCon
2222
{
2323
config().blackboard->get("node", node_);
2424

25-
node_->declare_parameter("cam_frame", "head_front_camera_rgb_optical_frame");
25+
node_->declare_parameter("cam_frame", "camera_color_optical_frame");
2626
node_->declare_parameter("manipulation_frame", "base_link");
2727
// node_->declare_parameter("party_wp", std::vector<double>{0.0, 0.0, 0.0});
2828
// node_->declare_parameter("entrance_wp", std::vector<double>{0.0, 0.0, 0.0});

bt_nodes/configuration/src/configuration/init_restaurant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ InitRestaurant::InitRestaurant(
2323
{
2424
config().blackboard->get("node", node_);
2525

26-
node_->declare_parameter("cam_frame", "head_front_camera_rgb_optical_frame");
26+
node_->declare_parameter("cam_frame", "camera_color_optical_frame");
2727

2828
tf_buffer_ = std::make_shared<tf2_ros::Buffer>(node_->get_clock());
2929
tf_listener_ = std::make_shared<tf2_ros::TransformListener>(*tf_buffer_);

bt_nodes/configuration/src/configuration/init_stickler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ InitStickler::InitStickler(
2323
{
2424
config().blackboard->get("node", node_);
2525

26-
node_->declare_parameter("cam_frame", "head_front_camera_rgb_optical_frame");
26+
node_->declare_parameter("cam_frame", "camera_color_optical_frame");
2727

2828
tf_buffer_ = std::make_shared<tf2_ros::Buffer>(node_->get_clock());
2929
tf_listener_ = std::make_shared<tf2_ros::TransformListener>(*tf_buffer_);

0 commit comments

Comments
 (0)