Raise NotImplementedError for unsupported sensors in MJX. Update MJX feature parity docs to include fully supported sensors.
PiperOrigin-RevId: 673325233 Change-Id: Ib262bdd37937c5230765c11d1f61581e55e8c397
This commit is contained in:
committed by
Copybara-Service
parent
4e3dc14f8e
commit
8710126d08
@@ -214,6 +214,11 @@ The following features are **fully supported** in MJX:
|
|||||||
- :ref:`flInertia`
|
- :ref:`flInertia`
|
||||||
* - :ref:`Tendons <tendon>`
|
* - :ref:`Tendons <tendon>`
|
||||||
- :ref:`Fixed <tendon-fixed>`
|
- :ref:`Fixed <tendon-fixed>`
|
||||||
|
* - :ref:`Sensors <mjtSensor>`
|
||||||
|
- ``MAGNETOMETER``, ``CAMPROJECTION``, ``RANGEFINDER``, ``JOINTPOS``, ``ACTUATORPOS``, ``BALLQUAT``, ``FRAMEPOS``,
|
||||||
|
``FRAMEXAXIS``, ``FRAMEYAXIS``, ``FRAMEZAXIS``, ``FRAMEQUAT``, ``SUBTREECOM``, ``CLOCK``, ``VELOCIMETER``,
|
||||||
|
``GYRO``, ``JOINTVEL``, ``ACTUATORVEL``, ``BALLANGVEL``, ``FRAMELINVEL``, ``FRAMEANGVEL``, ``SUBTREELINVEL``,
|
||||||
|
``SUBTREEANGMOM``, ``ACCELEROMETER``, ``ACTUATORFRC``, ``JOINTACTFRC``.
|
||||||
|
|
||||||
The following features are **in development** and coming soon:
|
The following features are **in development** and coming soon:
|
||||||
|
|
||||||
|
|||||||
@@ -116,8 +116,7 @@ def put_model(
|
|||||||
(m.actuator_gaintype, types.GainType, mujoco.mjtGain),
|
(m.actuator_gaintype, types.GainType, mujoco.mjtGain),
|
||||||
(m.actuator_trntype, types.TrnType, mujoco.mjtTrn),
|
(m.actuator_trntype, types.TrnType, mujoco.mjtTrn),
|
||||||
(m.eq_type, types.EqType, mujoco.mjtEq),
|
(m.eq_type, types.EqType, mujoco.mjtEq),
|
||||||
# TODO(taylorhowell): causes Menagerie test to fail
|
(m.sensor_type, types.SensorType, mujoco.mjtSensor),
|
||||||
# (m.sensor_type, types.SensorType, mujoco.mjtSensor),
|
|
||||||
(m.wrap_type, types.WrapType, mujoco.mjtWrap),
|
(m.wrap_type, types.WrapType, mujoco.mjtWrap),
|
||||||
):
|
):
|
||||||
missing = set(enum_field) - set(enum_type)
|
missing = set(enum_field) - set(enum_type)
|
||||||
|
|||||||
@@ -93,11 +93,29 @@ class SensorTest(parameterized.TestCase):
|
|||||||
_assert_eq(random_sensor, dx.sensordata, 'sensordata')
|
_assert_eq(random_sensor, dx.sensordata, 'sensordata')
|
||||||
|
|
||||||
def test_unsupported_sensor(self):
|
def test_unsupported_sensor(self):
|
||||||
"""Tests MJX sensor functions do not break for unsupported sensors."""
|
"""Tests unsupported sensor raises error."""
|
||||||
m = test_util.load_test_file('sensor/unsupported.xml')
|
m = mujoco.MjModel.from_xml_string("""
|
||||||
mx = mjx.put_model(m)
|
<mujoco>
|
||||||
dx = jax.jit(mjx.forward)(mx, mjx.put_data(m, mujoco.MjData(m)))
|
<worldbody>
|
||||||
_assert_eq(np.zeros(m.nsensordata), dx.sensordata, 'sensordata')
|
<body>
|
||||||
|
<joint type="hinge"/>
|
||||||
|
<geom name="geom0" size="0.1"/>
|
||||||
|
<site name="site0"/>
|
||||||
|
<body>
|
||||||
|
<joint type="hinge"/>
|
||||||
|
<geom name="geom1" size="0.25"/>
|
||||||
|
<site name="site1"/>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</worldbody>
|
||||||
|
<sensor>
|
||||||
|
<distance name="distance" geom1="geom0" geom2="geom1"/>
|
||||||
|
<touch name="touch" site="site0"/>
|
||||||
|
</sensor>
|
||||||
|
</mujoco>
|
||||||
|
""")
|
||||||
|
with self.assertRaises(NotImplementedError):
|
||||||
|
mjx.put_model(m)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
<!-- For validating model with unsupported sensors -->
|
|
||||||
<mujoco model="unsupported_sensor">
|
|
||||||
<asset>
|
|
||||||
<material name="material"/>
|
|
||||||
</asset>
|
|
||||||
<worldbody>
|
|
||||||
<!-- tree 0 -->
|
|
||||||
<body name="body0" pos="1 2 3">
|
|
||||||
<joint name="hinge0" type="hinge" axis="1 0 0"/>
|
|
||||||
<geom name="geom0" size="0.1" material="material"/>
|
|
||||||
<site name="site_rangefinder0" pos="-1e-3 0 0.2"/>
|
|
||||||
<site name="site_rangefinder1" pos="-1e-3 0 0.175"/>
|
|
||||||
<site name="site0" pos=".1 .2 .3"/>
|
|
||||||
<body name="body1" pos="0.1 0.2 0.3">
|
|
||||||
<joint name="hinge1" type="hinge" axis="0 1 0"/>
|
|
||||||
<geom name="geom1" size="0.25"/>
|
|
||||||
<site name="site1" pos=".2 .4 .6"/>
|
|
||||||
</body>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
<!-- body 2 -->
|
|
||||||
<body name="body2" pos=".1 .1 .1">
|
|
||||||
<joint name="ballquat2" type="ball" pos="0.1 0.1 0.1"/>
|
|
||||||
<geom name="geom2" size="1"/>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
<!-- body 3 -->
|
|
||||||
<body name="body3" pos="-.1 -.1 -.1">
|
|
||||||
<joint name="ballquat3" type="ball" pos="0.1 0.2 0.3"/>
|
|
||||||
<geom size="1"/>
|
|
||||||
<site name="site3"/>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
<!-- bodies for camera projection -->
|
|
||||||
<body pos="11.1 0 1">
|
|
||||||
<geom type="box" size=".1 .6 .375"/>
|
|
||||||
<site name="frontorigin" pos="-.1 .6 .375"/>
|
|
||||||
<site name="frontcenter" pos="-.1 0 0"/>
|
|
||||||
</body>
|
|
||||||
<body pos="10 0 0">
|
|
||||||
<joint axis="0 0 1" range="-180 180" limited="false"/>
|
|
||||||
<geom type="sphere" size=".2" pos="0 0 0.9"/>
|
|
||||||
<camera pos="0 0 1" xyaxes="0 -1 0 0 0 1" fovy="41.11209"
|
|
||||||
resolution="1920 1200" name="fixedcamera"/>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
<!-- body for rangefinder -->
|
|
||||||
<body name="body_rangefinder" pos="1 2 4">
|
|
||||||
<geom size="0.01" material="material"/>
|
|
||||||
</body>
|
|
||||||
</worldbody>
|
|
||||||
|
|
||||||
<actuator>
|
|
||||||
<motor name="motor0" joint="hinge0" ctrlrange="-1 1" gear="10"
|
|
||||||
ctrllimited="true"/>
|
|
||||||
<motor name="motor1" joint="hinge1" ctrlrange="-1 1" gear="10"
|
|
||||||
ctrllimited="true"/>
|
|
||||||
</actuator>
|
|
||||||
|
|
||||||
<sensor>
|
|
||||||
<distance name="distance" geom1="geom0" geom2="geom1"/>
|
|
||||||
<framelinvel name="framelinvel" objtype="site" objname="site0"/>
|
|
||||||
<touch name="touch" site="site0"/>
|
|
||||||
</sensor>
|
|
||||||
</mujoco>
|
|
||||||
Reference in New Issue
Block a user