@@ -294,31 +294,30 @@ nav_msgs::msg::Path SmacPlannerHybrid::createPlan(
294294 if (!costmap->worldToMap (start.pose .position .x , start.pose .position .y , mx, my)) {
295295 throw std::runtime_error (" Start pose is out of costmap!" );
296296 }
297- double orientation_bin = tf2::getYaw (start.pose .orientation ) / _angle_bin_size;
297+
298+ double orientation_bin = std::round (tf2::getYaw (start.pose .orientation ) / _angle_bin_size);
298299 while (orientation_bin < 0.0 ) {
299300 orientation_bin += static_cast <float >(_angle_quantizations);
300301 }
301302 // This is needed to handle precision issues
302303 if (orientation_bin >= static_cast <float >(_angle_quantizations)) {
303304 orientation_bin -= static_cast <float >(_angle_quantizations);
304305 }
305- unsigned int orientation_bin_id = static_cast <unsigned int >(floor (orientation_bin));
306- _a_star->setStart (mx, my, orientation_bin_id);
306+ _a_star->setStart (mx, my, static_cast <unsigned int >(orientation_bin));
307307
308308 // Set goal point, in A* bin search coordinates
309309 if (!costmap->worldToMap (goal.pose .position .x , goal.pose .position .y , mx, my)) {
310310 throw std::runtime_error (" Goal pose is out of costmap!" );
311311 }
312- orientation_bin = tf2::getYaw (goal.pose .orientation ) / _angle_bin_size;
312+ orientation_bin = std::round ( tf2::getYaw (goal.pose .orientation ) / _angle_bin_size) ;
313313 while (orientation_bin < 0.0 ) {
314314 orientation_bin += static_cast <float >(_angle_quantizations);
315315 }
316316 // This is needed to handle precision issues
317317 if (orientation_bin >= static_cast <float >(_angle_quantizations)) {
318318 orientation_bin -= static_cast <float >(_angle_quantizations);
319319 }
320- orientation_bin_id = static_cast <unsigned int >(floor (orientation_bin));
321- _a_star->setGoal (mx, my, orientation_bin_id);
320+ _a_star->setGoal (mx, my, static_cast <unsigned int >(orientation_bin));
322321
323322 // Setup message
324323 nav_msgs::msg::Path plan;
0 commit comments