Skip to content

Commit a27c815

Browse files
Added function to check maximum distance of sensor points
Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp>
1 parent e1a3139 commit a27c815

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

localization/ndt_scan_matcher/config/ndt_scan_matcher.param.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
map_frame: "map"
1212

1313

14+
sensor_points:
15+
# Required distance of input sensor points.
16+
# If the max distance of input sensor points is lower than this value, the scan matching will not be performed.
17+
required_distance: 10.0
18+
19+
1420
ndt:
1521
# The maximum difference between two consecutive
1622
# transformations in order to consider convergence

localization/ndt_scan_matcher/include/ndt_scan_matcher/hyper_parameters.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ struct HyperParameters
3737
std::string map_frame;
3838
} frame;
3939

40+
struct SensorPoints
41+
{
42+
double required_distance;
43+
} sensor_points;
44+
4045
pclomp::NdtParams ndt;
4146
bool ndt_regularization_enable;
4247

@@ -91,6 +96,9 @@ struct HyperParameters
9196
frame.ndt_base_frame = node->declare_parameter<std::string>("frame.ndt_base_frame");
9297
frame.map_frame = node->declare_parameter<std::string>("frame.map_frame");
9398

99+
sensor_points.required_distance =
100+
node->declare_parameter<double>("sensor_points.required_distance");
101+
94102
ndt.trans_epsilon = node->declare_parameter<double>("ndt.trans_epsilon");
95103
ndt.step_size = node->declare_parameter<double>("ndt.step_size");
96104
ndt.resolution = node->declare_parameter<double>("ndt.resolution");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Parameters for Ndt Scan Matcher Node",
4+
"definitions": {
5+
"frame": {
6+
"type": "object",
7+
"properties": {
8+
"required_distance": {
9+
"type": "number",
10+
"description": "Required distance of input sensor points. If the max distance of input sensor points is lower than this value, the scan matching will not be performed.",
11+
"default": "10.0"
12+
}
13+
},
14+
"required": [
15+
"required_distance"
16+
],
17+
"additionalProperties": false
18+
}
19+
}
20+
}

localization/ndt_scan_matcher/src/ndt_scan_matcher_core.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,21 @@ void NDTScanMatcher::callback_sensor_points(
346346
transform_sensor_measurement(
347347
sensor_frame, param_.frame.base_frame, sensor_points_in_sensor_frame,
348348
sensor_points_in_baselink_frame);
349+
350+
// check max distance of sensor points
351+
double max_distance = 0.0;
352+
for (const auto & point : sensor_points_in_baselink_frame->points) {
353+
const double distance = std::hypot(point.x, point.y, point.z);
354+
max_distance = std::max(max_distance, distance);
355+
}
356+
if (max_distance < param_.sensor_points.required_distance) {
357+
RCLCPP_WARN_STREAM(
358+
this->get_logger(),
359+
"Max distance of sensor points = " << std::fixed << std::setprecision(3) << max_distance
360+
<< " < " << param_.sensor_points.required_distance);
361+
return;
362+
}
363+
349364
ndt_ptr_->setInputSource(sensor_points_in_baselink_frame);
350365
if (!is_activated_) return;
351366

0 commit comments

Comments
 (0)