How to print touch sensor value of collision of parent body

Discussion in 'Modeling' started by taegyu, Aug 25, 2020.

  1. Hi, I want to print contact force between collision of parent body and other materials by touch sensor of site
    which is included in a child body .

    Specifically, I wanted to arrange touch sensors neatly to the end-effector of jaco arm
    so I created child body which has flat box geometric to the finger body of end-effector
    and arranged a site which has box geometric on that child plane which shows neatly arranged touch sensors.

    However, when I control end-effector to grab arbitrary materials like box, the sensor doesn't show
    any values except for 0.0 value.

    I think this is because the touch sensor is not included in the body where the collision is happening.
    but I cannot figure out how to print collision value while placing sensors arranged neatly to the plane of finger of jaco arm.

    can you help me?

    (exemplary code)

    Code:
    <!-- for palm EE -->
                                        <body name="EE" pos="0 0 0.12" euler="0 0 0">
                                        </body>
    
                                        <body name="thumb_proximal" pos="0.002786 -0.03126 0.114668" quat="0.95922726  0.262085    0.02762996 -0.10213274">
                                            <geom name="thumb_proximal" type="mesh" mesh="finger_proximal" euler="0 -1.5707 0" friction="1 0.5 0.01" solimp="0.95 0.95 0.01 0.5 6" solref="0.01 1" condim="6" margin="0.0"/>
                                            <joint name="joint_thumb" pos="0 0 0" axis="1 0 0" ref="1.1" limited="true" range="-0.2 1.1" solimplimit="0.95 0.95 0.01" solreflimit="0.01 1" stiffness="5" springref="0.0" damping="0.35"/>
                                            <body name="thumb_proximal_plane" pos="0 0.000 0.032">
                                                <geom name="thumb_proximal_plane" type="box" euler="1.44 0 0" size="0.008 0.008 0.0005" rgba="0 1 0 0.5" />
                                                <site name="tp_touch_0" type="box" pos="0 0.00 0.0" size="0.0024 0.0024 0.0024" euler="1.44 0 0" rgba="0 0 1 0.5"/>
                                                <site name="tp_touch_1" type="box" pos="0.0048 0.0008 0.0048" size="0.0024 0.0024 0.0024" euler="1.44 0 0" rgba="0 1 0 0.5"/>
                                                <site name="tp_touch_2" type="box" pos="-0.0048 0.0008 0.0048" size="0.0024 0.0024 0.0024" euler="1.44 0 0" rgba="0 1 0 0.5"/>
                                                <site name="tp_touch_3" type="box" pos="0.0048 -0.0008 -0.0048" size="0.0024 0.0024 0.0024" euler="1.44 0 0" rgba="0 1 1 0.5"/>
                                                <site name="tp_touch_4" type="box" pos="-0.0048 -0.0008 -0.0048" size="0.0024 0.0024 0.0024" euler="1.44 0 0" rgba="0 1 1 0.5"/>
                                            </body>
    Code:
    <sensor>
            <touch name="tp_touch_0" site ="tp_touch_0"/>
            <touch name="tp_touch_1" site ="tp_touch_1"/>
            <touch name="tp_touch_2" site ="tp_touch_2"/>
            <touch name="tp_touch_3" site ="tp_touch_3"/>
            <touch name="tp_touch_4" site ="tp_touch_4"/>
    </sensor>
     
  2. I tried to create a touch sensor in a finger of parent body but value is still 0.0 .... Idk what is problem
     
  3. Hey Taegyu,
    I think the geom must be inside the touch site. I'm using Deepminds dm_control python wrapper, because I need to change the environment during simulation.

    here my python snippet for body + geom + site:

    Code:
    self.end_effector.add(
                "geom",
                name="suction_cup_geom",
                dclass="ur10",
                type="ellipsoid",
                pos=[0, 0.4, -0.02],
                euler=[-1.6, 0, 0],
                size=[0.015, 0.015, 0.000015],
                rgba=[1.0, 1.0, 0.5, 1],
            )
            self.end_effector.add(
                "site",
                pos=[0, 0.4, -0.02],
                size=[0.016, 0.016, 0.000016],
                type="ellipsoid",
                euler=[-1.6, 0, 0],
                name="suction_site",
                rgba=[0.5, 0, 0, 1],
            )
    In the xml the touch sensor is deffined as:

    Code:
    <sensor>
            <touch name="suction_touch" site="suction_site"/>
        </sensor>
    If I remember right the object that you want to "touch" needs to have contype=1, conaffinity=1. That are my settings

    I think your geom is not inside the site. And your touch sensors have the same name as the sites. That could be a problem
     
    Last edited: Aug 27, 2020
  4. Thank you very much.
    I'm not sure because the sensor outputs not appear often so that I cannot check precisely (I also posted this issue on forum)
    , but I think it was solved by adding contype and conaffinity.