Skip to content

Commit 9e63d43

Browse files
mergify[bot]981213
andauthored
mppi: return NO_INFORMATION when the checked point is outside the costmap (#3816) (#3818)
otherwise the controller crashes at ObstaclesCritic::costAtPose because x_i and y_i isn't initialized. (cherry picked from commit 6b250a7) Co-authored-by: Chuanhong Guo <[email protected]>
1 parent aaee5ae commit 9e63d43

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

nav2_mppi_controller/src/critics/obstacles_critic.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ CollisionCost ObstaclesCritic::costAtPose(float x, float y, float theta)
192192
float & cost = collision_cost.cost;
193193
collision_cost.using_footprint = false;
194194
unsigned int x_i, y_i;
195-
collision_checker_.worldToMap(x, y, x_i, y_i);
195+
if (!collision_checker_.worldToMap(x, y, x_i, y_i)) {
196+
cost = nav2_costmap_2d::NO_INFORMATION;
197+
return collision_cost;
198+
}
196199
cost = collision_checker_.pointCost(x_i, y_i);
197200

198201
if (consider_footprint_ && (cost >= possibly_inscribed_cost_ || possibly_inscribed_cost_ < 1)) {

0 commit comments

Comments
 (0)