Skip to content

Commit b3efe17

Browse files
nav2_costmap_2d: static_layer: add grid value interpretation for inscribed inflated obstacles
Until now, the special OccupancyGrid value "99" attributed to the inscribed inflated obstacles was mapped to 251 on conversion to Costmap2D, using the default linear relation. This is incorrect since a special value exists in the Costmap2D for inscribed obstacles: 253. This commit makes sure that the correct value is used in case of inflated obstacle. Signed-off-by: Dylan De Coeyer <[email protected]>
1 parent 9ed832e commit b3efe17

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

nav2_costmap_2d/include/nav2_costmap_2d/static_layer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ class StaticLayer : public CostmapLayer
201201
bool track_unknown_space_;
202202
bool use_maximum_;
203203
unsigned char lethal_threshold_;
204+
unsigned char inscribed_obstacle_cost_value_;
204205
unsigned char unknown_cost_value_;
205206
bool trinary_costmap_;
206207
bool map_received_{false};

nav2_costmap_2d/plugins/static_layer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ PLUGINLIB_EXPORT_CLASS(nav2_costmap_2d::StaticLayer, nav2_costmap_2d::Layer)
5353

5454
using nav2_costmap_2d::NO_INFORMATION;
5555
using nav2_costmap_2d::LETHAL_OBSTACLE;
56+
using nav2_costmap_2d::INSCRIBED_INFLATED_OBSTACLE;
5657
using nav2_costmap_2d::FREE_SPACE;
5758
using rcl_interfaces::msg::ParameterType;
5859

@@ -157,6 +158,7 @@ StaticLayer::getParameters()
157158
node->get_parameter("track_unknown_space", track_unknown_space_);
158159
node->get_parameter("use_maximum", use_maximum_);
159160
node->get_parameter("lethal_cost_threshold", temp_lethal_threshold);
161+
node->get_parameter("inscribed_obstacle_cost_value", inscribed_obstacle_cost_value_);
160162
node->get_parameter("unknown_cost_value", unknown_cost_value_);
161163
node->get_parameter("trinary_costmap", trinary_costmap_);
162164
node->get_parameter("transform_tolerance", temp_tf_tol);
@@ -267,6 +269,8 @@ StaticLayer::interpretValue(unsigned char value)
267269
return NO_INFORMATION;
268270
} else if (!track_unknown_space_ && value == unknown_cost_value_) {
269271
return FREE_SPACE;
272+
} else if (value == inscribed_obstacle_cost_value_) {
273+
return INSCRIBED_INFLATED_OBSTACLE;
270274
} else if (value >= lethal_threshold_) {
271275
return LETHAL_OBSTACLE;
272276
} else if (trinary_costmap_) {

nav2_costmap_2d/src/costmap_2d_ros.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ void Costmap2DROS::init()
131131
declare_parameter("initial_transform_timeout", rclcpp::ParameterValue(60.0));
132132
declare_parameter("trinary_costmap", rclcpp::ParameterValue(true));
133133
declare_parameter("unknown_cost_value", rclcpp::ParameterValue(static_cast<unsigned char>(0xff)));
134+
declare_parameter("inscribed_obstacle_cost_value", rclcpp::ParameterValue(99));
134135
declare_parameter("update_frequency", rclcpp::ParameterValue(5.0));
135136
declare_parameter("use_maximum", rclcpp::ParameterValue(false));
136137
declare_parameter("subscribe_to_stamped_footprint", rclcpp::ParameterValue(false));

0 commit comments

Comments
 (0)