@@ -80,31 +80,38 @@ MultiObjectTracker::MultiObjectTracker(const rclcpp::NodeOptions & node_options)
80
80
world_frame_id_ = declare_parameter<std::string>(" world_frame_id" );
81
81
bool enable_delay_compensation{declare_parameter<bool >(" enable_delay_compensation" )};
82
82
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 ();
91
86
92
87
// ROS interface - Publisher
93
88
tracked_objects_pub_ = create_publisher<TrackedObjects>(" output" , rclcpp::QoS{1 });
94
89
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 ()) {
97
98
RCLCPP_ERROR (this ->get_logger (), " No input topics are specified." );
98
99
return ;
99
100
}
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);
108
115
}
109
116
110
117
input_channel_size_ = input_topic_names.size ();
@@ -114,7 +121,8 @@ MultiObjectTracker::MultiObjectTracker(const rclcpp::NodeOptions & node_options)
114
121
input_channels_[i].input_topic = input_topic_names[i];
115
122
input_channels_[i].long_name = input_names_long[i];
116
123
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];
118
126
}
119
127
120
128
// Initialize input manager
0 commit comments