Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SceneGraphCollisionChecker Segfaults when Given NaNs #22586

Open
cohnt opened this issue Feb 4, 2025 · 2 comments
Open

SceneGraphCollisionChecker Segfaults when Given NaNs #22586

cohnt opened this issue Feb 4, 2025 · 2 comments
Assignees
Labels
component: geometry proximity Contact, distance, signed distance queries and related properties type: bug

Comments

@cohnt
Copy link
Contributor

cohnt commented Feb 4, 2025

What happened?

Not sure how this happened, but I was getting segfaults in some of my code, and eventually discovered it was due to passing nans into a SceneGraphCollisionChecker.

import numpy as np
from pydrake.all import (
    RobotDiagramBuilder,
    Parser,
    CollisionCheckerParams,
    SceneGraphCollisionChecker,
)

builder = RobotDiagramBuilder()

parser = Parser(builder.plant(), builder.scene_graph())
foo = parser.AddModelsFromUrl("package://drake_models/dishes/evo_bowl.sdf")
bar = parser.AddModelsFromUrl("package://drake_models/dishes/plate_8in.sdf")

diagram = builder.Build()

params = dict()
params["edge_step_size"] = 0.01
params["model"] = diagram
params["robot_model_instances"] = foo
cc = SceneGraphCollisionChecker(**params)

q = np.random.rand(14)
q[0] = np.nan
cc.CheckConfigCollisionFree(q)

Obviously, adding a quick check to complain if it gets nans should help the user. But notably, commenting out the bar = parser.AddModelsFromUrl... line makes it not segfault, so I'm suspicious that there's something going on in the scene graph behind the scenes that is segfaulting. And a backtrace shows something going on in the proximity engine as well.

#11 0x00007fffbeb69673 in drake::geometry::internal::ProximityEngine<double>::ComputeSignedDistancePairwiseClosestPoints(std::unordered_map<drake::geometry::GeometryId, drake::math::RigidTransform<double>, std::hash<drake::geometry::GeometryId>, std::equal_to<drake::geometry::GeometryId>, std::allocator<std::pair<drake::geometry::GeometryId const, drake::math::RigidTransform<double> > > > const&, double) const ()
   from /home/tommy/opt/rlg/drake-build/install/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#12 0x00007fffbef80c9c in drake::geometry::QueryObject<double>::ComputeSignedDistancePairwiseClosestPoints(double) const ()
   from /home/tommy/opt/rlg/drake-build/install/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#13 0x00007fffbffd418e in drake::planning::SceneGraphCollisionChecker::DoCheckContextConfigCollisionFree(drake::planning::CollisionCheckerContext const&) const () from /home/tommy/opt/rlg/drake-build/install/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so

Version

31989f3

What operating system are you using?

Ubuntu 22.04, Other

What installation option are you using?

compiled from source code using Bazel

Relevant log output

@cohnt cohnt added the type: bug label Feb 4, 2025
@jwnimmer-tri jwnimmer-tri added component: planning and control Optimization-based planning and control, and search- and sampling-based planning component: geometry proximity Contact, distance, signed distance queries and related properties and removed component: planning and control Optimization-based planning and control, and search- and sampling-based planning labels Feb 5, 2025
@jwnimmer-tri
Copy link
Collaborator

Even though the reproducer is SceneGraphCollisionChecker, I imagine that similar to #21219 (comment) the fundamental problem is that SceneGraph fails to check that the kinematics it's been given are finite, and hands the non-finite values down to FCL which explodes. I imagine the solution is to have SceneGraph fail-fast with an exception in this case, instead of segfaulting.

@SeanCurtis-TRI
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: geometry proximity Contact, distance, signed distance queries and related properties type: bug
Projects
None yet
Development

No branches or pull requests

3 participants