Open xela-95 opened 4 days ago
I already encountered this problem in the past for similar reasons. Refer to:
In that occasion, I fixed only the RBDAs that I needed. In your case, there are other ones that fail for similar reasons. Can you try to apply something similar to the following to exclude running the scan call?
This can be added to https://github.com/ami-iit/jaxsim/pull/186
This can be added to #186
Probably it's time to merge that PR. We're already a bit further than what I define "minor changes", as it often happens :smile:
I already encountered this problem in the past for similar reasons. Refer to:
* [Add new test suite of functional APIs #106](https://github.com/ami-iit/jaxsim/pull/106) * [945f04b](https://github.com/ami-iit/jaxsim/commit/945f04b683c3519772ad4ec7bb916bacd4400a3f)
In that occasion, I fixed only the RBDAs that I needed. In your case, there are other ones that fail for similar reasons. Can you try to apply something similar to the following to exclude running the scan call?
Cool thanks, we had the intuition that a workaround something that was necessary, but we were a bit clueless. @xela-95 probably you can open a PR yourself with the fix proposed by @diegoferigo ?
Cool thanks, we had the intuition that a workaround something that was necessary, but we were a bit clueless. @xela-95 probably you can open a PR yourself with the fix proposed by @diegoferigo ?
Sure, I'll try to see if this fixes the issue and then open a PR :)
xref other jax issues:
The fix suggested by @diegoferigo is useful and may be useful for users finding related jax issues on search engines.
It's worth noting that (if I don't mistake) the fix works in our case only because the condition of the if
operates on a static element (following model, kin_dyn_parameters
, link_names). I fear that it won't work if the condition cannot be evaluated statically. In that case, using jax.lax.cond
might be necessary.
Most cases we saw were indeed due to model.number_of_links() > 1
(and probably went unnoticed as it is not so common to integrate a rigid body without joints).
Most cases we saw were indeed due to
model.number_of_links() > 1
(and probably went unnoticed as it is not so common to integrate a rigid body without joints).
We actually do support that, and single-body models are also part of our test suite (together with a fixed-based and a floating-base model). This went unnoticed because JIT is automatically enabled in tests, and JIT-compiled jax.lax.scan
do not complain if there is no actual iteration. They complain only if called either with JAX_DISABLE_JIT
or inside a jax.disable_jit
context.
Related issue on JAX: https://github.com/google/jax/issues/4668
The error is: