Add tendon position sensor to MJX.

PiperOrigin-RevId: 684851437
Change-Id: Ica0a30762a9cb3d612357b40b6f87cd2fc544fdb
This commit is contained in:
Taylor Howell
2024-10-11 08:47:09 -07:00
committed by Copybara-Service
parent 5fe2b88726
commit 223892c051
5 changed files with 24 additions and 5 deletions
+1
View File
@@ -24,6 +24,7 @@ MJX
- Added support for :ref:`spatial tendons <tendon-spatial>` with pulleys and external sphere and cylinder wrapping. - Added support for :ref:`spatial tendons <tendon-spatial>` with pulleys and external sphere and cylinder wrapping.
- Added sphere-cylinder and sphere-ellipsoid collision functions (:github:issue:`2126`). - Added sphere-cylinder and sphere-ellipsoid collision functions (:github:issue:`2126`).
- Fixed a bug with frictionloss constraints. - Fixed a bug with frictionloss constraints.
- Added ``TENDONPOS`` sensor.
Bug fixes Bug fixes
^^^^^^^^^ ^^^^^^^^^
+5 -5
View File
@@ -217,11 +217,11 @@ The following features are **fully supported** in MJX:
* - :ref:`Tendons <tendon>` * - :ref:`Tendons <tendon>`
- :ref:`Fixed <tendon-fixed>` - :ref:`Fixed <tendon-fixed>`
* - :ref:`Sensors <mjtSensor>` * - :ref:`Sensors <mjtSensor>`
- ``MAGNETOMETER``, ``CAMPROJECTION``, ``RANGEFINDER``, ``JOINTPOS``, ``ACTUATORPOS``, ``BALLQUAT``, ``FRAMEPOS``, - ``MAGNETOMETER``, ``CAMPROJECTION``, ``RANGEFINDER``, ``JOINTPOS``, ``TENDONPOS``, ``ACTUATORPOS``, ``BALLQUAT``,
``FRAMEXAXIS``, ``FRAMEYAXIS``, ``FRAMEZAXIS``, ``FRAMEQUAT``, ``SUBTREECOM``, ``CLOCK``, ``VELOCIMETER``, ``FRAMEPOS``, ``FRAMEXAXIS``, ``FRAMEYAXIS``, ``FRAMEZAXIS``, ``FRAMEQUAT``, ``SUBTREECOM``, ``CLOCK``,
``GYRO``, ``JOINTVEL``, ``ACTUATORVEL``, ``BALLANGVEL``, ``FRAMELINVEL``, ``FRAMEANGVEL``, ``SUBTREELINVEL``, ``VELOCIMETER``, ``GYRO``, ``JOINTVEL``, ``ACTUATORVEL``, ``BALLANGVEL``, ``FRAMELINVEL``, ``FRAMEANGVEL``,
``SUBTREEANGMOM``, ``ACCELEROMETER``, ``FORCE``, ``TORQUE``, ``ACTUATORFRC``, ``JOINTACTFRC``, ``FRAMELINACC``, ``SUBTREELINVEL``, ``SUBTREEANGMOM``, ``ACCELEROMETER``, ``FORCE``, ``TORQUE``, ``ACTUATORFRC``, ``JOINTACTFRC``,
``FRAMEANGACC``. ``FRAMELINACC``, ``FRAMEANGACC``.
The following features are **in development** and coming soon: The following features are **in development** and coming soon:
+2
View File
@@ -166,6 +166,8 @@ def sensor_pos(m: Model, d: Data) -> Data:
continue # avoid adding to sensors/adrs list a second time continue # avoid adding to sensors/adrs list a second time
elif sensor_type == SensorType.JOINTPOS: elif sensor_type == SensorType.JOINTPOS:
sensor = d.qpos[m.jnt_qposadr[objid]] sensor = d.qpos[m.jnt_qposadr[objid]]
elif sensor_type == SensorType.TENDONPOS:
sensor = d.ten_length[objid]
elif sensor_type == SensorType.ACTUATORPOS: elif sensor_type == SensorType.ACTUATORPOS:
sensor = d.actuator_length[objid] sensor = d.actuator_length[objid]
elif sensor_type == SensorType.BALLQUAT: elif sensor_type == SensorType.BALLQUAT:
+2
View File
@@ -308,6 +308,7 @@ class SensorType(enum.IntEnum):
CAMPROJECTION: camera projection CAMPROJECTION: camera projection
RANGEFINDER: rangefinder RANGEFINDER: rangefinder
JOINTPOS: joint position JOINTPOS: joint position
TENDONPOS: scalar tendon position
ACTUATORPOS: actuator position ACTUATORPOS: actuator position
BALLQUAT: ball joint orientation BALLQUAT: ball joint orientation
FRAMEPOS: frame position FRAMEPOS: frame position
@@ -338,6 +339,7 @@ class SensorType(enum.IntEnum):
CAMPROJECTION = mujoco.mjtSensor.mjSENS_CAMPROJECTION CAMPROJECTION = mujoco.mjtSensor.mjSENS_CAMPROJECTION
RANGEFINDER = mujoco.mjtSensor.mjSENS_RANGEFINDER RANGEFINDER = mujoco.mjtSensor.mjSENS_RANGEFINDER
JOINTPOS = mujoco.mjtSensor.mjSENS_JOINTPOS JOINTPOS = mujoco.mjtSensor.mjSENS_JOINTPOS
TENDONPOS = mujoco.mjtSensor.mjSENS_TENDONPOS
ACTUATORPOS = mujoco.mjtSensor.mjSENS_ACTUATORPOS ACTUATORPOS = mujoco.mjtSensor.mjSENS_ACTUATORPOS
BALLQUAT = mujoco.mjtSensor.mjSENS_BALLQUAT BALLQUAT = mujoco.mjtSensor.mjSENS_BALLQUAT
FRAMEPOS = mujoco.mjtSensor.mjSENS_FRAMEPOS FRAMEPOS = mujoco.mjtSensor.mjSENS_FRAMEPOS
@@ -5,6 +5,7 @@
-camprojection -camprojection
-rangefinder -rangefinder
-jointpos -jointpos
-tendonpos
-actuatorpos -actuatorpos
-ballquat -ballquat
-framepos -framepos
@@ -107,8 +108,20 @@
ctrllimited="true"/> ctrllimited="true"/>
</actuator> </actuator>
<tendon>
<fixed name="fixed">
<joint joint="hinge0" coef=".1"/>
<joint joint="hinge1" coef=".2"/>
</fixed>
<spatial name="spatial">
<site site="site0"/>
<site site="site1"/>
</spatial>
</tendon>
<sensor> <sensor>
<torque site="site_torque"/> <torque site="site_torque"/>
<tendonpos tendon="fixed"/>
<magnetometer name="magnetometer0" site="site0"/> <magnetometer name="magnetometer0" site="site0"/>
<velocimeter name="velocimeter0" site="site0"/> <velocimeter name="velocimeter0" site="site0"/>
<velocimeter name="velocimeter0cutoff" site="site0" cutoff="3e-4"/> <velocimeter name="velocimeter0cutoff" site="site0" cutoff="3e-4"/>
@@ -117,6 +130,7 @@
<rangefinder name="rangefinder0" site="site_rangefinder0"/> <rangefinder name="rangefinder0" site="site_rangefinder0"/>
<accelerometer name="accelerometer1" site="site1"/> <accelerometer name="accelerometer1" site="site1"/>
<force site="site_force"/> <force site="site_force"/>
<tendonpos tendon="spatial"/>
<jointpos name="jointpos0" joint="hinge0"/> <jointpos name="jointpos0" joint="hinge0"/>
<jointpos name="jointpos0cutoff" joint="hinge0" cutoff="1e-4"/> <jointpos name="jointpos0cutoff" joint="hinge0" cutoff="1e-4"/>
<jointvel name="jointvel0" joint="hinge0"/> <jointvel name="jointvel0" joint="hinge0"/>