Created
September 2, 2025 14:25
-
-
Save jwnimmer-tri/7d2a627f351a0925062df6a5822a125d to your computer and use it in GitHub Desktop.
make_collision_checker.py example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def MakeCollisionChecker(*, model_urls: list[str]) -> SceneGraphCollisionChecker: | |
model_builder = RobotDiagramBuilder() | |
model_builder.parser().package_map().AddMap(...) | |
for url in model_urls: | |
model_builder.parser().AddModelsFromUrl(url) | |
# Identify model instances belonging to the robot. | |
known_robot_model_instance_names = [ | |
"left::panda", | |
# "..." | |
] | |
robot_models = [ | |
model_builder.plant().GetModelInstanceByName(name) | |
for name in known_robot_model_instance_names | |
if model_builder.plant().HasModelInstanceNamed(name) | |
] | |
# Create the collision checker around the model. | |
model = model_builder.Build() | |
checker_params = CollisionCheckerParams( | |
model=model, | |
robot_model_instances=robot_models, | |
edge_step_size=0.05, | |
env_collision_padding=0.0, | |
self_collision_padding=0.0, | |
implicit_context_parallelism=False, | |
# We explicitly request the default C-space distance function. We're | |
# not doing edge queries, so the default is fine. | |
distance_and_interpolation_provider=None, | |
) | |
return SceneGraphCollisionChecker(checker_params) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment