-
Notifications
You must be signed in to change notification settings - Fork 13
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 ContactModel
base class and abstract contact handling in JaxSimModel
and JaxSimModelData
#178
Conversation
0755ca0
to
c202825
Compare
For some reason, CI is failing only in Python 3.10 (https://github.com/ami-iit/jaxsim/actions/runs/9511311149) |
c8560af
to
8883e59
Compare
Mmh, since it is related to hash and equality, maybe we can wait to merge #179. |
8883e59
to
daee668
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @flferretti for this first attempt aimed at abstracting the contact model in view of the addition of alternative ones. I left few initial comments in the code.
- What if we leave the actual soft-contact class defining the algorithm in
jaxsim.rbda
? If we plan to add multiple contact models, I'm ok in adding a new subpackagejaxsim.rbda.contacts.{soft|...}
. - I'd keep the high-level detection of the contact model much more simple, right now there are many hacks I'd like to avoid at this initial stage.
50bdbee
to
8120bdf
Compare
Done in 2999198 |
4556dbb
to
5640547
Compare
d3b7d38
to
1a97511
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks @flferretti! Last review pass with the final suggestions. Well done 🚀
src/jaxsim/rbda/contacts/common.py
Outdated
position: jtp.Vector, | ||
velocity: jtp.Vector, | ||
**kwargs, | ||
) -> tuple[Any, ...]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to provide as first output the computed contact forces, and as second output a tuple of auxiliary data. For the current soft contacts model, it will be (ṁ,)
) -> tuple[Any, ...]: | |
) -> tuple[jtp.Matrix, tuple[Any, ...]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in f64764f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this has to be propagated to the implementation before resolving this conversation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a9e3b2f
f64764f
to
2cac06c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final suggestions that I overlooked in my previous review:
- Can you double check in our codebase where
JaxSimModel.build
is called? For sure, the newJaxSimModel.contact_model
attribute has to be copied when the model is reduced here. - Instead of
pass
, you can also use...
but I would not leave the body empty.
The only part in which the |
a9e3b2f
to
dfebf77
Compare
I added the |
Ok. Instead, regarding the model reduction, I meant that something to prevent a problem similar to #168 is still missing, right? |
It's indeed there jaxsim/src/jaxsim/api/model.py Line 369 in dfebf77
|
Woops, sorry my bad. All good then, thanks! |
Co-authored-by: Diego Ferigo <[email protected]>
Co-authored-by: Diego Ferigo <[email protected]>
Co-authored-by: Diego Ferigo <[email protected]>
882a4a0
to
11a557e
Compare
This pull request refactors the contact models to enhance flexibility and future extensibility. Key changes include:
ContactModel
base class together withContactsState
andContactParams
SoftContactModel
,SoftContactParams
andSoftContactState
to inherit fromContactModel
for consistency.contact_model
attribute toJaxSimModel
.These changes allow specifying different contact models during instantiation, facilitating the development of additional contact models in the future.
C.C. @xela-95
📚 Documentation preview 📚: https://jaxsim--178.org.readthedocs.build//178/