Skip to content

feat(examples): add ikine_XX timing columns to ik_speed.py - #654

Merged
petercorke merged 1 commit into
mainfrom
feat/ik-speed-3-column
Aug 26, 2026
Merged

feat(examples): add ikine_XX timing columns to ik_speed.py#654
petercorke merged 1 commit into
mainfrom
feat/ik-speed-3-column

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

Extends examples/ik_speed.py from a single ik_XX-only benchmark to three timing columns per method:

  • ik_XX — the existing fast, C-only solver (unchanged)
  • ikine_XX, C++ ETS — the pure-Python ikine_XX solver, with fkine/jacob0 evaluated via the normal C++-accelerated ETS
  • ikine_XX, pure Python ETS — the same ikine_XX solver, but with the ETS forced onto its pure-Python fallback (both the solver loop and every fkine/jacob0 call interpreted) -- what a pure-Python wheel / Pyodide build actually experiences

The pure-Python column uses 1,000 samples instead of 10,000 -- it's orders of magnitude slower per solve (confirmed by a small dry run: LM Sugihara alone projects to ~28 minutes at 1,000 samples with this script's existing k values, which I left unchanged).

Forcing the pure-Python ETS path required figuring out the right lever: robot.ets() returns a cached/memoized instance, so a fresh robot.ets() call doesn't help. Instead, roboticstoolbox.ets.fknm._C_AVAILABLE is patched to False and the existing ets's _fknm_stale flag is set, forcing its lazily-built C++ handle to rebuild as None on next access -- confirmed directly that ets._fknm becomes None and ikine_LM still works correctly against it.

Test plan

  • Dry run at reduced scale (200 / 20 samples) -- all three columns populate correctly, numbers are sensible (ik_XX fastest, ikine_XX/C++ in between, ikine_XX/pure-Python orders of magnitude slower)
  • Confirmed ets._fknm is None after the patch (via direct repr check) and reverts cleanly afterward
  • py_compile clean
  • Full 1,000-sample run not executed in this session (would take ~35-40 min) -- left for a real benchmark pass since the dry run already validates correctness

🤖 Generated with Claude Code

Extends the existing ik_XX-only benchmark to three columns per method:
the fast C-only ik_XX solver, ikine_XX with the normal C++-accelerated
ETS (fkine/jacobian in C++, only the solver loop interpreted), and
ikine_XX with the ETS forced onto its pure-Python fallback (both the
solver loop and fkine/jacobian interpreted, as in a pure-Python wheel
or Pyodide build).

The pure-Python column uses a much smaller sample count (1,000 vs
10,000) since it's orders of magnitude slower per solve. Forcing the
pure-Python ETS reuses the same cached ets instance rather than
building a new one (robot.ets() returns a memoized instance): patch
roboticstoolbox.ets.fknm._C_AVAILABLE to False and dirty the ets's
_fknm cache so it rebuilds without a C++ handle.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@petercorke
petercorke merged commit 2f41a71 into main Aug 26, 2026
17 checks passed
@petercorke
petercorke deleted the feat/ik-speed-3-column branch August 26, 2026 12:14
@github-actions github-actions Bot mentioned this pull request Aug 26, 2026
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (07a60f4) to head (f153011).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #654   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        143     143           
  Lines      14027   14050   +23     
=====================================
- Misses     14027   14050   +23     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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