Fix running AD through jaxsim.math.Rotation.from_axis_angle
#277
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In these days, I tried to solve an unconstrained non-linear optimization problem using the JaxSim functions to construct the cost function. I used the
L-BFGS
solver from optax, and it works flawlessly 🎉What I'm trying to solve is quite usual in AMI. I want to compute the initial configuration of a humanoid robot such that the knees and the elbows are slightly bent, the soles of the feet are in contact, and the feet are slightly more distant w.r.t. the configuration with zero joint positions. The optimized variables are the joint positions and the base height. The corresponding optimization problem computes FK in the cost function (exploiting AD support through the JaxSim function).
I had to fix the gradient propagation as in this PR to prevent having problems either with zero division in the jitted function or the same problem in the gradient computed with AD. The trick I used it the double-where workaround, as described in:
📚 Documentation preview 📚: https://jaxsim--277.org.readthedocs.build//277/