Skip to content

Fix plotting in moveit_benchmark_statistics.py and re-enable --plot - #4003

Open
vishwagw wants to merge 5 commits into
moveit:mainfrom
vishwagw:fix/plotstatistics
Open

vishwagw wants to merge 5 commits into
moveit:mainfrom
vishwagw:fix/plotstatistics

Conversation

@vishwagw

@vishwagw vishwagw commented Nov 27, 2026 •

Copy link
Copy Markdown

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

  • 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.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: sjahr, julienking, nbbrooks

Merge Risk: Minimal · up to 14c47

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: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5399d29 and 14c4793.

Files selected for processing: 4

  • moveit_ros/benchmarks/CMakeLists.txt
  • moveit_ros/benchmarks/package.xml
  • moveit_ros/benchmarks/scripts/moveit_benchmark_statistics.py
  • moveit_ros/benchmarks/test/test_moveit_benchmark_statistics.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@mergify

mergify Bot commented Nov 27, 2026

Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant