ContactListener API between rigid body and soft body #5184
Replies: 1 comment 2 replies
-
@hugtalbot & @bakpaul I am sorry for name-dropping like this, I know in the community you both are some of the most active people so I thought I could get your attention on this, I know I should be patient for the reply and not tag, so I sincerely apologize. I am kinda stuck on the progress as I need to find the location of the point of contact between bodies to move forward onto my next part. |
Beta Was this translation helpful? Give feedback.
-
Problem
Description
I am very new to sofa and still trying to understand and navigate my way around it, so sorry if my questions seems to be trivial.
I am trying to find the point of contact between two collision models ( in this case a gripper (rigid body) and a soft body layer. I decided to use ContactListener API. Now I make the gripper drop from up at a controlled speed, it touches once and bounces back. I get two sets of data for this scene, as attached below.
example output:
{'numberOfContacts': 16, 'collisionPointsModel1': [Vec3d(0, 2.76162, 0.013304), Vec3d(0, 2.7614, 0.0137588), Vec3d(0.00186864, 2.76889, 0.0547318), Vec3d(0.0305556, 2.7647, 0.0445549), Vec3d(0.0382823, 2.7616, 0.0308967), Vec3d(0.0508172, 2.76565, 0.00901991), Vec3d(0.046474, 2.76377, 0.0204908), Vec3d(0.0488622, 2.76533, 0.0215185), Vec3d(0.0454395, 2.76252, 0.0158121), Vec3d(-0.0179506, 2.78136, 0.068998), Vec3d(0.0393523, 2.75932, -0.0142727), Vec3d(0.0358865, 2.77477, -0.0556169), Vec3d(0.0377225, 2.75761, -0.0056905), Vec3d(0.0637444, 2.78346, -0.0322426), Vec3d(0.0639254, 2.77955, -0.0166332), Vec3d(0.0692672, 2.79861, -0.0434354)], 'collisionPointsModel2': [Vec3d(0.0526529, 2.70831, 0.0617356), Vec3d(0.052426, 2.70831, 0.0619818), Vec3d(0.032873, 2.70827, 0.0831928), Vec3d(0.051119, 2.70831, 0.0633995), Vec3d(0.0614721, 2.70833, 0.0521685), Vec3d(0.0781368, 2.70837, 0.0340907), Vec3d(0.0704232, 2.70835, 0.0424584), Vec3d(0.0710097, 2.70835, 0.0418221), Vec3d(0.0722783, 2.70836, 0.040446), Vec3d(0.016671, 2.70824, 0.100769), Vec3d(0.0844714, 2.70838, 0.0272188), Vec3d(0.103498, 2.70842, 0.00657852), Vec3d(0.0794441, 2.70837, 0.0326724), Vec3d(0.104656, 2.70843, 0.00532265), Vec3d(0.0969563, 2.70841, 0.0136752), Vec3d(0.112786, 2.70844, -0.0034967)], 'collisionElementsModel1': [5187, 9129, 5984, 5845, 5940, 5827, 5934, 5933, 5830, 9527, 5899, 5605, 5800, 5641, 5756, 5612], 'collisionElementsModel2': [304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304]}
Now my questions are
root.addObject("ContactListener", name="collisionListener", collisionModel1= probe_node.probeCollision.LineCollisionModel.getLinkPath(), collisionModel2= skin.skinCollision.LineCollisionModel.getLinkPath())
I really appreciate any help and discussion on this. Thank you!
I have attached my code as well for reference
Environment
Context
Env vars
python -c "exec( \"import os, sys\nprint('#################')\nprint('--- sys.version ---')\nprint(sys.version)\nprint('--- PATH ---')\ntry:\n print(os.environ['PATH'])\nexcept Exception:\n pass\nprint('--- SOFA_ROOT ---')\ntry:\n print(os.environ['SOFA_ROOT'])\nexcept Exception:\n pass\nprint('--- PYTHONPATH ---')\ntry:\n print(os.environ['PYTHONPATH'])\nexcept Exception:\n pass\nprint('--- sys.path ---')\ntry:\n print(str(sys.path))\nexcept Exception:\n pass\nprint('#################')\" )"
--- sys.version --- 3.10.12 (main, Nov 6 2024, 20:22:13) [GCC 11.4.0] --- PATH --- /home/sun/sofa/build/bin:/home/sun/.local/bin:/usr/bin/python3:/usr/local/bin:/home/sun/sofa/build/bin:/home/sun/.local/bin:/usr/bin/python3:/usr/local/bin:/opt/ros/humble/bin:/home/sun/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin --- SOFA_ROOT --- /home/sun/SOFA/v24.06.00:/home/sun/SOFA/v24.06.00: --- PYTHONPATH --- /home/sun/SOFA/v24.06.00/plugins/SofaPython3/lib/python3/site-packages:/home/sun/SOFA/v24.06.00/plugins/SofaPython3/lib/python3/site-packages:/opt/ros/humble/lib/python3.10/site-packages:/opt/ros/humble/local/lib/python3.10/dist-packages --- sys.path --- ['', '/home/sun/SOFA/v24.06.00/plugins/SofaPython3/lib/python3/site-packages', '/opt/ros/humble/lib/python3.10/site-packages', '/opt/ros/humble/local/lib/python3.10/dist-packages', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/home/sun/.local/lib/python3.10/site-packages', '/home/sun/.local/lib/python3.10/site-packages/rerun_sdk', '/usr/local/lib/python3.10/dist-packages', '/usr/lib/python3/dist-packages']
Beta Was this translation helpful? Give feedback.
All reactions