Skip to content

Commit ca91b5b

Browse files
committed
feat: pre-defined channels, select on launcher
Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp>
1 parent 90d287c commit ca91b5b

File tree

4 files changed

+69
-26
lines changed

4 files changed

+69
-26
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**:
2+
ros__parameters:
3+
input_channels:
4+
detected_objects:
5+
topic: "/perception/object_recognition/detection/objects"
6+
name: "detected_objects"
7+
name_short: "all"
8+
expected_frequency: 10.0
9+
centerpoint:
10+
topic: "/perception/object_recognition/detection/centerpoint/objects"
11+
name: "centerpoint"
12+
name_short: "Lcp"
13+
expected_frequency: 10.0
14+
centerpoint_validated:
15+
topic: "/perception/object_recognition/detection/centerpoint/validation/objects"
16+
name: "centerpoint"
17+
name_short: "Lcp"
18+
expected_frequency: 10.0
19+
camera_lidar_fusion:
20+
topic: "/perception/object_recognition/detection/clustering/camera_lidar_fusion/objects"
21+
name: "camera_lidar_fusion"
22+
name_short: "CLf"
23+
expected_frequency: 10.0
24+
camera_lidar_fusion_filtered:
25+
topic: "/perception/object_recognition/detection/clustering/camera_lidar_fusion/objects"
26+
name: "camera_lidar_fusion"
27+
name_short: "CLf"
28+
expected_frequency: 10.0
29+
detection_by_tracker:
30+
topic: "/perception/object_recognition/detection/detection_by_tracker/objects"
31+
name: "detection_by_tracker"
32+
name_short: "Ld"
33+
expected_frequency: 10.0
34+
radar_far:
35+
topic: "/perception/object_recognition/detection/radar/far_objects"
36+
name: "radar_far"
37+
name_short: "Rf"
38+
expected_frequency: 30.0

perception/multi_object_tracker/config/multi_object_tracker_node.param.yaml

-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,3 @@
2020
publish_debug_markers: false
2121
diagnostics_warn_delay: 0.5 # [sec]
2222
diagnostics_error_delay: 1.0 # [sec]
23-
24-
input_topic_names: ["/perception/object_recognition/detection/objects"]
25-
input_names_long: ["detected_objects"]
26-
input_names_short: ["all"]
27-
input_priority: [0]
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<launch>
3-
<arg name="input" default="/perception/object_recognition/detection/objects"/>
3+
<arg name="selected_input_channels" default="['detected_objects']"/>
44
<arg name="output" default="objects"/>
55
<arg name="tracker_setting_path" default="$(find-pkg-share multi_object_tracker)/config/multi_object_tracker_node.param.yaml"/>
66
<arg name="data_association_matrix_path" default="$(find-pkg-share multi_object_tracker)/config/data_association_matrix.param.yaml"/>
7+
<arg name="input_channels_path" default="$(find-pkg-share multi_object_tracker)/config/input_channels.param.yaml"/>
78

89
<node pkg="multi_object_tracker" exec="multi_object_tracker" name="multi_object_tracker" output="screen">
9-
<remap from="input" to="$(var input)"/>
10+
<param name="selected_input_channels" value="$(var selected_input_channels)"/>
1011
<remap from="output" to="$(var output)"/>
1112
<param from="$(var tracker_setting_path)"/>
1213
<param from="$(var data_association_matrix_path)"/>
14+
<param from="$(var input_channels_path)"/>
1315
</node>
1416
</launch>

perception/multi_object_tracker/src/multi_object_tracker_core.cpp

+27-19
Original file line numberDiff line numberDiff line change
@@ -80,31 +80,38 @@ MultiObjectTracker::MultiObjectTracker(const rclcpp::NodeOptions & node_options)
8080
world_frame_id_ = declare_parameter<std::string>("world_frame_id");
8181
bool enable_delay_compensation{declare_parameter<bool>("enable_delay_compensation")};
8282

83-
declare_parameter("input_topic_names", std::vector<std::string>());
84-
declare_parameter("input_names_long", std::vector<std::string>());
85-
declare_parameter("input_names_short", std::vector<std::string>());
86-
declare_parameter("input_priority", std::vector<int64_t>());
87-
std::vector<std::string> input_topic_names = get_parameter("input_topic_names").as_string_array();
88-
std::vector<std::string> input_names_long = get_parameter("input_names_long").as_string_array();
89-
std::vector<std::string> input_names_short = get_parameter("input_names_short").as_string_array();
90-
std::vector<int64_t> input_priority = get_parameter("input_priority").as_integer_array();
83+
declare_parameter("selected_input_channels", std::vector<std::string>());
84+
std::vector<std::string> selected_input_channels =
85+
get_parameter("selected_input_channels").as_string_array();
9186

9287
// ROS interface - Publisher
9388
tracked_objects_pub_ = create_publisher<TrackedObjects>("output", rclcpp::QoS{1});
9489

95-
// ROS interface - Subscribers
96-
if (input_topic_names.empty()) {
90+
// ROS interface - Input channels
91+
// Get input channels
92+
std::vector<std::string> input_topic_names;
93+
std::vector<std::string> input_names_long;
94+
std::vector<std::string> input_names_short;
95+
std::vector<double> input_expected_rates;
96+
97+
if (selected_input_channels.empty()) {
9798
RCLCPP_ERROR(this->get_logger(), "No input topics are specified.");
9899
return;
99100
}
100-
if (
101-
input_names_long.size() != input_topic_names.size() ||
102-
input_names_short.size() != input_topic_names.size() ||
103-
input_priority.size() != input_topic_names.size()) {
104-
RCLCPP_ERROR(
105-
this->get_logger(),
106-
"The number of input topic names, long names, and short names must be the same.");
107-
return;
101+
102+
for (const auto & selected_input_channel : selected_input_channels) {
103+
const std::string input_topic_name =
104+
declare_parameter<std::string>("input_channels." + selected_input_channel + ".topic");
105+
const std::string input_name_long =
106+
declare_parameter<std::string>("input_channels." + selected_input_channel + ".name");
107+
const std::string input_name_short =
108+
declare_parameter<std::string>("input_channels." + selected_input_channel + ".name_short");
109+
const double input_expected_frequency =
110+
declare_parameter<double>("input_channels." + selected_input_channel + ".expected_frequency");
111+
input_topic_names.push_back(input_topic_name);
112+
input_names_long.push_back(input_name_long);
113+
input_names_short.push_back(input_name_short);
114+
input_expected_rates.push_back(input_expected_frequency);
108115
}
109116

110117
input_channel_size_ = input_topic_names.size();
@@ -114,7 +121,8 @@ MultiObjectTracker::MultiObjectTracker(const rclcpp::NodeOptions & node_options)
114121
input_channels_[i].input_topic = input_topic_names[i];
115122
input_channels_[i].long_name = input_names_long[i];
116123
input_channels_[i].short_name = input_names_short[i];
117-
input_channels_[i].priority = static_cast<int>(input_priority[i]);
124+
input_channels_[i].priority = 1;
125+
input_channels_[i].expected_rate = input_expected_rates[i];
118126
}
119127

120128
// Initialize input manager

0 commit comments

Comments
 (0)