Skip to content

Commit b8c9701

Browse files
feat(ndt_scan_matcher): added a function to check maximum distance of sensor points (autowarefoundation#6559)
* Added function to check maximum distance of sensor points Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp> * style(pre-commit): autofix * Added unit Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp> * Fixed json schema Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp> --------- Signed-off-by: Shintaro SAKODA <shintaro.sakoda@tier4.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent b7fdccc commit b8c9701

File tree

6 files changed

+56
-1
lines changed

6 files changed

+56
-1
lines changed

localization/ndt_scan_matcher/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ One optional function is regularization. Please see the regularization chapter i
6060

6161
{{ json_to_markdown("localization/ndt_scan_matcher/schema/sub/frame.json") }}
6262

63+
#### Sensor Points
64+
65+
{{ json_to_markdown("localization/ndt_scan_matcher/schema/sub/sensor_points.json") }}
66+
6367
#### Ndt
6468

6569
{{ json_to_markdown("localization/ndt_scan_matcher/schema/sub/ndt.json") }}

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. [m]
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");

localization/ndt_scan_matcher/schema/ndt_scan_matcher.schema.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"covariance": { "$ref": "sub/covariance.json#/definitions/covariance" },
2222
"dynamic_map_loading": {
2323
"$ref": "sub/dynamic_map_loading.json#/definitions/dynamic_map_loading"
24+
},
25+
"sensor_points": {
26+
"$ref": "sub/sensor_points.json#/definitions/sensor_points"
2427
}
2528
},
2629
"required": [
@@ -30,7 +33,8 @@
3033
"validation",
3134
"score_estimation",
3235
"covariance",
33-
"dynamic_map_loading"
36+
"dynamic_map_loading",
37+
"sensor_points"
3438
],
3539
"additionalProperties": false
3640
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Parameters for Ndt Scan Matcher Node",
4+
"definitions": {
5+
"sensor_points": {
6+
"type": "object",
7+
"properties": {
8+
"required_distance": {
9+
"type": "number",
10+
"description": "Required distance of input sensor points [m]. 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": ["required_distance"],
15+
"additionalProperties": false
16+
}
17+
}
18+
}

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(), "Max distance of sensor points = "
359+
<< std::fixed << std::setprecision(3) << max_distance << " [m] < "
360+
<< param_.sensor_points.required_distance << " [m]");
361+
return;
362+
}
363+
349364
ndt_ptr_->setInputSource(sensor_points_in_baselink_frame);
350365
if (!is_activated_) return;
351366

0 commit comments

Comments
 (0)