Skip to content

Commit b795851

Browse files
authoredFeb 19, 2025
fix(autoware_radar_threshold_filter): use sensor data qos (#10156)
* fix(autoware_radar_threshold_filter): use sensor data qos Signed-off-by: Mehmet Emin BAŞOĞLU <mehmeteminbasoglu@hotmail.com> * change type to fix cpplint Signed-off-by: Mehmet Emin BAŞOĞLU <mehmeteminbasoglu@hotmail.com> * update test Signed-off-by: Mehmet Emin BAŞOĞLU <mehmeteminbasoglu@hotmail.com> --------- Signed-off-by: Mehmet Emin BAŞOĞLU <mehmeteminbasoglu@hotmail.com>
1 parent 8ed8654 commit b795851

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed
 

‎sensing/autoware_radar_threshold_filter/config/radar_threshold_filter.param.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@
1616
is_z_filter: false
1717
z_min: -2.0
1818
z_max: 5.0
19+
20+
max_queue_size: 5

‎sensing/autoware_radar_threshold_filter/src/radar_threshold_filter_node.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,16 @@ RadarThresholdFilterNode::RadarThresholdFilterNode(const rclcpp::NodeOptions & n
7575
node_param_.is_z_filter = declare_parameter<bool>("node_params.is_z_filter");
7676
node_param_.z_min = declare_parameter<double>("node_params.z_min");
7777
node_param_.z_max = declare_parameter<double>("node_params.z_max");
78+
node_param_.max_queue_size = declare_parameter<int64_t>("node_params.max_queue_size");
7879

7980
// Subscriber
8081
sub_radar_ = create_subscription<RadarScan>(
81-
"~/input/radar", rclcpp::QoS{1}, std::bind(&RadarThresholdFilterNode::onData, this, _1));
82+
"~/input/radar", rclcpp::SensorDataQoS().keep_last(node_param_.max_queue_size),
83+
std::bind(&RadarThresholdFilterNode::onData, this, _1));
8284

8385
// Publisher
84-
pub_radar_ = create_publisher<RadarScan>("~/output/radar", 1);
86+
pub_radar_ = create_publisher<RadarScan>(
87+
"~/output/radar", rclcpp::SensorDataQoS().keep_last(node_param_.max_queue_size));
8588
}
8689

8790
rcl_interfaces::msg::SetParametersResult RadarThresholdFilterNode::onSetParam(
@@ -103,6 +106,7 @@ rcl_interfaces::msg::SetParametersResult RadarThresholdFilterNode::onSetParam(
103106
update_param(params, "node_params.is_z_filter", p.is_z_filter);
104107
update_param(params, "node_params.z_min", p.z_min);
105108
update_param(params, "node_params.z_max", p.z_max);
109+
update_param(params, "node_params.max_queue_size", p.max_queue_size);
106110
}
107111
} catch (const rclcpp::exceptions::InvalidParameterTypeException & e) {
108112
result.successful = false;

‎sensing/autoware_radar_threshold_filter/src/radar_threshold_filter_node.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class RadarThresholdFilterNode : public rclcpp::Node
4848
bool is_z_filter{};
4949
double z_min{};
5050
double z_max{};
51+
size_t max_queue_size{};
5152
};
5253

5354
private:

‎sensing/autoware_radar_threshold_filter/test/radar_threshold_filter/test_radar_threshold_filter.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ TEST(RadarThresholdFilter, isWithinThreshold)
3232
const double azimuth_max = 1.2;
3333
const double z_min = -2.0;
3434
const double z_max = 5.0;
35+
const int64_t max_queue_size = 5;
3536
// amplitude filter
3637
{
3738
rclcpp::NodeOptions node_options;
@@ -48,6 +49,7 @@ TEST(RadarThresholdFilter, isWithinThreshold)
4849
{"node_params.is_z_filter", false},
4950
{"node_params.z_min", z_min},
5051
{"node_params.z_max", z_max},
52+
{"node_params.max_queue_size", max_queue_size},
5153
});
5254

5355
RadarThresholdFilterNode node(node_options);
@@ -78,6 +80,7 @@ TEST(RadarThresholdFilter, isWithinThreshold)
7880
{"node_params.is_z_filter", false},
7981
{"node_params.z_min", z_min},
8082
{"node_params.z_max", z_max},
83+
{"node_params.max_queue_size", max_queue_size},
8184
});
8285

8386
RadarThresholdFilterNode node(node_options);
@@ -107,6 +110,7 @@ TEST(RadarThresholdFilter, isWithinThreshold)
107110
{"node_params.is_z_filter", false},
108111
{"node_params.z_min", z_min},
109112
{"node_params.z_max", z_max},
113+
{"node_params.max_queue_size", max_queue_size},
110114
});
111115

112116
RadarThresholdFilterNode node(node_options);
@@ -135,6 +139,7 @@ TEST(RadarThresholdFilter, isWithinThreshold)
135139
{"node_params.is_z_filter", true},
136140
{"node_params.z_min", z_min},
137141
{"node_params.z_max", z_max},
142+
{"node_params.max_queue_size", max_queue_size},
138143
});
139144

140145
RadarThresholdFilterNode node(node_options);

0 commit comments

Comments
 (0)
Please sign in to comment.