Skip to content

Commit fbdf753

Browse files
authored
Fix seg fault (#5501)
* Fix segmentation fault Signed-off-by: Tony Najjar <[email protected]> * fix linting Signed-off-by: Tony Najjar <[email protected]> --------- Signed-off-by: Tony Najjar <[email protected]>
1 parent 15604f2 commit fbdf753

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

nav2_smac_planner/src/node_lattice.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ bool NodeLattice::isNodeValid(
230230
// Check primitive end pose
231231
// Convert grid quantization of primitives to radians, then collision checker quantization
232232
static const double bin_size = 2.0 * M_PI / collision_checker->getPrecomputedAngles().size();
233-
const double & angle = motion_table.getAngleFromBin(this->pose.theta) / bin_size;
233+
const double angle = std::fmod(motion_table.getAngleFromBin(this->pose.theta),
234+
2.0 * M_PI) / bin_size;
234235
if (collision_checker->inCollision(
235236
this->pose.x, this->pose.y, angle /*bin in collision checker*/, traverse_unknown))
236237
{
@@ -269,7 +270,7 @@ bool NodeLattice::isNodeValid(
269270
if (is_backwards) {
270271
prim_pose._theta = std::fmod(it->_theta + M_PI, 2.0 * M_PI);
271272
} else {
272-
prim_pose._theta = it->_theta;
273+
prim_pose._theta = std::fmod(it->_theta, 2.0 * M_PI);
273274
}
274275
if (collision_checker->inCollision(
275276
prim_pose._x,

0 commit comments

Comments
 (0)