-
Notifications
You must be signed in to change notification settings - Fork 10
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
Consider only enabled collidable points in contact forces computation for Rigid
, RelaxedRigid
and Soft
contact models
#274
Consider only enabled collidable points in contact forces computation for Rigid
, RelaxedRigid
and Soft
contact models
#274
Conversation
Rigid
and RelaxedRigid
contact models
Rigid
and RelaxedRigid
contact modelsRigid
and RelaxedRigid
contact models
@diegoferigo I have some questions about this work: I tried to extend this work to jaxsim/src/jaxsim/rbda/contacts/visco_elastic.py Lines 1086 to 1090 in ae908f1
While if I do a similar thing with SoftContacts I get the following error:
(where in this example, 16 is the number of enabled collidable points and 48 is their total number). Have you any idea on how to address this? |
@diegoferigo do you think is useful to add some unit tests for this? If yes, do you suggest to update some of the tests already in place or to perform some other simulation tests with a reduced number of collidable points? |
My guess is that the integrator has been initialized passing a |
I start with a remark. Contrarily to state-less contact models like Filtering either statically or dynamically the active contact points of stateless models is reasonable1. This is because when a active point becomes inactive, or another contact point is considered instead, there's no state to handle. This is no longer true in soft-like models. As a consequence, I believe that dynamic filtering of active contact points of soft-like models is something that we cannot achieve (cc @flferretti). However, static filtering can be supported, and this PR will only implement this type of filtering. This being said, I think that you need to initialize the tangential deformation variables stored in
In the meantime, you can maybe filter 3 out of 4 of the bottom corners of the falling box simulation with different contact models. We can discuss this better later. Footnotes
|
Thanks a lot for the clear remarks! |
c61bdc5
to
1c517cb
Compare
In the end by just updating tangential deformations just for the enabled collidable points, without changing the shape of the array of this state the static filtering of collidable points also worked for Soft Contacts. |
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 a lot @xela-95! I just left a couple minor comments
Rigid
and RelaxedRigid
contact modelsRigid
, RelaxedRigid
and Soft
contact models
1c517cb
to
d14636b
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 @xela-95 for your work! I'm leaving a general comment to trigger a discussion, I'm not sure what's the best approach.
This PR implements the filtering of the collidable points at the contact model level. Furthermore, to streamline this approach for integration purpose, it also updates jaxsim.api.contact.collidable_point_dynamics
to return the contact forces of only the enabled collidable points. This last change creates a disparity with all the other APIs belonging to jaxsim.api.contact
, that will keep returning data corresponding to all the collidable points.
I'm not sure here how to proceed. There are a few ways:
- Compute the contact forces of all collidable points and slice the output of
collidable_point_dynamics
at the caller level, as done for other contact-related quantities. This will however defeat any performance boost that would result from the filtering. - Return a full matrix of contact forces and aux_data, having zero content for disabled collidable points.
- Adjust all the other APIs to return quantities corresponding to only the enabled collidable points.
I'm not sure which one is the best at first sight. For the time being, to reduce the work, I'd tend towards 2 and possibly give 3 a try in the future. But I'd like to discuss first to know your opinion.
Thanks a lot for the feedback @diegoferigo ! Yes you're right this PR could led to a non obvious disparity in the Ideally form the user perspective I think it will be more useful (and less of a hassle) to get always quantities related only to enabled collidable points, but this behavior could have impacts that we should test better, maybe in a separate PR. I will update the current PR with the solution 2) for the time being. i.e. updating all |
My concerns on the extended filter is that the filtering in the future can be useful to dynamically select a subset of points (as opposed to now that is hardcoded). Being the mask a static attribute, if it changes automatically, there will be jit recompilation. We might work around it with Footnotes |
For what regards:
The lines to be modified are:
|
shape=(len(model.kin_dyn_parameters.contact_parameters.body), 4, 4) |
api.contact.jacobian
jaxsim/src/jaxsim/api/contact.py
Line 496 in bd59060
jnp.array(model.kin_dyn_parameters.contact_parameters.body, dtype=int)
api.contact.jacobian_derivative
jaxsim/src/jaxsim/api/contact.py
Lines 570 to 571 in bd59060
parent_link_idxs = jnp.array(model.kin_dyn_parameters.contact_parameters.body) L_p_Ci = jnp.array(model.kin_dyn_parameters.contact_parameters.point)
api.contact.transforms
jaxsim/src/jaxsim/api/contact.py
Line 443 in bd59060
jnp.array(model.kin_dyn_parameters.contact_parameters.body, dtype=int) jaxsim/src/jaxsim/api/contact.py
Line 449 in bd59060
model.kin_dyn_parameters.contact_parameters.point
api.contact.in_contact
jaxsim/src/jaxsim/api/contact.py
Line 261 in bd59060
jnp.array(model.kin_dyn_parameters.contact_parameters.body) == link_index,
rbda.collidable_points.collidable_points_pos_vel
if len(model.kin_dyn_parameters.contact_parameters.body) == 0: jaxsim/src/jaxsim/rbda/collidable_points.py
Lines 139 to 140 in bd59060
model.kin_dyn_parameters.contact_parameters.point, jnp.array(model.kin_dyn_parameters.contact_parameters.body),
And then reset the modifications done inside rbda.contact.*
as the previous modifications will naturally be propagated
It seems doable, WDYT?
Yes for sure before to start considering the idea of dynamic slicing we should investigate the possible performance outcomes deriving from the issues you're describing.
Thanks for the contribution @flferretti ! For me, this is doable with the static filtering we adopted in this PR. WRT the considerations expressed by @diegoferigo these modifications could produce a performance increase for now, that maybe should be changed again when/if we'll address dynamic filtering. I can give it a try since it should be doable quite quickly. |
5f2e20f
to
f0d2726
Compare
Done, now the |
f0d2726
to
593d9bd
Compare
Rebased on main |
… enabled collidable points
Enable a subset of collidable points in SoftContacts, RigidContacts, and RelaxedRigidContacts
…s of enabled collidable points
593d9bd
to
c531bbd
Compare
In this PR I'm adding the possibility to consider only a subset of the available collidable points of the model in the computation of the contact forces.
I'm extending the behavior already introduced in #248 for
ViscoElasticContacts
toRigidContacts
RelaxedRigidContacts
SoftContacts
The modifications in this PR have the intention of be sufficiently general to easily extend this also toSoftContacts
.📚 Documentation preview 📚: https://jaxsim--274.org.readthedocs.build//274/