Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize vectorization of free-floating Jacobian #110

Closed
diegoferigo opened this issue Mar 13, 2024 · 1 comment · Fixed by #121
Closed

Optimize vectorization of free-floating Jacobian #110

diegoferigo opened this issue Mar 13, 2024 · 1 comment · Fixed by #121
Assignees

Comments

@diegoferigo
Copy link
Member

diegoferigo commented Mar 13, 2024

Currently we are computing the free-floating jacobian $J \in \mathbb{R}^{6 \times (6 + n)}$ using the following algorithm:

def jacobian(model: PhysicsModel, body_index: jtp.Int, q: jtp.Vector) -> jtp.Matrix:
"""
Compute the Jacobian matrix for a specific link in an articulated body or robot.
Args:
model (PhysicsModel): The physics model of the articulated body or robot.
body_index (jtp.Int): The index of the link for which to compute the Jacobian matrix.
q (jtp.Vector): Joint positions (Generalized coordinates).
Returns:
jtp.Matrix: The Jacobian matrix for the specified link.
"""

When jit-compiled, body_index must be a static argument, therefore the following vectorization is quite slow:

J_free_floating = jax.vmap(
lambda i: to_output(
W_J_WL=js.link.jacobian(
model=model,
data=data,
link_index=i,
output_vel_repr=VelRepr.Inertial,
)
)
)(jnp.arange(model.number_of_links()))

We should investigate if we can compute a "full" free-floating jacobian (with all columns filled) in a shared representation (like a doubly-left one), and then produce the link jacobian by filtering the columns using the support parent array $\kappa(i)$ together with appropriate conversions of input/output velocity representations.

@diegoferigo diegoferigo linked a pull request Mar 26, 2024 that will close this issue
@diegoferigo diegoferigo self-assigned this Mar 26, 2024
@diegoferigo
Copy link
Member Author

I implemented the algorithm to compute the doubly-left full Jacobian ${}^B J_{W,\text{\_}/B}$ in #121. Closing.

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 a pull request may close this issue.

1 participant