ami-iit / jaxsim

A differentiable physics engine and multibody dynamics library for control and robot learning.
https://jaxsim.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
69 stars 10 forks source link

Validate link, frame, and joint indices in our jit-compiled APIs #182

Closed diegoferigo closed 3 months ago

diegoferigo commented 3 months ago

Implements the jit-compatible exceptions of #181 to stop the execution of jit-compiled methods when the integer indices of links, frames, and joints are not valid.


📚 Documentation preview 📚: https://jaxsim--182.org.readthedocs.build//182/

diegoferigo commented 3 months ago

That's great, thanks! Does it have any concrete effect on the performances?

Not really, the modified methods are not called a lot. I don't expect any runtime overhead since the extra branch injected for raising the exception is never called, and the only overhead is a boolean comparison that has almost no cost.

Inspecting the time taken by CI, there's no significant change. It takes 15-20 seconds more on average but this is also because this PR introduces a new test.

diegoferigo commented 3 months ago

In any case, if we face any overhead in the future that we want to get rid of, we can introduce a new environment variable that disables raising exceptions within jit-compiled function. It should be straightforward.