-
Notifications
You must be signed in to change notification settings - Fork 52
Add path shortening utils and consolidate examples #33
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
Merged
Merged
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
2b1a1a4
Add functions for path shortening
eholum c0932ed
Start adding unit tests for path shortcutting
eholum f1337ba
Update roboplan/src/core/path_utils.cpp
eholum 2d07f7a
Eigen, right.
eholum 3863ce7
Make path shortening actually work
eholum 546c0bb
Seed path shortcutting
eholum c1f9410
Never shortcut the start
eholum 2a2a23a
Add python bindings
eholum ac46894
Weird timeouts when connecting through ssh in the vizer viz
eholum 530abc1
Add path shortcutting example
eholum c6fe78d
Update bindings/src/roboplan/viser_visualizer.py
eholum e36d4e1
Tweak RRT params for path shortening
eholum aebffd9
Merge branch 'main' into path-shortening
eholum 5f7d2e5
Separate tree and path rendering
eholum d9116e1
Add path shortcutting to existing RRT demos
eholum 2ecd997
0 is a valid seed
eholum ed53e17
Minor viz tweaks
eholum 562a806
Add tyro as a dep and install in containers
eholum 3a6082e
Consolidate RRT examples with tyro
eholum 86d29d1
Generalize the IK example
eholum 8bf6e97
Add comment
eholum 795f377
Unused params
eholum 0742a16
pin typing_extensions
eholum fef1552
Install tyro with the other bindings deps
eholum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| from pathlib import Path | ||
| from roboplan import get_package_share_dir | ||
|
|
||
|
|
||
| ROBOPLAN_EXAMPLES_DIR = Path(get_package_share_dir()) | ||
|
|
||
| # Dictionary of supported example models and their relevant parameters. | ||
| # Entries are a list of: | ||
| # - The URDF path. | ||
| # - The SRDF path. | ||
| # - The end-effector name. | ||
| # - The robot's base link. | ||
| # - The starting "pose" of the robot. | ||
| MODELS = { | ||
| "ur5": [ | ||
| ROBOPLAN_EXAMPLES_DIR / "ur_robot_model" / "ur5_gripper.urdf", | ||
| ROBOPLAN_EXAMPLES_DIR / "ur_robot_model" / "ur5_gripper.srdf", | ||
| "tool0", | ||
| "base", | ||
| [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], | ||
| ], | ||
| "franka": [ | ||
| ROBOPLAN_EXAMPLES_DIR / "franka_robot_model" / "fr3.urdf", | ||
| ROBOPLAN_EXAMPLES_DIR / "franka_robot_model" / "fr3.srdf", | ||
| "fr3_hand", | ||
| "fr3_link0", | ||
| [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], | ||
| ], | ||
| } |
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
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import sys | ||
| import time | ||
| import tyro | ||
|
|
||
| import pinocchio as pin | ||
| from common import MODELS, ROBOPLAN_EXAMPLES_DIR | ||
| from roboplan import ( | ||
| shortcutPath, | ||
| JointConfiguration, | ||
| Scene, | ||
| RRTOptions, | ||
| RRT, | ||
| ) | ||
| from roboplan.viser_visualizer import ViserVisualizer, visualizePath, visualizeTree | ||
|
|
||
|
|
||
| def main( | ||
| model: str = "ur5", | ||
| max_connection_distance: float = 1.0, | ||
| collision_check_step_size: float = 0.05, | ||
| goal_biasing_probability: float = 0.15, | ||
| max_nodes: int = 1000, | ||
| max_planning_time: float = 3.0, | ||
| rrt_connect: bool = False, | ||
| include_shortcutting: bool = False, | ||
| host: str = "localhost", | ||
| port: str = "8000", | ||
| ): | ||
| """ | ||
| Run the RRT example with the provided parameters. | ||
|
|
||
|
|
||
| Parameters: | ||
| model: The name of the model to user (ur5 or franka). | ||
| max_connection_distance: Maximum connection distance between two search nodes. | ||
| collision_check_step_size: Configuration-space step size for collision checking along edges. | ||
| goal_biasing_probability: Weighting of the goal node during random sampling. | ||
| max_nodes: The maximum number of nodes to add to the search tree. | ||
| max_planning_time: The maximum time (in seconds) to search for a path. | ||
| rrt_connect: Whether or not to use RRT-Connect. | ||
| include_shortcutting: Whether or not to include path shortcutting for found paths. | ||
| host: The host for the ViserVisualizer. | ||
| port: The port for the ViserVisualizer. | ||
| """ | ||
|
|
||
| if model not in MODELS: | ||
| print(f"Invalid model requested: {model}") | ||
| sys.exit(1) | ||
|
|
||
| urdf_path, srdf_path, ee_name, _, _ = MODELS[model] | ||
| package_paths = [ROBOPLAN_EXAMPLES_DIR] | ||
|
|
||
| scene = Scene("test_scene", urdf_path, srdf_path, package_paths) | ||
|
|
||
| # Create a redundant Pinocchio model just for visualization. | ||
| # When Pinocchio 4.x releases nanobind bindings, we should be able to directly grab the model from the scene instead. | ||
| model, collision_model, visual_model = pin.buildModelsFromUrdf( | ||
| urdf_path, package_dirs=package_paths | ||
| ) | ||
| viz = ViserVisualizer(model, collision_model, visual_model) | ||
| viz.initViewer(open=True, loadModel=True, host=host, port=port) | ||
|
|
||
| # Optionally include path shortening | ||
| include_shortcutting = True | ||
|
|
||
| # Set up an RRT and perform path planning. | ||
| options = RRTOptions() | ||
| options.max_connection_distance = max_connection_distance | ||
| options.collision_check_step_size = collision_check_step_size | ||
| options.goal_biasing_probability = goal_biasing_probability | ||
| options.max_nodes = max_nodes | ||
| options.max_planning_time = max_planning_time | ||
| options.rrt_connect = rrt_connect | ||
| rrt = RRT(scene, options) | ||
|
|
||
| start = JointConfiguration() | ||
| start.positions = scene.randomCollisionFreePositions() | ||
| assert start.positions is not None | ||
|
|
||
| goal = JointConfiguration() | ||
| goal.positions = scene.randomCollisionFreePositions() | ||
| assert goal.positions is not None | ||
|
|
||
| path = rrt.plan(start, goal) | ||
| assert path is not None | ||
|
|
||
| if include_shortcutting: | ||
| shortcut_path = shortcutPath( | ||
| scene, path, options.collision_check_step_size, 1000 | ||
| ) | ||
|
|
||
| # Visualize the tree and path | ||
| print(path) | ||
| viz.display(start.positions) | ||
| visualizePath(viz, scene, path, ee_name, 0.05) | ||
| visualizeTree(viz, scene, rrt, ee_name, 0.05) | ||
|
|
||
| if include_shortcutting: | ||
| print("Shortcutted path:") | ||
| print(shortcut_path) | ||
| visualizePath( | ||
| viz, scene, shortcut_path, ee_name, 0.05, (0, 100, 0), "/rrt/shortcut_path" | ||
| ) | ||
|
|
||
| try: | ||
| while True: | ||
| time.sleep(10.0) | ||
| except KeyboardInterrupt: | ||
| pass | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| tyro.cli(main) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.