Skip to content

Refactor dynamics parameters to use numba typed dict#168

Open
dhruvildarji wants to merge 1 commit intof1tenth:mainfrom
dhruvildarji:fix/dynamics-parameter-typing
Open

Refactor dynamics parameters to use numba typed dict#168
dhruvildarji wants to merge 1 commit intof1tenth:mainfrom
dhruvildarji:fix/dynamics-parameter-typing

Conversation

@dhruvildarji
Copy link
Copy Markdown

Summary

  • Replace individual float parameters (16+ args) in vehicle dynamics functions (vehicle_dynamics_ks, vehicle_dynamics_st, accl_constraints, steering_constraint) with a single numba.typed.Dict parameter
  • Add create_numba_params() helper to convert plain Python dicts to numba typed dicts
  • Simplify call sites in base_classes.py by passing self.numba_params instead of unpacking 16 individual self.params[...] values per call (5 call sites in RK4 + Euler integrator)
  • All existing unit tests pass with identical numerical results

Motivation

As noted in #157, the current approach of passing 16+ individual float parameters through every dynamics function call is verbose and error-prone. Using a numba typed dict:

  • Reduces function signature complexity from 18 args to 3 args
  • Makes it trivial to add new vehicle parameters without changing every function signature and call site
  • Maintains numba JIT compilation compatibility and performance (450k+ fps on dynamics step)

Test plan

  • All DynamicsTest unit tests pass (derivatives, zero-init roll/dec/acc/rollleft)
  • Performance benchmark: 450k+ fps (well above the 5000 fps threshold)
  • Numerical results match ground truth values exactly

Closes #157

Replace individual float parameters in vehicle dynamics functions with a
single numba.typed.Dict parameter. This simplifies function signatures,
reduces the boilerplate of unpacking 16+ parameters at every call site,
and makes it easier to add new parameters in the future.

Closes f1tenth#157

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Change typing of dynamics parameters

1 participant