-
Notifications
You must be signed in to change notification settings - Fork 52
Add Benchmarks for RRT #67
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 all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d161e3d
Add pytest-benchmark
eholum 6d14db0
Add RRT benchmarks
eholum a80ef97
Ensure RRT benchmarks are succeeding at a reasonable rate
eholum 16ae8c3
Add CI for benchmarks
eholum 59b9048
Benchmarking as its own file for now
eholum 97dd1fe
Save benchmarks with pixi task
eholum 709c6d6
No comparisons for now
eholum 3acf91e
No persistance check
eholum 1a30f91
Make it a todo and ask sea-bass
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,6 @@ | |
| # pixi environments | ||
| .pixi | ||
| *.egg-info | ||
|
|
||
| # Benchmarking results | ||
| pytest_benchmarks.json | ||
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,95 @@ | ||
| import pytest | ||
| import sys | ||
| import xacro | ||
|
|
||
| from roboplan import ( | ||
| JointConfiguration, | ||
| Scene, | ||
| RRTOptions, | ||
| RRT, | ||
| ) | ||
|
|
||
| # We don't build the bindings examples, so we just include the relative | ||
| # directory manually. | ||
| from pathlib import Path | ||
|
|
||
| examples_dir = Path(__file__).parent.parent / "bindings" / "examples" | ||
| sys.path.insert(0, str(examples_dir)) | ||
|
|
||
| from common import MODELS, ROBOPLAN_EXAMPLES_DIR | ||
|
|
||
|
|
||
| def solve(scene: Scene, rrt: RRT, seed: int = 1234): | ||
| """ | ||
| Runs an RRT test by sampling random, collision-free joint configurations | ||
| then attempting to plan a path between them. | ||
|
|
||
| Returns 1 if planning was successful, 0 otherwise. | ||
| """ | ||
| scene.setRngSeed(seed) | ||
|
|
||
| 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) | ||
| return 0 if path is None else 1 | ||
|
|
||
|
|
||
| def solve_many(scene: Scene, rrt: RRT, iterations: int = 10): | ||
| """ | ||
| Runs the specified number of iterations of RRT with a random seed. | ||
|
|
||
| Returns the number of successful solves. | ||
| """ | ||
| successes = 0 | ||
| for i in range(iterations): | ||
| successes += solve(scene, rrt, 11235 + i) | ||
| return successes | ||
|
|
||
|
|
||
| def create_scene(model_name: str) -> Scene: | ||
| model_data = MODELS[model_name] | ||
| package_paths = [ROBOPLAN_EXAMPLES_DIR] | ||
|
|
||
| urdf_xml = xacro.process_file(model_data.urdf_path).toxml() | ||
| srdf_xml = xacro.process_file(model_data.srdf_path).toxml() | ||
|
|
||
| scene = Scene( | ||
| f"{model_name}_benchmark_scene", | ||
| urdf=urdf_xml, | ||
| srdf=srdf_xml, | ||
| package_paths=package_paths, | ||
| yaml_config_path=model_data.yaml_config_path, | ||
| ) | ||
| return scene | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session", params=["kinova", "ur5", "franka", "dual"]) | ||
| def scene(request): | ||
| return create_scene(request.param) | ||
|
|
||
|
|
||
| def test_benchmark_rrt(benchmark, scene): | ||
| options = RRTOptions() | ||
| options.max_nodes = 100000 | ||
| options.max_planning_time = 10.0 | ||
| rrt = RRT(scene, options) | ||
|
|
||
| success_rate = benchmark(solve_many, scene, rrt, 10) | ||
| assert success_rate >= 0.95 | ||
|
|
||
|
|
||
| def test_benchmark_rrt_connect(benchmark, scene): | ||
| options = RRTOptions() | ||
| options.max_nodes = 100000 | ||
| options.rrt_connect = True | ||
| options.max_planning_time = 10.0 | ||
| rrt = RRT(scene, options) | ||
|
|
||
| success_rate = benchmark(solve_many, scene, rrt, 10) | ||
| assert success_rate >= 0.95 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've played around with, but haven't actually connected, two options here for continuous benchmark monitoring (assuming we want this)...
https://github.com/benchmark-action/github-action-benchmark, which can store benchmarking results in gh-pages. It'll be a little annoying to configure so if we go this route it's probably easier to just wait until the repo is public. On the plus side we wouldn't need a separate app and it supports more benchmarking suites out of the box. On the down side it's more to configure.
https://github.com/CodSpeedHQ/action, third part app to which benchmarking results are uploaded and are viewable on their dashboard. It's pretty easy to setup and use but requires granting access to our repo.
Thoughts? Or do we just want the benchmarks in place and then can come back to this later and rely on checking manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sample output here.
https://github.com/open-planning/roboplan/actions/runs/18103021233/job/51510609862?pr=67#step:6:27
If this is enough for now then we can call it enough for now...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think waiting for the repo to be public is good for me. We can just make this a non-required check for now.
As for 1 or 2, I think whichever is easier tbh