How to get contact forces #75
-
How can I get the contact forces when using |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 2 replies
-
Contact forces cannot be retrieved directly, at least not currently. |
Beta Was this translation helpful? Give feedback.
-
Thank you; I'm now able to retrieve some forces. However, when I check the forces at the end of my script, it seems I'm only accessing the final computed values. Is this correct? The documentation for |
Beta Was this translation helpful? Give feedback.
-
Sure, SetPreStepUserFunction would be called at the beginning of the next step.
See the documentation for the interface of userFunctions (I just noticed that the solver argument is missing in the docu). There is a test model explicitLieGroupIntegratorPythonTest.py which uses such user functions. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
This is correctly showing what PostNewtonUserFunction does. If you only like to retrieve values for plotting, you could use a SensorUserFunction, which takes the final values at the end of steps. I forgot to mention that in the previous answer. |
Beta Was this translation helpful? Give feedback.
-
Thank you! Yeah I see the horizontal shift now. For reference:
|
Beta Was this translation helpful? Give feedback.
Contact forces cannot be retrieved directly, at least not currently.
However, there is a GeneralContact function called "GetSystemODE2RhsContactForces()", which allows you to see the contribution of contact forces to the global force vector.
Say, if you know your global coordinate indices of a planar rigid body node, say 21,22, and 23, you could call GetSystemODE2RhsContactForces() and this would give you all contact forces (21 and 22) and the torque due to friction (23) acting on this body.