2 July 2020 at 15 h 12 min #16768SherpaParticipant
- University College London
I’ve been using the soft robotics plugin and have been adapting the pneumatic gripper tutorial to my needs. I am struggling on how to read force data exerted by the gripper on the ojects it interacts with. Is it possible to otain this data either through the code or the gui?
I have checked the SOFA documentation but didn’t find something to help me so if you could point me in the right direction I would be very grateful!
Thank you!7 July 2020 at 23 h 31 min #16830HugoKeymaster
- SOFA Consortium
It is actually a bit complex to access collision forces. If I remember properly, the tutorial is using a FreeMotionAnimationLoop, therefore solving collision using the Lagrange multipliers approach.
The result of the collision forces (solved within the constraint problem) are stored by the ConstraintProblem. To compute them on your degrees of freedom, you need to recover “constraint” of the MechanicalObject corresponding to the and multiply it with the lambda saved in the ConstraintSolver and resulting from the constraint resolution.
It is not yet available in the SOFA API, we know it is something to improve for users/devs.
@olivier-goury could you please correct me here, if anything is incorrect?
Hugo8 July 2020 at 9 h 44 min #16835olivierParticipant
- DEFROST Team, Inria
Yes Hugo, you’re absolutely right. To add some info, H will give you the force direction, while lambda will give you the intensity. You can get H from the python code in your SOFA scene by calling the “constraint” field of the MechanicalObject. For lambda, I think you will have to go in the constraint solver (typically GenericConstraintSolver) and print it out at the end of the solveSystem(…) function.
Do not hesitate if you need more details,
Olivier23 July 2020 at 19 h 57 min #16950BrunoB81HKParticipant
I’m building a scene in python and I try to compute the forces like you wrote there. I’m having trouble finding lambda. Can you Go further in your explanation of how to get the lambda?
Also, there is a Data in the GenericConstraintSolver that is named constraintForces and they doesn’t seems to be the constaints forces. What are they?
Thanks a lot for your help!
Bruno27 July 2020 at 12 h 02 min #16961olivierParticipant
- DEFROST Team, Inria
For your second question, actually, the Data constraintForces does give you the value of Lambda (so the intensity of the constraint forces).
So to answer your first question, to output lambda, I think the easiest will be to get it using a PythonScriptController in which you recover the value of that data calling findData(‘constraintForces’) on the object genericConstraintSolver, or just read it from the GUI if you do not need it at each timestep.
(You can find an example of controller in SoftRobots/docs/examples/component/constraint/CableConstraint/CableConstraint.pyscn)
Olivier27 July 2020 at 17 h 55 min #16966
- You must be logged in to reply to this topic.