Skip to content

Commit

Permalink
map-size restriction to avoid overflow and nullptr caused by user-mis…
Browse files Browse the repository at this point in the history
…configuration (#3242)

* odom alpha restriction

* odom alpha code style

* odom alpha code style

* odom alpha code style

* map-size restriction

* map-size code style

* map-size rejection

* map-size codestyle

* map-size return false
  • Loading branch information
Cryst4L9527 authored and SteveMacenski committed Nov 8, 2022
1 parent 28474a9 commit 079a717
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions nav2_costmap_2d/src/costmap_2d_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,27 @@ Costmap2DROS::dynamicParametersCallback(std::vector<rclcpp::Parameter> parameter
}
} else if (type == ParameterType::PARAMETER_INTEGER) {
if (name == "width") {
resize_map = true;
map_width_meters_ = parameter.as_int();
if (parameter.as_int() > 0) {
resize_map = true;
map_width_meters_ = parameter.as_int();
} else {
RCLCPP_ERROR(
get_logger(), "You try to set width of map to be negative or zero,"
" this isn't allowed, please give a positive value.");
result.successful = false;
return result;
}
} else if (name == "height") {
resize_map = true;
map_height_meters_ = parameter.as_int();
if (parameter.as_int() > 0) {
resize_map = true;
map_height_meters_ = parameter.as_int();
} else {
RCLCPP_ERROR(
get_logger(), "You try to set height of map to be negative or zero,"
" this isn't allowed, please give a positive value.");
result.successful = false;
return result;
}
}
} else if (type == ParameterType::PARAMETER_STRING) {
if (name == "footprint") {
Expand Down

0 comments on commit 079a717

Please sign in to comment.