-
-
Notifications
You must be signed in to change notification settings - Fork 626
Benchmark RNE
RTB ships three implementations of inverse dynamics (RNE — Recursive Newton-Euler): a compiled C extension (rne), a pure-Python port of the same algorithm (rne_python), and a generic Featherstone-style implementation built on spatialmath's SE3/SpatialForce classes (Robot.rne, used by URDF/ETS-based robots that aren't DHRobots). examples/benchmark_rne.py checks that all three agree, and times them against each other.
python examples/benchmark_rne.py
No arguments. It uses rtb.models.DH.Panda() (7-DOF, mdh=True) — a robot all three implementations genuinely apply to; see the script's own docstring for why plain DH robots like Puma560 are excluded (Robot.rne() structurally requires joint-last ETS segments, true for MDH DHRobots, not standard DH). A companion script, examples/rne_compare.py, demonstrates that exclusion directly on Puma560.
CPU: Apple M1 (8 cores), 3204 MHz
Robot: Panda (n=7, mdh=True)
Correctness (single random pose):
max|C - rne_python| = 7.105e-15
max|C - Robot.rne| = 5.329e-15
max|rne_python - Robot.rne| = 3.553e-15
Timing over a 1000-row trajectory (distinct random poses, not tiled):
┌──────────────────────────┬─────────────┬────────────────────┬────────┬─────────────────────┐
│ Method │ 1 pose (us) │ 1000-row traj (ms) │ us/row │ speedup vs C (traj) │
├──────────────────────────┼─────────────┼────────────────────┼────────┼─────────────────────┤
│ C extension (rne) │ 10.58 │ 0.933 │ 0.93 │ 1.0x │
│ pure Python (rne_python) │ 580.04 │ 539.296 │ 539.30 │ 578.1x │
│ generic Robot.rne │ 1141.08 │ 885.169 │ 885.17 │ 948.9x │
└──────────────────────────┴─────────────┴────────────────────┴────────┴─────────────────────┘
All three agree to within machine precision (~1e-14) at every pose. The compiled C extension is roughly 3 orders of magnitude faster than either Python implementation — expected, since it does the whole trajectory in a single C++ call rather than one Python-level RNE pass per row. Exact numbers depend on the machine; re-run the script for your own hardware.
- Frequently asked questions (FAQ)
- Documentation Style Guide
- Background
- Key concepts
- Introduction to robot and link classes
- Working with Jupyter
- Working from the command line
- What about Simulink?
- How to contribute
- Contributors
- Coding conventions