Skip to content

Commit b9412dd

Browse files
committed
Merge branch 'humble-devel' of https://github.com/CoreSenseEU/CoreSense4Home into humble-devel
2 parents d00f501 + 175c716 commit b9412dd

12 files changed

Lines changed: 485 additions & 4 deletions

File tree

bt_nodes/configuration/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ list(APPEND plugin_libs init_restaurant_bt_node)
6161
add_library(remove_string_suffix_bt_node SHARED src/configuration/remove_string_suffix.cpp)
6262
list(APPEND plugin_libs remove_string_suffix_bt_node)
6363

64+
add_library(add_string_suffix_bt_node SHARED src/configuration/add_string_suffix.cpp)
65+
list(APPEND plugin_libs add_string_suffix_bt_node)
66+
6467
add_library(remove_string_prefix_bt_node SHARED src/configuration/remove_string_prefix.cpp)
6568
list(APPEND plugin_libs remove_string_prefix_bt_node)
6669

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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__ADD_STRING_SUFFIX_HPP_
16+
#define CONFIGURATION__ADD_STRING_SUFFIX_HPP_
17+
18+
#include "behaviortree_cpp_v3/behavior_tree.h"
19+
#include "behaviortree_cpp_v3/bt_factory.h"
20+
21+
namespace configuration
22+
{
23+
24+
class AddStringSuffix : public BT::ActionNodeBase
25+
{
26+
public:
27+
explicit AddStringSuffix(const std::string & xml_tag_name, const BT::NodeConfiguration & conf);
28+
29+
void halt();
30+
BT::NodeStatus tick();
31+
32+
static BT::PortsList providedPorts()
33+
{
34+
return BT::PortsList(
35+
{
36+
BT::InputPort<std::string>("string_to_modify"),
37+
BT::InputPort<std::string>("suffix"),
38+
BT::OutputPort<std::string>("result")
39+
});
40+
}
41+
42+
private:
43+
std::string string_to_modify_;
44+
std::string suffix_;
45+
std::string result_;
46+
};
47+
48+
} // namespace configuration
49+
50+
#endif // CONFIGURATION__ADD_STRING_SUFFIX_HPP_
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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/add_string_suffix.hpp"
16+
17+
namespace configuration
18+
{
19+
20+
AddStringSuffix::AddStringSuffix(
21+
const std::string & xml_tag_name, const BT::NodeConfiguration & conf)
22+
: BT::ActionNodeBase(xml_tag_name, conf)
23+
{
24+
}
25+
26+
BT::NodeStatus AddStringSuffix::tick()
27+
{
28+
getInput("string_to_modify", string_to_modify_);
29+
getInput("suffix", suffix_);
30+
if (string_to_modify_.empty()) {
31+
return BT::NodeStatus::FAILURE;
32+
}
33+
result_ = string_to_modify_ + suffix_;
34+
setOutput("result", result_);
35+
return BT::NodeStatus::SUCCESS;
36+
}
37+
38+
void AddStringSuffix::halt() {}
39+
40+
} // namespace configuration
41+
42+
BT_REGISTER_NODES(factory)
43+
{
44+
factory.registerNodeType<configuration::AddStringSuffix>("AddStringSuffix");
45+
}

bt_nodes/perception/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ list(APPEND plugin_libs clear_octomap_bt_node)
112112
add_library(switch_yolo_model_bt_node SHARED src/perception/switch_yolo_model.cpp)
113113
list(APPEND plugin_libs switch_yolo_model_bt_node)
114114

115+
add_library(set_persistent_id_bt_node SHARED src/perception/set_persistent_id.cpp)
116+
list(APPEND plugin_libs set_persistent_id_bt_node)
117+
115118
add_library(extract_pc_from_class_bt_node SHARED src/perception/extract_pc_from_class.cpp)
116119
list(APPEND plugin_libs extract_pc_from_class_bt_node)
117120

@@ -120,6 +123,8 @@ list(APPEND plugin_libs store_identity_vector_bt_node)
120123

121124
add_library(enable_detect_by_identity_bt_node SHARED src/perception/enable_detect_by_identity.cpp)
122125
list(APPEND plugin_libs enable_detect_by_identity_bt_node)
126+
add_library(extract_handover_alignment_bt_node SHARED src/perception/ExtractHandoverAlignment.cpp)
127+
list(APPEND plugin_libs extract_handover_alignment_bt_node)
123128

124129
foreach(bt_plugin ${plugin_libs})
125130
ament_target_dependencies(${bt_plugin} ${dependencies})
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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 PERCEPTION__EXTRACT_HANDOVER_ALIGNMENT_HPP_
16+
#define PERCEPTION__EXTRACT_HANDOVER_ALIGNMENT_HPP_
17+
18+
#include <string>
19+
20+
#include "behaviortree_cpp_v3/behavior_tree.h"
21+
#include "behaviortree_cpp_v3/bt_factory.h"
22+
#include "geometry_msgs/msg/transform_stamped.hpp"
23+
#include "rclcpp/rclcpp.hpp"
24+
#include "rclcpp_cascade_lifecycle/rclcpp_cascade_lifecycle.hpp"
25+
#include "tf2_geometry_msgs/tf2_geometry_msgs.hpp"
26+
#include "tf2_ros/buffer.h"
27+
#include "tf2_ros/transform_listener.h"
28+
#include "yolo_msgs/msg/detection_array.hpp"
29+
#include "sensor_msgs/msg/joint_state.hpp"
30+
31+
namespace perception
32+
{
33+
34+
class ExtractHandoverAlignment : public BT::ActionNodeBase
35+
{
36+
public:
37+
explicit ExtractHandoverAlignment(
38+
const std::string & xml_tag_name, const BT::NodeConfiguration & conf);
39+
40+
void halt();
41+
BT::NodeStatus tick();
42+
43+
static BT::PortsList providedPorts()
44+
{
45+
return BT::PortsList(
46+
{BT::InputPort<std::string>("interest_class"),
47+
BT::InputPort<double>("target_z_distance"),
48+
BT::InputPort<double>("target_y_distance"),
49+
BT::OutputPort<double>("base_x_movement"),
50+
BT::OutputPort<double>("torso_z_movement")});
51+
}
52+
53+
void detection_callback_(yolo_msgs::msg::DetectionArray::UniquePtr msg);
54+
void joint_state_callback_(sensor_msgs::msg::JointState::UniquePtr msg);
55+
56+
private:
57+
std::shared_ptr<rclcpp_cascade_lifecycle::CascadeLifecycleNode> node_;
58+
rclcpp::Subscription<yolo_msgs::msg::DetectionArray>::SharedPtr detected_objs_sub_;
59+
rclcpp::Subscription<sensor_msgs::msg::JointState>::SharedPtr joint_state_sub_;
60+
yolo_msgs::msg::DetectionArray::UniquePtr last_detected_objs_ = {nullptr};
61+
std::string interest_class_{""};
62+
double current_torso_height_ = 0.0;
63+
bool torso_height_received_ = false;
64+
65+
std::unique_ptr<tf2_ros::Buffer> tf_buffer_;
66+
std::shared_ptr<tf2_ros::TransformListener> tf_listener_;
67+
};
68+
69+
} // namespace perception
70+
71+
#endif // PERCEPTION__EXTRACT_HANDOVER_ALIGNMENT_HPP_
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 PERCEPTION__SET_PERSISTENT_ID_HPP_
16+
#define PERCEPTION__SET_PERSISTENT_ID_HPP_
17+
18+
#include <string>
19+
20+
#include "behaviortree_cpp_v3/behavior_tree.h"
21+
#include "behaviortree_cpp_v3/bt_factory.h"
22+
#include "perception/bt_service_node.hpp"
23+
#include "yolo_msgs/srv/set_persitent_id.hpp"
24+
#include "rclcpp/rclcpp.hpp"
25+
#include "rclcpp_cascade_lifecycle/rclcpp_cascade_lifecycle.hpp"
26+
27+
namespace perception
28+
{
29+
30+
class SetPersistentId : public perception::BtServiceNode<
31+
yolo_msgs::srv::SetPersitentID,
32+
rclcpp_cascade_lifecycle::CascadeLifecycleNode>
33+
{
34+
public:
35+
explicit SetPersistentId(
36+
const std::string & xml_tag_name, const std::string & action_name,
37+
const BT::NodeConfiguration & conf);
38+
39+
void on_tick() override;
40+
void on_result() override;
41+
42+
static BT::PortsList providedPorts()
43+
{
44+
return BT::PortsList(
45+
{BT::InputPort<int>("id")});
46+
}
47+
};
48+
49+
} // namespace perception
50+
51+
#endif // PERCEPTION__SET_PERSISTENT_ID_HPP_

0 commit comments

Comments
 (0)