Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add distance sensing for SDF geoms #2216

Open
dyackzan opened this issue Nov 6, 2024 · 0 comments · May be fixed by #2218
Open

Add distance sensing for SDF geoms #2216

dyackzan opened this issue Nov 6, 2024 · 0 comments · May be fixed by #2218
Labels
enhancement New feature or request

Comments

@dyackzan
Copy link

dyackzan commented Nov 6, 2024

The feature, motivation and pitch

The distance sensor returns the distance between two bodies/geoms normally, but if one of the elements is an SDF geom, then it will only return the penetration distance if the geoms are in contact. So if the objects are not in contact then the distance sensor doesn't actually sense the distance and will just return the cutoff value.

I'll make this a feature request rather than a bug since this behavior seems intentional/place-holding based on the mjc_SDF function that gets used when a distance sensor between an SDF and most other geom types is created.

Alternatives

No response

Additional context

I used the following model to test:

<mujoco model="distance_testing">
    <extension>
        <plugin plugin="mujoco.sdf.torus">
            <instance name="torus">
                <config key="radius1" value="0.35"/>
                <config key="radius2" value="0.15"/>
            </instance>
        </plugin>
    </extension>

    <asset>
        <mesh name="torus">
            <plugin instance="torus"/>
        </mesh>
    </asset>
    <option sdf_iterations="10" sdf_initpoints="40"/>

    <worldbody>
        <light name="top" pos="0 0 1"/>
        <body name="sphere" pos="1.0 0. 0." >
            <joint name="trans_1" type="slide" damping="100" axis="1 0 0"/>
            <joint name="trans_2" type="slide" damping="100" axis="0 1 0"/>
            <geom name="sphere_geom" type="sphere" size=".2 .2 .2" rgba="1 0 0 1" margin="1.0" gap="1.0"/>
        </body>

        <body name="sphere2" pos="0.0 1.0 0." >
            <geom name="sphere2_geom" type="sphere" size=".2 .2 .2" rgba="0 1 0 1" margin="1.0" gap="1.0"/>
        </body>

        <body name="torus" pos="0.0 0.0 0.0">
            <geom type="sdf" name="torus_geom" mesh="torus" rgba="0.4 0.4 0.4 1" margin="1.0" gap="1.0">
                <plugin instance="torus"/>
            </geom>
        </body>
    </worldbody>

    <actuator>
        <position name="trans_jnt_1" joint="trans_1" ctrlrange="-1 1" ctrllimited="true" kp="4000" kv="600"/>
        <position name="trans_jnt_2" joint="trans_2" ctrlrange="-1 1" ctrllimited="true" kp="4000" kv="600"/>
    </actuator>

    <sensor>
        <distance name="sphere_torus_distance_sensor" geom1="sphere_geom" geom2="torus_geom" cutoff="10"/>
        <distance name="sphere_sphere_distance_sensor" geom1="sphere_geom" geom2="sphere2_geom" cutoff="10"/>
    </sensor>
</mujoco>

You can see that the distance sensor reading between the mobile sphere and the sphere changes value as you slide the mobile sphere around. But the distance sensor reading between the torus (SDF) and the mobile sphere never changes unless the two geoms come into contact.

@dyackzan dyackzan added the enhancement New feature or request label Nov 6, 2024
@dyackzan dyackzan linked a pull request Nov 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant