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

Exploit branch-induced sparsity to invert the mass matrix #107

Open
diegoferigo opened this issue Mar 12, 2024 · 3 comments · May be fixed by #231
Open

Exploit branch-induced sparsity to invert the mass matrix #107

diegoferigo opened this issue Mar 12, 2024 · 3 comments · May be fixed by #231
Assignees

Comments

@diegoferigo
Copy link
Member

diegoferigo commented Mar 12, 2024

Inverting the mass matrix $M \in \mathbb{R}^{(6+n)\times(6+n)}$ is a operation commonly used in model-based control. Also for simulation purpose, it can be used to compute the forward dynamics without relying on ABA, like we do in:

ν̇ = jnp.linalg.solve(M, S @ τ - h + JTf)

If we decompose the free-floating as follows:

$$M = \begin{pmatrix} M_{bb} & M_{bs} \\\ M_{bs}^T & M_{ss} \end{pmatrix}$$

we can exploit the known topology of the kinematic tree defined by the parent array $\lambda(i)$ to speed up the inversion of $M_{ss} \in \mathbb{R}^{n \times n}$.

Enhancing the performance of this inversion could enable downstream users to implement alternative forward dynamics beyond our ABA and CRB implementations, for example including second-order dynamics like advanced motor dynamics (e.g. #62) or musculoskeletal models. If performance are not too far from ABA, it could be a great alternative of include these effects in ABA since it might be a daunting task.

Some references:

Note that the code from Featherstone only inverts $M_{ss}$. We can exploit the following property to extend the result to the free-floating mass matrix:

https://www.wikiwand.com/en/Block_matrix#Block_matrix_inversion

@diegoferigo diegoferigo self-assigned this Mar 13, 2024
@flferretti
Copy link
Collaborator

More resources:

@diegoferigo
Copy link
Member Author

A while ago I started playing a bit around with this type of inversion, but I couldn't get any better performance than calling jax.numpy.linalg.inv. I came up to the conclusion that the best approach to get the inverse of the mass matrix is to implement a new RBDA that directly provides $M(\mathbf{q})^{-1}$:

@flferretti
Copy link
Collaborator

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.

2 participants