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

Add relaxed rigid contacts model #223

Merged
merged 29 commits into from
Sep 13, 2024
Merged

Conversation

flferretti
Copy link
Collaborator

@flferretti flferretti commented Aug 23, 2024

This PR adds an alternative rigid contact model in which the holonomic constraint is relaxed. This allows some penetration, while guaranteeing more stability with respect to the spring-damper model. It is worth noting that the slipping behavior is not considered.


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

@flferretti flferretti self-assigned this Aug 23, 2024
Copy link
Member

@diegoferigo diegoferigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @flferretti! I left an initial review with some comment. Let's align on the merging strategy as soon as @xela-95 is back and #218 gets reviewed as well.

src/jaxsim/terrain/terrain.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
@flferretti flferretti force-pushed the feature/relaxed_rigid_contacts branch 9 times, most recently from 4fb23ed to a562aea Compare September 11, 2024 21:03
Copy link
Member

@diegoferigo diegoferigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, well done @flferretti. All looks good - just minor suggestions excluding a methodological question on the free acceleration. I'll give you green flag as soon as it will be answered.

src/jaxsim/typing.py Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
@flferretti flferretti force-pushed the feature/relaxed_rigid_contacts branch from 7a0758a to f588068 Compare September 12, 2024 13:21
@flferretti flferretti force-pushed the feature/relaxed_rigid_contacts branch from f588068 to 9537c2c Compare September 12, 2024 14:08
Copy link
Member

@diegoferigo diegoferigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates @flferretti. I still have a doubt on the representation used in $\dot{\boldsymbol{\nu}}$. Can you please verify if it is sound?

src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
@flferretti flferretti force-pushed the feature/relaxed_rigid_contacts branch from fb3cb28 to 43e50d2 Compare September 13, 2024 09:03
@flferretti flferretti force-pushed the feature/relaxed_rigid_contacts branch from 3319598 to ae1ff74 Compare September 13, 2024 09:20
Copy link
Member

@diegoferigo diegoferigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, good to go now. Just the last minor suggestions. Great work @flferretti.

Comment on lines -408 to -416
# Convert the inertial-fixed base acceleration to a mixed base acceleration.
W_H_B = data.base_transform()
W_H_BW = W_H_B.at[0:3, 0:3].set(jnp.eye(3))
BW_X_W = math.Adjoint.from_transform(W_H_BW, inverse=True)
term1 = BW_X_W @ W_v̇_WB
term2 = jnp.zeros(6).at[0:3].set(jnp.cross(W_ṗ_B, W_ω_WB))
BW_v̇_WB = term1 - term2

BW_ν̇ = jnp.hstack([BW_v̇_WB, s̈])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xela-95 not necessarily before this PR is merged, can you provide some feedback that this computation is equivalent with the new one? Just want to be sure that everything stays consistent.

src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
src/jaxsim/rbda/contacts/relaxed_rigid.py Outdated Show resolved Hide resolved
@flferretti flferretti force-pushed the feature/relaxed_rigid_contacts branch from ae1ff74 to 3c75735 Compare September 13, 2024 09:29
src/jaxsim/api/ode.py Outdated Show resolved Hide resolved
src/jaxsim/api/ode.py Outdated Show resolved Hide resolved
@flferretti flferretti force-pushed the feature/relaxed_rigid_contacts branch from 3c75735 to a09bc0d Compare September 13, 2024 09:58
@diegoferigo
Copy link
Member

diegoferigo commented Sep 13, 2024

Good to go! Last, can you please link in the first comment the url to code/documentation of Mujoco/Brax from where this contact model got inspired? Thanks!

@flferretti flferretti force-pushed the feature/relaxed_rigid_contacts branch from 6c47479 to 42aed4b Compare September 13, 2024 10:22
@flferretti flferretti merged commit 9129e41 into main Sep 13, 2024
24 checks passed
@flferretti flferretti deleted the feature/relaxed_rigid_contacts branch September 13, 2024 10:41
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 this pull request may close these issues.

3 participants