@@ -287,7 +287,9 @@ nav_msgs::msg::Path SmacPlannerHybrid::createPlan(
287287
288288 // Set starting point, in A* bin search coordinates
289289 unsigned int mx, my;
290- costmap->worldToMap (start.pose .position .x , start.pose .position .y , mx, my);
290+ if (!costmap->worldToMap (start.pose .position .x , start.pose .position .y , mx, my)) {
291+ throw std::runtime_error (" Start pose is out of costmap!" );
292+ }
291293 double orientation_bin = tf2::getYaw (start.pose .orientation ) / _angle_bin_size;
292294 while (orientation_bin < 0.0 ) {
293295 orientation_bin += static_cast <float >(_angle_quantizations);
@@ -300,7 +302,9 @@ nav_msgs::msg::Path SmacPlannerHybrid::createPlan(
300302 _a_star->setStart (mx, my, orientation_bin_id);
301303
302304 // Set goal point, in A* bin search coordinates
303- costmap->worldToMap (goal.pose .position .x , goal.pose .position .y , mx, my);
305+ if (!costmap->worldToMap (goal.pose .position .x , goal.pose .position .y , mx, my)) {
306+ throw std::runtime_error (" Goal pose is out of costmap!" );
307+ }
304308 orientation_bin = tf2::getYaw (goal.pose .orientation ) / _angle_bin_size;
305309 while (orientation_bin < 0.0 ) {
306310 orientation_bin += static_cast <float >(_angle_quantizations);
0 commit comments