You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix plotting in moveit_benchmark_statistics.py and re-enable --plot - #4003
moveit_benchmark_statistics.py --plot has been disabled with TODO(sjahr): This is currently broken and needs to be fixed. I ran plotStatistics() on a log written in the BenchmarkExecutor::writeOutput format. Depending on the matplotlib version, it fails in one of two places, and a third bug crashes the summary page:
BOOLEAN plots (all versions): MoveIt logs booleans as "true"/"false", which SQLite stores as text, so sum(m) raises TypeError: unsupported operand type(s) for +: 'int' and 'str'. Added isTrue(), which accepts both MoveIt's true/false and OMPL's 1/0.
Box plots (matplotlib ≥ 3.8): XTick.label was removed, giving AttributeError: 'XTick' object has no attribute 'label'. Switched to label1, which also exists in older versions.
Summary page: when planners have different run counts (for example, after a crash), ",".join(numRuns) is called on ints and raises TypeError, and %d would also fail on the joined string. It now prints the distinct counts, e.g. Number of averaged runs: 7, 10.
I also:
dropped vert=1 from boxplot (vertical is the default; the argument is deprecated in matplotlib 3.11 and removed in 3.13),
re-enabled the --plot option,
added python3-matplotlib and python3-numpy as exec_depends, since the script imports both at module level but package.xml didn't declare them,
added test/test_moveit_benchmark_statistics.py, registered with ament_add_pytest_test. It writes a small log in the writeOutput format, with a failed run and uneven run counts, and checks isTrue, the BOOLEAN bar percentages, and that plotStatistics writes a PDF. All 3 tests fail without this PR.
Tested with matplotlib 3.6.3 (Ubuntu 24.04, Jazzy/Rolling) and 3.11.2 (latest):
the full CLI (-d ... -p plots.pdf benchmark.log) produces a 9-page PDF on both, with no warnings from the script itself,
the new tests pass on both and fail on main,
colcon test --packages-select moveit_ros_benchmarks runs the new test (3 passed).
Formatting: black 25.1.0, codespell 2.4.1 (with .codespell_words) and cmake-format 0.6.13 are clean.
Not changed, but noticed while testing: in readBenchmarkLog, the all_experiments entry sets memorylimit and timelimit from totaltime (lines ~214–219), so its summary page shows the total collection time as both limits. I can send a separate fix if wanted.
Checklist
[x] Required by CI: Code is auto formatted using clang-format
[ ] Extend the tutorials / documentation reference
[ ] Document API changes relevant to the user in the MIGRATION.md notes
[x] Create tests, which fail without this PR reference
[ ] Include a screenshot if changing a GUI
[ ] While waiting for someone to review your request, please help review another open pull request to support the maintainers
Summary by CodeRabbit
Bug Fixes
Benchmark statistics now recognize common boolean values consistently and calculate boolean percentages using only runs that report each attribute.
Experiment summaries now show all distinct run counts, sorted and separated by commas.
The --plot option now generates benchmark charts in a PDF.
No actionable comments were generated in the recent review.
Walkthrough
The benchmark statistics script now normalizes boolean values for plot percentages, updates plot output behavior, displays sorted distinct run counts, and invokes plotting when requested. The package adds plotting and test dependencies, registers a pytest test, and includes tests for the updated behavior.
Changes: Benchmark statistics
Layer / File(s)
Summary
Boolean statistics and tests moveit_ros/benchmarks/scripts/moveit_benchmark_statistics.py, moveit_ros/benchmarks/test/test_moveit_benchmark_statistics.py, moveit_ros/benchmarks/CMakeLists.txt
isTrue accepts stripped, case-insensitive "1" and "true" values. Boolean plot percentages use this conversion. Tests cover conversion and percentage calculations, and CMake registers the test module.
Plot output and run-count summaries moveit_ros/benchmarks/package.xml, moveit_ros/benchmarks/scripts/moveit_benchmark_statistics.py, moveit_ros/benchmarks/test/test_moveit_benchmark_statistics.py
The script updates box-plot and tick-label arguments, displays sorted distinct run counts, and calls plotStatistics when --plot is set. The manifest adds plotting dependencies, and a test checks PDF output.
This change restores plotting in the benchmark statistics script and adds tests and dependency declarations. No concrete merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the two main changes in the PR: fixing plotting in moveit_benchmark_statistics.py and re-enabling the --plot option. The raw summary confirms both: boolean parsing and tick-label fixes…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the two main changes in the PR: fixing plotting in moveit_benchmark_statistics.py and re-enabling the --plot option. The raw summary confirms both: boolean parsing and tick-label fixes restore plotting, and the CLI now calls plotting when --plot is supplied. The title is specific and does not include file lists or vague terms.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.
Queue this pull request once it meets the queue conditions
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
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.
Description
moveit_benchmark_statistics.py --plot has been disabled with TODO(sjahr): This is currently broken and needs to be fixed. I ran plotStatistics() on a log written in the BenchmarkExecutor::writeOutput format. Depending on the matplotlib version, it fails in one of two places, and a third bug crashes the summary page:
BOOLEAN plots (all versions): MoveIt logs booleans as "true"/"false", which SQLite stores as text, so sum(m) raises TypeError: unsupported operand type(s) for +: 'int' and 'str'. Added isTrue(), which accepts both MoveIt's true/false and OMPL's 1/0.
Box plots (matplotlib ≥ 3.8): XTick.label was removed, giving AttributeError: 'XTick' object has no attribute 'label'. Switched to label1, which also exists in older versions.
Summary page: when planners have different run counts (for example, after a crash), ",".join(numRuns) is called on ints and raises TypeError, and %d would also fail on the joined string. It now prints the distinct counts, e.g. Number of averaged runs: 7, 10.
I also:
dropped vert=1 from boxplot (vertical is the default; the argument is deprecated in matplotlib 3.11 and removed in 3.13),
re-enabled the --plot option,
added python3-matplotlib and python3-numpy as exec_depends, since the script imports both at module level but package.xml didn't declare them,
added test/test_moveit_benchmark_statistics.py, registered with ament_add_pytest_test. It writes a small log in the writeOutput format, with a failed run and uneven run counts, and checks isTrue, the BOOLEAN bar percentages, and that plotStatistics writes a PDF. All 3 tests fail without this PR.
Tested with matplotlib 3.6.3 (Ubuntu 24.04, Jazzy/Rolling) and 3.11.2 (latest):
the full CLI (-d ... -p plots.pdf benchmark.log) produces a 9-page PDF on both, with no warnings from the script itself,
the new tests pass on both and fail on main,
colcon test --packages-select moveit_ros_benchmarks runs the new test (3 passed).
Formatting: black 25.1.0, codespell 2.4.1 (with .codespell_words) and cmake-format 0.6.13 are clean.
Not changed, but noticed while testing: in readBenchmarkLog, the all_experiments entry sets memorylimit and timelimit from totaltime (lines ~214–219), so its summary page shows the total collection time as both limits. I can send a separate fix if wanted.
Checklist
[x] Required by CI: Code is auto formatted using clang-format
[ ] Extend the tutorials / documentation reference
[ ] Document API changes relevant to the user in the MIGRATION.md notes
[x] Create tests, which fail without this PR reference
[ ] Include a screenshot if changing a GUI
[ ] While waiting for someone to review your request, please help review another open pull request to support the maintainers
Summary by CodeRabbit
--plotoption now generates benchmark charts in a PDF.