Add mj_geomDistance API function and sensors for geometric distance, normal direction and segment between between two geoms. Fixes #51

PiperOrigin-RevId: 632458301
Change-Id: I65b7e5bb0df59008028114cf4a07e0d6365ff3d3
This commit is contained in:
Yuval Tassa
2024-05-10 04:51:46 -07:00
committed by Copybara-Service
parent 31de1dad9d
commit 02d015458c
29 changed files with 1002 additions and 66 deletions
+29
View File
@@ -0,0 +1,29 @@
<mujoco model="Body-Body collisions fromto">
<option>
<flag gravity="disable"/>
</option>
<worldbody>
<light pos=".5 0 3"/>
<light pos="-.5 0 3"/>
<geom type="plane" size="2 2 .01"/>
<body name="1" pos="0 0 .3">
<freejoint/>
<replicate count="50" offset="0 0 0.01" euler="0 0 25">
<geom type="capsule" size=".01 .05" pos="0 -.23 -.2" euler="0 84.5 0" rgba="0 0 1 1"/>
</replicate>
</body>
<body name="2" pos=".6 0 .3" euler="0 0 90">
<freejoint/>
<replicate count="50" offset="0 0 0.01" euler="0 0 15">
<geom type="capsule" pos=".025 -.2 -.2" size=".032 .04" euler="-24 -12 2" rgba=".8 0 0 1"/>
</replicate>
</body>
</worldbody>
<sensor>
<fromto body1="1" body2="2" cutoff="1"/>
</sensor>
</mujoco>
+83
View File
@@ -0,0 +1,83 @@
<mujoco model="Convex-Convex collisions">
<option>
<flag gravity="disable"/>
</option>
<asset>
<mesh name="halfbox1" scale=".2 .3 .1"
vertex="0 0 0 1 0 0 0 1 0 1 1 0
0 0 1 1 0 1 0 1 1 "/>
<mesh name="halfbox2" scale=".2 .3 .1"
vertex="1 0 0 0 1 0 1 1 0
0 0 1 1 0 1 0 1 1 "/>
<hfield name="hfield" nrow="3" ncol="4" size="1 1 .1 .08"
elevation="1 0 1 2
0 2 1 1
1 0 1 0"/>
</asset>
<default>
<geom rgba=".2 .2 .6 1"/>
</default>
<worldbody>
<light pos=".5 0 3"/>
<light pos="-.5 0 3"/>
<geom name="hfield" type="hfield" hfield="hfield" rgba="0.5 0.5 0.5 1"/>
<body pos=".2 0 .6">
<freejoint/>
<geom name="sphere" type="sphere" size=".15"/>
</body>
<body pos="0 0 .3">
<freejoint/>
<geom name="ellipsoid" type="ellipsoid" size=".1 .1 .2"/>
</body>
<body pos=".4 0 .3">
<freejoint/>
<geom name="cylinder" type="cylinder" size=".1 .15"/>
</body>
<body pos="-.5 0 .3">
<freejoint/>
<geom name="box" type="box" size=".2 .15 .1"/>
</body>
<body pos="-.5 0 .6">
<freejoint/>
<geom name="mesh1" type="mesh" mesh="halfbox1"/>
</body>
<body pos="-.5 -.6 .3">
<freejoint/>
<geom name="mesh2" type="mesh" mesh="halfbox2"/>
</body>
</worldbody>
<sensor>
<fromto geom1="ellipsoid" geom2="box" cutoff="1"/>
<fromto geom1="ellipsoid" geom2="cylinder" cutoff="1"/>
<fromto geom1="ellipsoid" geom2="mesh2" cutoff="1"/>
<fromto geom1="ellipsoid" geom2="hfield" cutoff="1"/>
<fromto geom1="mesh1" geom2="sphere" cutoff="1"/>
<fromto geom1="mesh1" geom2="box" cutoff="1"/>
<fromto geom1="mesh1" geom2="mesh2" cutoff="1"/>
<fromto geom1="hfield" geom2="sphere" cutoff="1"/>
<fromto geom1="hfield" geom2="box" cutoff="1"/>
<fromto geom1="hfield" geom2="mesh1" cutoff="1"/>
<fromto geom1="ellipsoid" geom2="box" cutoff="0.2"/>
<fromto geom1="ellipsoid" geom2="cylinder" cutoff="0.2"/>
<fromto geom1="ellipsoid" geom2="mesh2" cutoff="0.2"/>
<fromto geom1="ellipsoid" geom2="hfield" cutoff="0.2"/>
<fromto geom1="mesh1" geom2="sphere" cutoff="0.2"/>
<fromto geom1="mesh1" geom2="box" cutoff="0.2"/>
<fromto geom1="mesh1" geom2="mesh2" cutoff="0.2"/>
<fromto geom1="hfield" geom2="sphere" cutoff="0.2"/>
<fromto geom1="hfield" geom2="box" cutoff="0.2"/>
<fromto geom1="hfield" geom2="mesh1" cutoff="0.2"/>
</sensor>
</mujoco>
+71
View File
@@ -0,0 +1,71 @@
<mujoco model="Primitive collisions">
<asset>
<mesh name="halfbox" scale=".2 .3 .1"
vertex="0 0 0 1 0 0 0 1 0 1 1 0
0 0 1 1 0 1 0 1 1 "/>
</asset>
<default>
<geom rgba=".2 .2 .6 1"/>
</default>
<worldbody>
<light pos=".5 0 3"/>
<light pos="-.5 0 3"/>
<geom name="plane" type="plane" size="2 2 .01" rgba="0.5 0.5 0.5 1"/>
<body pos=".2 0 .6">
<freejoint/>
<geom name="sphere" type="sphere" size=".15"/>
</body>
<body pos="0 0 .3">
<freejoint/>
<geom name="capsule1" type="capsule" size=".1 .1"/>
</body>
<body pos="-.2 0 .4" euler="90 0 0">
<freejoint/>
<geom name="capsule2" type="capsule" size=".05 .1"/>
</body>
<body pos=".4 0 .3">
<freejoint/>
<geom name="cylinder" type="cylinder" size=".1 .15"/>
</body>
<body pos="-.5 0 .3">
<freejoint/>
<geom name="box1" type="box" size=".2 .15 .1"/>
</body>
<body pos="-.5 0 .6">
<freejoint/>
<geom name="box2" type="box" size=".1 .05 .1"/>
</body>
<body pos="-.5 -.6 .3">
<freejoint/>
<geom name="mesh" type="mesh" mesh="halfbox"/>
</body>
</worldbody>
<sensor>
<fromto geom1="plane" geom2="sphere" cutoff="1"/>
<fromto geom1="plane" geom2="capsule1" cutoff="1"/>
<fromto geom1="plane" geom2="box1" cutoff="1"/>
<fromto geom1="plane" geom2="cylinder" cutoff="1"/>
<fromto geom1="plane" geom2="mesh" cutoff="1"/>
<fromto geom1="capsule2" geom2="capsule1" cutoff="1"/>
<fromto geom1="capsule1" geom2="sphere" cutoff="1"/>
<fromto geom1="sphere" geom2="cylinder" cutoff="1"/>
<fromto geom1="box1" geom2="sphere" cutoff="1"/>
<fromto geom1="box2" geom2="capsule2" cutoff="1"/>
<fromto geom1="box1" geom2="box2" cutoff="1"/>
</sensor>
</mujoco>