Skip to content

Commit

Permalink
Add more semantic checks for amcl parameters (#2528)
Browse files Browse the repository at this point in the history
* Fix null pointer in amcl on_cleanup

* Add more semantic checks for amcl
  • Loading branch information
zouyonghao authored and SteveMacenski committed Sep 14, 2021
1 parent cbfe97e commit 9dab8be
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions nav2_amcl/src/amcl_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,25 @@ AmclNode::initParameters()
last_time_printed_msg_ = now();

// Semantic checks
if (laser_likelihood_max_dist_ < 0) {
RCLCPP_WARN(
get_logger(), "You've set laser_likelihood_max_dist to be negtive,"
" this isn't allowed so it will be set to default value 2.0.");
laser_likelihood_max_dist_ = 2.0;
}
if (max_particles_ < 0) {
RCLCPP_WARN(
get_logger(), "You've set max_particles to be negtive,"
" this isn't allowed so it will be set to default value 2000.");
max_particles_ = 2000;
}

if (min_particles_ < 0) {
RCLCPP_WARN(
get_logger(), "You've set min_particles to be negtive,"
" this isn't allowed so it will be set to default value 500.");
min_particles_ = 500;
}

if (min_particles_ > max_particles_) {
RCLCPP_WARN(
Expand Down

0 comments on commit 9dab8be

Please sign in to comment.