Home › Forum › SOFA › Using SOFA › How to know the collision force or energy
- This topic has 5 replies, 2 voices, and was last updated 7 years, 1 month ago by Hugo.
-
AuthorPosts
-
20 November 2017 at 09:44 #10154r0m1Blocked
Hello everyone,
I have a Python scene two objects, each one having both a MechanicalObject and a collision model, which is made of a MechanicalObject and Point collision model. One of them is moving, the other is fixed.
I would like to know the energy or the force generated when the two object collide. Indeed, I would like to perform a particular action when a threshold is exceeded. Where this force (or energy) can be found (in the MechanicalObject of the father node, the MechanicalObject of the collision model node, … of the moving object, of the still one …) ?
Thanks for your help,
Cheers20 November 2017 at 13:13 #10157HugoKeymasterDear @r0m1
Welcome on the SOFA forum!
Since the second object is fixed, all forces applied on this object should result from the collision only. Therefore, one way would be to access the “force” vector of this mechanical object in your python script and trigger any action regarding your threshold.Let me know if this helps.
Hugo
20 November 2017 at 14:56 #10159r0m1BlockedHello Hugo,
Thanks for your help, but unfortunately it did not work.
The moving object is moved thanks to a LinearForceField. When we try to get the ‘force’ vector of the MechanicalObject of the moving object, we get the value we fixed inside the LinearForceField. The ‘force’ vector of the MechanicalObject does not change even when the contact happens.20 November 2017 at 15:23 #10162HugoKeymasterYes but I was talking about the “force” vector of the fixed mechanical object.
What about this one?Hugo
21 November 2017 at 09:01 #10164r0m1BlockedIt is the same the only force value which is present is the one due to gravity.
I also checked the “externalForce” vector of fixed mechanical object: there is a value different from 0 before the contact happens, which is even bigger than the value when the collision occurs. Can it be because the fixed object is attached to a fixed base with an AttachConstraint ?
21 November 2017 at 15:51 #10165HugoKeymasterWhat’s your collision method and model exactly ? Or simpler : could you share with us the structure of your scene please ?
externalForce is a vector summing up forces coming from external interactions (usually fully explicit forces). Typically, forces due to the mouse interactions, JointSpringForceField or collision. With collision using an UncoupledConstraintCorrection for instance, the externalForce is filled when applying the contact force (as you can see UncoupledConstraintCorrection.inl line 484). But at the end of each time step, the externalForce vector is reset by the MechanicalObject (see MechanicalObject.inl line 1465)
Hope this help,
-
AuthorPosts
- You must be logged in to reply to this topic.