Skip to content

Commit

Permalink
Also include self-collisions to make RRT look nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-bass committed Apr 5, 2024
1 parent 9b3d996 commit 3b1199a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
32 changes: 32 additions & 0 deletions examples/example_rrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,38 @@
def prepare_scene(visual_model, collision_model):
"""Helper function to create a collision scene for this example."""

# Add self collisions
self_collision_pair_names = [
("panda_link0_0", "panda_link2_0"),
("panda_link0_0", "panda_link3_0"),
("panda_link0_0", "panda_link4_0"),
("panda_link0_0", "panda_link5_0"),
("panda_link0_0", "panda_link6_0"),
("panda_link0_0", "panda_link7_0"),
("panda_link1_0", "panda_link3_0"),
("panda_link1_0", "panda_link4_0"),
("panda_link1_0", "panda_link5_0"),
("panda_link1_0", "panda_link6_0"),
("panda_link1_0", "panda_link7_0"),
("panda_link2_0", "panda_link4_0"),
("panda_link2_0", "panda_link5_0"),
("panda_link2_0", "panda_link6_0"),
("panda_link2_0", "panda_link7_0"),
("panda_link3_0", "panda_link5_0"),
("panda_link3_0", "panda_link6_0"),
("panda_link3_0", "panda_link7_0"),
("panda_link4_0", "panda_link6_0"),
("panda_link4_0", "panda_link7_0"),
("panda_link5_0", "panda_link7_0"),
]
for pair in self_collision_pair_names:
collision_model.addCollisionPair(
pinocchio.CollisionPair(
collision_model.getGeometryId(pair[0]),
collision_model.getGeometryId(pair[1]),
)
)

# Add collision objects
ground_plane = pinocchio.GeometryObject(
"ground_plane",
Expand Down
6 changes: 3 additions & 3 deletions src/pyroboplan/planning/rrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ def plan(self, q_start, q_goal, options=RRTPlannerOptions()):
):
goal_found = True

# Switch to the other tree
if options.bidirectional_rrt:
start_tree_phase = not start_tree_phase
# Switch to the other tree next iteration, if bidirectional mode is enabled.
if options.bidirectional_rrt:
start_tree_phase = not start_tree_phase

# Back out the path by traversing the parents from the goal.
self.latest_path = []
Expand Down

0 comments on commit 3b1199a

Please sign in to comment.