Remove "global" option from [compiler/coordinate](https://mujoco.readthedocs.io/en/latest/XMLreference.html#compiler-coordinate) attribute.
Keeping this rarely-used setting complicates the compiler logic and is blocking future improvements. In order to convert older models which used this option, load and save them in MuJoCo 2.3.3 or older. PiperOrigin-RevId: 521739137 Change-Id: If0cb40d5db4879a4db9318cc2be258a7923e6e85
This commit is contained in:
committed by
Copybara-Service
parent
b327058641
commit
7cc42ecf2a
+11
-35
@@ -191,11 +191,11 @@ any effect. The settings here are global and apply to the entire model.
|
|||||||
|
|
||||||
.. _compiler-coordinate:
|
.. _compiler-coordinate:
|
||||||
|
|
||||||
:at:`coordinate`: :at-val:`[local, global], "local" for MJCF, always "local" for URDF`
|
:at:`coordinate`: :at-val:`[local, global], "local"`
|
||||||
This attribute specifies whether the frame positions and orientations in the MJCF model are expressed in local or
|
In previous versions, this attribute could be used to specify whether frame positions and orientations are expressed
|
||||||
global coordinates; recall :ref:`Coordinate frames <CFrame>`. The compiler converts global into local
|
in local or global coordinates, but the "global" option has since been removed, and will cause an error to be
|
||||||
coordinates, and mjModel always uses local coordinates. For URDF models the parser sets this attribute to "local"
|
generated. In order to convert older models which used the "global" option, load and save them in MuJoCo 2.3.3 or
|
||||||
internally, regardless of the XML setting.
|
older.
|
||||||
|
|
||||||
.. _compiler-angle:
|
.. _compiler-angle:
|
||||||
|
|
||||||
@@ -2839,23 +2839,7 @@ defined. Its body name is automatically defined as "world".
|
|||||||
.. _body-pos:
|
.. _body-pos:
|
||||||
|
|
||||||
:at:`pos`: :at-val:`real(3), optional`
|
:at:`pos`: :at-val:`real(3), optional`
|
||||||
The 3D position of the body frame, in local or global coordinates as determined by the coordinate attribute of
|
The 3D position of the body frame, in the parent coordinate frame. If undefined it defaults to (0,0,0).
|
||||||
:ref:`compiler <compiler>`. Recall the earlier discussion of local and global coordinates in :ref:`Coordinate frames
|
|
||||||
<CFrame>`. In local coordinates, if the body position is left undefined it defaults to (0,0,0). In global
|
|
||||||
coordinates, an undefined body position is inferred by the compiler through the following steps:
|
|
||||||
|
|
||||||
#. If the inertial frame is not defined via the :ref:`inertial <body-inertial>` element, it is inferred from the
|
|
||||||
geoms attached to the body. If there are no geoms, the inertial frame remains undefined. This step is applied in
|
|
||||||
both local and global coordinates.
|
|
||||||
#. If both the body frame and the inertial frame are undefined, a compile error is generated.
|
|
||||||
#. If one of these two frames is defined and the other is not, the defined one is copied into the undefined one. At
|
|
||||||
this point both frames are defined, in global coordinates.
|
|
||||||
#. The inertial frame as well as all elements defined in the body are converted to local coordinates, relative to the
|
|
||||||
body frame.
|
|
||||||
|
|
||||||
Note that whether a frame is defined or not depends on its pos attribute, which is in the special undefined state by
|
|
||||||
default. Orientation cannot be used to make this determination because it has an internal default (the unit
|
|
||||||
quaternion).
|
|
||||||
|
|
||||||
.. _body-quat:
|
.. _body-quat:
|
||||||
|
|
||||||
@@ -2868,12 +2852,7 @@ defined. Its body name is automatically defined as "world".
|
|||||||
.. _body-euler:
|
.. _body-euler:
|
||||||
|
|
||||||
:at:`quat`, :at:`axisangle`, :at:`xyaxes`, :at:`zaxis`, :at:`euler`
|
:at:`quat`, :at:`axisangle`, :at:`xyaxes`, :at:`zaxis`, :at:`euler`
|
||||||
See :ref:`COrientation`. Similar to position, the orientation specified here is
|
See :ref:`COrientation`.
|
||||||
interpreted in either local or global coordinates as determined by the coordinate attribute of
|
|
||||||
:ref:`compiler <compiler>`. Unlike position which is required in local coordinates, the orientation defaults to the
|
|
||||||
unit quaternion, thus specifying it is optional even in local coordinates. If the body frame was copied from the body
|
|
||||||
inertial frame per the above rules, the copy operation applies to both position and orientation, and the setting of
|
|
||||||
the orientation-related attributes is ignored.
|
|
||||||
|
|
||||||
.. _body-gravcomp:
|
.. _body-gravcomp:
|
||||||
|
|
||||||
@@ -3021,8 +3000,7 @@ unit quaternions.
|
|||||||
.. _body-joint-pos:
|
.. _body-joint-pos:
|
||||||
|
|
||||||
:at:`pos`: :at-val:`real(3), "0 0 0"`
|
:at:`pos`: :at-val:`real(3), "0 0 0"`
|
||||||
Position of the joint, specified in local or global coordinates as determined by the coordinate attribute of
|
Position of the joint, specified in the frame of the parent body. For free joints this attribute is ignored.
|
||||||
:ref:`compiler <compiler>`. For free joints this attribute is ignored.
|
|
||||||
|
|
||||||
.. _body-joint-axis:
|
.. _body-joint-axis:
|
||||||
|
|
||||||
@@ -3434,8 +3412,7 @@ helps clarify the role of bodies and geoms in MuJoCo.
|
|||||||
.. _body-geom-pos:
|
.. _body-geom-pos:
|
||||||
|
|
||||||
:at:`pos`: :at-val:`real(3), "0 0 0"`
|
:at:`pos`: :at-val:`real(3), "0 0 0"`
|
||||||
Position of the geom frame, in local or global coordinates as determined by the coordinate attribute of
|
Position of the geom, specified in the frame of the parent body.
|
||||||
:ref:`compiler <compiler>`.
|
|
||||||
|
|
||||||
.. _body-geom-quat:
|
.. _body-geom-quat:
|
||||||
|
|
||||||
@@ -4416,9 +4393,8 @@ geoms volumes of either body. This constraint can be used to define ball joints
|
|||||||
kinematics; the constraint solver pushes these points towards each other. In the MJCF model however only one point is
|
kinematics; the constraint solver pushes these points towards each other. In the MJCF model however only one point is
|
||||||
given. We assume that the equality constraint is exactly satisfied in the configuration in which the model is defined
|
given. We assume that the equality constraint is exactly satisfied in the configuration in which the model is defined
|
||||||
(this applies to all other constraint types as well). The compiler uses the single anchor specified in the MJCF model
|
(this applies to all other constraint types as well). The compiler uses the single anchor specified in the MJCF model
|
||||||
to compute the two body-relative anchor points in mjModel. If the MJCF model is in global coordinates, as determined
|
to compute the two body-relative anchor points in mjModel. Specified relative to the local coordinate frame of
|
||||||
by the coordinate attribute of :ref:`compiler <compiler>`, the anchor is specified in global coordinates. Otherwise
|
the *first* body.
|
||||||
the anchor is specified relative to the local coordinate frame of the *first* body.
|
|
||||||
|
|
||||||
|
|
||||||
.. _equality-weld:
|
.. _equality-weld:
|
||||||
|
|||||||
Vendored
+16
-17
@@ -1,6 +1,4 @@
|
|||||||
<mujoco model="example">
|
<mujoco model="example">
|
||||||
<compiler coordinate="global"/>
|
|
||||||
|
|
||||||
<default>
|
<default>
|
||||||
<geom rgba=".8 .6 .4 1"/>
|
<geom rgba=".8 .6 .4 1"/>
|
||||||
</default>
|
</default>
|
||||||
@@ -11,25 +9,26 @@
|
|||||||
|
|
||||||
<worldbody>
|
<worldbody>
|
||||||
<light pos="0 1 1" dir="0 -1 -1" diffuse="1 1 1"/>
|
<light pos="0 1 1" dir="0 -1 -1" diffuse="1 1 1"/>
|
||||||
<body>
|
<body pos="0 0 1">
|
||||||
<geom type="capsule" fromto="0 0 1 0 0 0.6" size="0.06"/>
|
<joint type="ball"/>
|
||||||
<joint type="ball" pos="0 0 1"/>
|
<geom type="capsule" size="0.06" fromto="0 0 0 0 0 -.4"/>
|
||||||
<body>
|
<body pos="0 0 -0.4">
|
||||||
<geom type="capsule" fromto="0 0 0.6 0.3 0 0.6" size="0.04"/>
|
<joint axis="0 1 0"/>
|
||||||
<joint type="hinge" pos="0 0 0.6" axis="0 1 0"/>
|
<joint axis="1 0 0"/>
|
||||||
<joint type="hinge" pos="0 0 0.6" axis="1 0 0"/>
|
<geom type="capsule" size="0.04" fromto="0 0 0 .3 0 0"/>
|
||||||
<body>
|
<body pos=".3 0 0">
|
||||||
<geom type="ellipsoid" pos="0.4 0 0.6" size="0.1 0.08 0.02"/>
|
<joint axis="0 1 0"/>
|
||||||
<site name="end1" pos="0.5 0 0.6" type="sphere" size="0.01"/>
|
<joint axis="0 0 1"/>
|
||||||
<joint type="hinge" pos="0.3 0 0.6" axis="0 1 0"/>
|
<geom pos=".1 0 0" size="0.1 0.08 0.02" type="ellipsoid"/>
|
||||||
<joint type="hinge" pos="0.3 0 0.6" axis="0 0 1"/>
|
<site name="end1" pos="0.2 0 0" size="0.01"/>
|
||||||
</body>
|
</body>
|
||||||
</body>
|
</body>
|
||||||
</body>
|
</body>
|
||||||
<body>
|
|
||||||
<geom type="cylinder" fromto="0.5 0 0.2 0.5 0 0" size="0.07"/>
|
<body pos="0.3 0 0.1">
|
||||||
<site name="end2" pos="0.5 0 0.2" type="sphere" size="0.01"/>
|
|
||||||
<joint type="free"/>
|
<joint type="free"/>
|
||||||
|
<geom size="0.07 0.1" type="cylinder"/>
|
||||||
|
<site name="end2" pos="0 0 0.1" size="0.01"/>
|
||||||
</body>
|
</body>
|
||||||
</worldbody>
|
</worldbody>
|
||||||
|
|
||||||
|
|||||||
Vendored
+561
-577
File diff suppressed because it is too large
Load Diff
Vendored
+13
-13
@@ -8,22 +8,22 @@
|
|||||||
</asset>
|
</asset>
|
||||||
<worldbody>
|
<worldbody>
|
||||||
<light pos="0 1 1" dir="0 -0.707107 -0.707107" diffuse="1 1 1"/>
|
<light pos="0 1 1" dir="0 -0.707107 -0.707107" diffuse="1 1 1"/>
|
||||||
<body pos="0 0 0.8" gravcomp="0">
|
<body pos="0 0 1">
|
||||||
<joint pos="0 0 0.2" type="ball"/>
|
<joint pos="0 0 0" type="ball"/>
|
||||||
<geom size="0.06 0.2" type="capsule"/>
|
<geom size="0.06 0.2" pos="0 0 -0.2" type="capsule"/>
|
||||||
<body pos="0.15 0 -0.2" quat="0.707107 0 -0.707107 0" gravcomp="0">
|
<body pos="0 0 -0.4">
|
||||||
<joint pos="0 0 0.15" axis="0 1 0"/>
|
<joint pos="0 0 0" axis="0 1 0"/>
|
||||||
<joint pos="0 0 0.15" axis="0 0 -1"/>
|
<joint pos="0 0 0" axis="1 0 0"/>
|
||||||
<geom size="0.04 0.15" type="capsule"/>
|
<geom size="0.04 0.15" pos="0.15 0 0" quat="0.707107 0 -0.707107 0" type="capsule"/>
|
||||||
<body pos="0 0 -0.25" quat="0.707107 0 0.707107 0" gravcomp="0">
|
<body pos="0.3 0 0">
|
||||||
<joint pos="-0.1 0 0" axis="0 1 0"/>
|
<joint pos="0 0 0" axis="0 1 0"/>
|
||||||
<joint pos="-0.1 0 0" axis="0 0 1"/>
|
<joint pos="0 0 0" axis="0 0 1"/>
|
||||||
<geom size="0.1 0.08 0.02" type="ellipsoid"/>
|
<geom size="0.1 0.08 0.02" pos="0.1 0 0" type="ellipsoid"/>
|
||||||
<site name="end1" pos="0.1 0 0" size="0.01"/>
|
<site name="end1" pos="0.2 0 0" size="0.01"/>
|
||||||
</body>
|
</body>
|
||||||
</body>
|
</body>
|
||||||
</body>
|
</body>
|
||||||
<body pos="0.5 0 0.1" gravcomp="0">
|
<body pos="0.3 0 0.1">
|
||||||
<joint type="free"/>
|
<joint type="free"/>
|
||||||
<geom size="0.07 0.1" type="cylinder"/>
|
<geom size="0.07 0.1" type="cylinder"/>
|
||||||
<site name="end2" pos="0 0 0.1" size="0.01"/>
|
<site name="end2" pos="0 0 0.1" size="0.01"/>
|
||||||
|
|||||||
Vendored
+59
-63
@@ -1,72 +1,68 @@
|
|||||||
<mujoco model="test">
|
<mujoco model="tendon">
|
||||||
<compiler coordinate="global"/>
|
<compiler autolimits="true"/>
|
||||||
|
|
||||||
<default>
|
<visual>
|
||||||
<geom rgba=".9 .7 .1 1" size="0.01"/>
|
<headlight diffuse="0.7 0.7 0.7"/>
|
||||||
<site type="sphere" rgba=".9 .9 .9 1" size="0.005"/>
|
</visual>
|
||||||
<joint type="hinge" axis="0 1 0" limited="true" range="0 60" solimplimit="0.95 0.95 0.1"/>
|
|
||||||
</default>
|
|
||||||
|
|
||||||
<visual>
|
<default class="main">
|
||||||
<headlight diffuse=".7 .7 .7"/>
|
<joint axis="0 0 1" solimplimit="0.95 0.95 0.1 0.5 2" range="0 60"/>
|
||||||
</visual>
|
<geom size="0.01 0 0" rgba="0.9 0.7 0.1 1"/>
|
||||||
|
<site rgba="0.9 0.9 0.9 1"/>
|
||||||
|
</default>
|
||||||
|
|
||||||
<worldbody>
|
<worldbody>
|
||||||
<body>
|
<body pos="-0.03 0 0.175">
|
||||||
<geom type="cylinder" fromto="-0.03 0 0.2 -0.03 0 0.15"
|
<joint pos="0 0 0.025" limited="false" type="slide"/>
|
||||||
size="0.03" rgba=".2 .2 .5 1" density="5000"/>
|
<geom size="0.03 0.025" type="cylinder" density="5000" rgba="0.2 0.2 0.5 1"/>
|
||||||
<joint type="slide" pos="-0.03 0 0.2" axis="0 0 1" limited="false"/>
|
<site name="s1" pos="0 0 0.025"/>
|
||||||
<site name="s1" pos="-0.03 0 0.2"/>
|
</body>
|
||||||
|
|
||||||
|
<site name="s2" pos="-0.03 0 0.32"/>
|
||||||
|
|
||||||
|
<body pos="0.0242857 0 0.3" quat="1 1 1 1">
|
||||||
|
<joint pos="0 0 -0.0242857"/>
|
||||||
|
<geom size="0.01 0.05" pos="0 0 0.0257143" quat="0 -1 -1 0" type="capsule"/>
|
||||||
|
<geom name="g1" size="0.02 0.015" pos="0 0 -0.0242857" quat="0 -1 0 -1" type="cylinder" rgba=".3 .9 .3 .4"/>
|
||||||
|
<site name="s3" pos="0 0.02 -0.00428571" quat="0.5 -0.5 -0.5 -0.5"/>
|
||||||
|
|
||||||
|
<body pos="0 0 0.1">
|
||||||
|
<joint pos="0 0 -0.0242857"/>
|
||||||
|
<geom size="0.01 0.05" pos="0 0 0.0257143" quat="0 -1 -1 0" type="capsule"/>
|
||||||
|
<geom name="g2" size="0.02 0.015" pos="0 0 -0.0242857" quat="0 -1 0 -1" type="cylinder" rgba=".3 .9 .3 .4"/>
|
||||||
|
<site name="s4" pos="0 0.01 0.00571429" quat="0.5 -0.5 -0.5 -0.5"/>
|
||||||
|
<site name="s5" pos="0 0.02 0.0257143" quat="0.5 -0.5 -0.5 -0.5"/>
|
||||||
|
<site name="side2" pos="0 0.03 -0.0242857" quat="0.5 -0.5 -0.5 -0.5"/>
|
||||||
|
|
||||||
|
<body pos="0 0 0.09">
|
||||||
|
<joint pos="0 0 -0.0143443"/>
|
||||||
|
<geom size="0.01 0.035" pos="0 0 0.0206557" quat="0 1 1 0" type="capsule"/>
|
||||||
|
<geom name="g3" size="0.02 0.015" pos="0 0 -0.0143443" quat="0 1 0 1" type="cylinder" rgba=".3 .9 .3 .4"/>
|
||||||
|
<site name="s6" pos="0 0.01 0.0156557" quat="1 -1 -1 -1"/>
|
||||||
|
<site name="side3" pos="0 0.03 -0.0143443" quat="1 -1 -1 -1"/>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<site name="s2" pos="-0.03 0 0.32"/>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<geom type="capsule" fromto="0 0 0.3 0.1 0 0.3"/>
|
|
||||||
<geom name="g1" type="cylinder" fromto="0.0 0.015 0.3 0.0 -0.015 0.3"
|
|
||||||
size="0.02" rgba=".3 .9 .3 .4"/>
|
|
||||||
<joint pos="0 0 0.3"/>
|
|
||||||
<site name="s3" pos="0.02 0 0.32"/>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<geom type="capsule" fromto="0.1 0 0.3 0.2 0 0.3"/>
|
|
||||||
<geom name="g2" type="cylinder" fromto="0.1 0.015 0.3 0.1 -0.015 0.3"
|
|
||||||
size="0.02" rgba=".3 .9 .3 .4"/>
|
|
||||||
<joint pos="0.1 0 0.3"/>
|
|
||||||
<site name="s4" pos="0.13 0 0.31"/>
|
|
||||||
<site name="s5" pos="0.15 0 0.32"/>
|
|
||||||
<site name="side2" pos="0.1 0 0.33"/>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<geom type="capsule" fromto="0.2 0 0.3 0.27 0 0.3"/>
|
|
||||||
<geom name="g3" type="cylinder" fromto="0.2 0.015 0.3 0.2 -0.015 0.3"
|
|
||||||
size="0.02" rgba=".3 .9 .3 .4"/>
|
|
||||||
<joint pos="0.2 0 0.3"/>
|
|
||||||
<site name="s6" pos="0.23 0 0.31"/>
|
|
||||||
<site name="side3" pos="0.2 0 0.33"/>
|
|
||||||
</body>
|
|
||||||
</body>
|
|
||||||
</body>
|
</body>
|
||||||
</worldbody>
|
</body>
|
||||||
|
</worldbody>
|
||||||
|
|
||||||
<tendon>
|
<tendon>
|
||||||
<spatial width="0.002" rgba=".95 .3 .3 1" limited="true" range="0 0.33">
|
<spatial range="0 0.33" width="0.002" rgba=".95 .3 .3 1">
|
||||||
<site site="s1"/>
|
<site site="s1"/>
|
||||||
<site site="s2"/>
|
<site site="s2"/>
|
||||||
<geom geom="g1"/>
|
<geom geom="g1"/>
|
||||||
<site site="s3"/>
|
<site site="s3"/>
|
||||||
|
|
||||||
<pulley divisor="2"/>
|
<pulley divisor="2"/>
|
||||||
<site site="s3"/>
|
<site site="s3"/>
|
||||||
<geom geom="g2" sidesite="side2"/>
|
<geom geom="g2" sidesite="side2"/>
|
||||||
<site site="s4"/>
|
<site site="s4"/>
|
||||||
|
|
||||||
<pulley divisor="2"/>
|
<pulley divisor="2"/>
|
||||||
<site site="s3"/>
|
<site site="s3"/>
|
||||||
<geom geom="g2" sidesite="side2"/>
|
<geom geom="g2" sidesite="side2"/>
|
||||||
<site site="s5"/>
|
<site site="s5"/>
|
||||||
<geom geom="g3" sidesite="side3"/>
|
<geom geom="g3" sidesite="side3"/>
|
||||||
<site site="s6"/>
|
<site site="s6"/>
|
||||||
</spatial>
|
</spatial>
|
||||||
</tendon>
|
</tendon>
|
||||||
</mujoco>
|
</mujoco>
|
||||||
|
|||||||
+6
-2
@@ -8,12 +8,16 @@ Upcoming version (not yet released)
|
|||||||
General
|
General
|
||||||
^^^^^^^
|
^^^^^^^
|
||||||
|
|
||||||
|
- Removed the "global" setting of the :ref:`compiler/coordinate<compiler-coordinate>` attribute. This rarely-used
|
||||||
|
setting complicates the compiler logic and is blocking future improvements. In order to convert older models which
|
||||||
|
used this option, load and save them in MuJoCo 2.3.3 or older.
|
||||||
|
|
||||||
.. image:: images/changelog/ellipsoidinertia.gif
|
.. image:: images/changelog/ellipsoidinertia.gif
|
||||||
:align: right
|
:align: right
|
||||||
:width: 240px
|
:width: 240px
|
||||||
|
|
||||||
- Added :ref:`ellipsoidinertia<visual-global-ellipsoidinertia>` to visualize equivalent inertias with ellipsoids instead
|
- Added :ref:`visual-global<visual-global>` flag :ref:`ellipsoidinertia<visual-global-ellipsoidinertia>` to visualize
|
||||||
of the default boxes.
|
equivalent body inertias with ellipsoids instead of the default boxes.
|
||||||
- Added documentation for :ref:`engine plugins<exPlugin>`.
|
- Added documentation for :ref:`engine plugins<exPlugin>`.
|
||||||
|
|
||||||
Bug fixes
|
Bug fixes
|
||||||
|
|||||||
+10
-45
@@ -182,11 +182,11 @@ no class is specified in the present element but one or more of its ancestor bod
|
|||||||
childclass from the nearest ancestor body is used. If the present element specifies a class, that class is used
|
childclass from the nearest ancestor body is used. If the present element specifies a class, that class is used
|
||||||
regardless of any childclass attributes in its ancestor bodies.
|
regardless of any childclass attributes in its ancestor bodies.
|
||||||
|
|
||||||
Some attributes, such as body position in models defined in global coordinates, can be in a special undefined state.
|
Some attributes, such as body inertia, can be in a special undefined state. This instructs the compiler to infer the
|
||||||
This instructs the compiler to infer the corresponding value from other information, in this case the positions of the
|
corresponding value from other information, in this case the inertias of the geoms attached to the body. The undefined
|
||||||
geoms attached to the body. The undefined state cannot be entered in the XML file. Therefore once an attribute is
|
state cannot be entered in the XML file. Therefore once an attribute is defined in a given class, it cannot be undefined
|
||||||
defined in a given class, it cannot be undefined in that class or in any of its child classes. So if the goal is to
|
in that class or in any of its child classes. So if the goal is to leave a certain attribute undefined in a given model
|
||||||
leave a certain attribute undefined in a given model element, it must be undefined in the active defaults class.
|
element, it must be undefined in the active defaults class.
|
||||||
|
|
||||||
A final twist here is actuators. They are different because some of the actuator-related elements are actually
|
A final twist here is actuators. They are different because some of the actuator-related elements are actually
|
||||||
shortcuts, and shortcuts interact with the defaults setting mechanism in a non-obvious way. This is explained in the
|
shortcuts, and shortcuts interact with the defaults setting mechanism in a non-obvious way. This is explained in the
|
||||||
@@ -197,47 +197,12 @@ shortcuts, and shortcuts interact with the defaults setting mechanism in a non-o
|
|||||||
Coordinate frames
|
Coordinate frames
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
After compilation the positions and orientations of all elements defined in the kinematic tree are expressed in local
|
The positions and orientations of all elements defined in the kinematic tree are expressed in local coordinates,
|
||||||
coordinates, relative to the parent body for bodies, and relative to the body that owns the element for geoms, joints,
|
relative to the parent body for bodies, and relative to the body that owns the element for geoms, joints, sites, cameras
|
||||||
sites, cameras and lights. Consequently, when a compiled model is saved as MJCF, the coordinates are always local.
|
and lights.
|
||||||
However when the user writes an MJCF file, the coordinates can be either local or global, as specified by the
|
|
||||||
:at:`coordinate` attribute of :ref:`compiler <compiler>`. This setting applies to all position and
|
|
||||||
orientation data in the MJCF file. A related attribute is :at:`angle`. It specifies whether all angles in the MJCF
|
|
||||||
file are expressed in degrees or radians (after compilation angles are always expressed in radians). Awareness of
|
|
||||||
these global settings is essential when constructing new models.
|
|
||||||
|
|
||||||
Global coordinates can sometimes be more intuitive and have the added benefit that body positions and orientations can
|
A related attribute is :ref:`compiler/angle<compiler-angle>`. It specifies whether angles in the MJCF file are expressed
|
||||||
be omitted. In that case the body frame is set to the body inertial frame, which can itself be omitted and inferred
|
in degrees or radians (after compilation, angles are always expressed in radians).
|
||||||
from the geom masses and inertias. When an MJCF model is defined in local coordinates on the other hand, the user must
|
|
||||||
specify the positions and orientations of the body frames explicitly. This is because if they were omitted, and the
|
|
||||||
elements inside the body were specified in local coordinates relative to the body frame, there would be no way to
|
|
||||||
infer the body frame.
|
|
||||||
|
|
||||||
Here is an example of an MJCF fragment in global coordinates:
|
|
||||||
|
|
||||||
.. code-block:: xml
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<geom type="box" pos="1 0 0" size="0.5 0.5 0.5"/>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
When this model is compiled and saved as MJCF (in local coordinates) the same fragment becomes:
|
|
||||||
|
|
||||||
.. code-block:: xml
|
|
||||||
|
|
||||||
<body pos="1 0 0">
|
|
||||||
<inertial pos="0 0 0" mass="1000" diaginertia="166.667 166.667 166.667"/>
|
|
||||||
<geom type="box" pos="0 0 0" size="0.5 0.5 0.5"/>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
The body position was set to the geom position (1 0 0), while the geom and inertial positions were set to (0 0 0)
|
|
||||||
relative to the body.
|
|
||||||
|
|
||||||
In principle the user always has a choice between local and global coordinates, but in practice this choice is viable
|
|
||||||
only when using geometric primitives rather than meshes. For meshes, the 3D vertex positions are expressed in either
|
|
||||||
local or global coordinates depending on how the mesh was designed - effectively forcing the user to adopt the same
|
|
||||||
convention for the entire model. The alternative would be to pre-process the mesh data outside MuJoCo so as to change
|
|
||||||
coordinates, but that effort is rarely justified.
|
|
||||||
|
|
||||||
.. _COrientation:
|
.. _COrientation:
|
||||||
|
|
||||||
|
|||||||
+16
-17
@@ -244,8 +244,6 @@ Next we provide a more elaborate example illustrating several features of MJCF.
|
|||||||
.. code:: xml
|
.. code:: xml
|
||||||
|
|
||||||
<mujoco model="example">
|
<mujoco model="example">
|
||||||
<compiler coordinate="global"/>
|
|
||||||
|
|
||||||
<default>
|
<default>
|
||||||
<geom rgba=".8 .6 .4 1"/>
|
<geom rgba=".8 .6 .4 1"/>
|
||||||
</default>
|
</default>
|
||||||
@@ -256,25 +254,26 @@ Next we provide a more elaborate example illustrating several features of MJCF.
|
|||||||
|
|
||||||
<worldbody>
|
<worldbody>
|
||||||
<light pos="0 1 1" dir="0 -1 -1" diffuse="1 1 1"/>
|
<light pos="0 1 1" dir="0 -1 -1" diffuse="1 1 1"/>
|
||||||
<body>
|
<body pos="0 0 1">
|
||||||
<geom type="capsule" fromto="0 0 1 0 0 0.6" size="0.06"/>
|
<joint type="ball"/>
|
||||||
<joint type="ball" pos="0 0 1"/>
|
<geom type="capsule" size="0.06" fromto="0 0 0 0 0 -.4"/>
|
||||||
<body>
|
<body pos="0 0 -0.4">
|
||||||
<geom type="capsule" fromto="0 0 0.6 0.3 0 0.6" size="0.04"/>
|
<joint axis="0 1 0"/>
|
||||||
<joint type="hinge" pos="0 0 0.6" axis="0 1 0"/>
|
<joint axis="1 0 0"/>
|
||||||
<joint type="hinge" pos="0 0 0.6" axis="1 0 0"/>
|
<geom type="capsule" size="0.04" fromto="0 0 0 .3 0 0"/>
|
||||||
<body>
|
<body pos=".3 0 0">
|
||||||
<geom type="ellipsoid" pos="0.4 0 0.6" size="0.1 0.08 0.02"/>
|
<joint axis="0 1 0"/>
|
||||||
<site name="end1" pos="0.5 0 0.6" type="sphere" size="0.01"/>
|
<joint axis="0 0 1"/>
|
||||||
<joint type="hinge" pos="0.3 0 0.6" axis="0 1 0"/>
|
<geom pos=".1 0 0" size="0.1 0.08 0.02" type="ellipsoid"/>
|
||||||
<joint type="hinge" pos="0.3 0 0.6" axis="0 0 1"/>
|
<site name="end1" pos="0.2 0 0" size="0.01"/>
|
||||||
</body>
|
</body>
|
||||||
</body>
|
</body>
|
||||||
</body>
|
</body>
|
||||||
<body>
|
|
||||||
<geom type="cylinder" fromto="0.5 0 0.2 0.5 0 0" size="0.07"/>
|
<body pos="0.3 0 0.1">
|
||||||
<site name="end2" pos="0.5 0 0.2" type="sphere" size="0.01"/>
|
|
||||||
<joint type="free"/>
|
<joint type="free"/>
|
||||||
|
<geom size="0.07 0.1" type="cylinder"/>
|
||||||
|
<site name="end2" pos="0 0 0.1" size="0.01"/>
|
||||||
</body>
|
</body>
|
||||||
</worldbody>
|
</worldbody>
|
||||||
|
|
||||||
|
|||||||
@@ -213,11 +213,6 @@ void mjCComposite::SetDefault(void) {
|
|||||||
|
|
||||||
// make composite object
|
// make composite object
|
||||||
bool mjCComposite::Make(mjCModel* model, mjCBody* body, char* error, int error_sz) {
|
bool mjCComposite::Make(mjCModel* model, mjCBody* body, char* error, int error_sz) {
|
||||||
// require local coordinates
|
|
||||||
if (model->global) {
|
|
||||||
return comperr(error, "Composite requires local coordinates", error_sz);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check geom type
|
// check geom type
|
||||||
if ((def[0].geom.type!=mjGEOM_SPHERE &&
|
if ((def[0].geom.type!=mjGEOM_SPHERE &&
|
||||||
def[0].geom.type!=mjGEOM_CAPSULE &&
|
def[0].geom.type!=mjGEOM_CAPSULE &&
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ mjCModel::mjCModel() {
|
|||||||
balanceinertia = false;
|
balanceinertia = false;
|
||||||
strippath = false;
|
strippath = false;
|
||||||
fitaabb = false;
|
fitaabb = false;
|
||||||
global = false;
|
|
||||||
degree = true;
|
degree = true;
|
||||||
euler[0] = 'x';
|
euler[0] = 'x';
|
||||||
euler[1] = 'y';
|
euler[1] = 'y';
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ class mjCModel {
|
|||||||
bool balanceinertia; // automatically impose A + B >= C rule
|
bool balanceinertia; // automatically impose A + B >= C rule
|
||||||
bool strippath; // automatically strip paths from mesh files
|
bool strippath; // automatically strip paths from mesh files
|
||||||
bool fitaabb; // meshfit to aabb instead of inertia box
|
bool fitaabb; // meshfit to aabb instead of inertia box
|
||||||
bool global; // local or global coordinates
|
|
||||||
bool degree; // angles in radians or degrees
|
bool degree; // angles in radians or degrees
|
||||||
char euler[3]; // sequence for euler rotations
|
char euler[3]; // sequence for euler rotations
|
||||||
std::string meshdir; // mesh and hfield directory
|
std::string meshdir; // mesh and hfield directory
|
||||||
|
|||||||
@@ -649,17 +649,8 @@ void mjCBody::GeomFrame(void) {
|
|||||||
// setup child local frame: pos
|
// setup child local frame: pos
|
||||||
void mjCBody::MakeLocal(double* _locpos, double* _locquat,
|
void mjCBody::MakeLocal(double* _locpos, double* _locquat,
|
||||||
const double* _pos, const double* _quat) {
|
const double* _pos, const double* _quat) {
|
||||||
// global: transform to local
|
mjuu_copyvec(_locpos, _pos, 3);
|
||||||
if (model->global) {
|
mjuu_copyvec(_locquat, _quat, 4);
|
||||||
mjuu_localpos(_locpos, _pos, pos, quat);
|
|
||||||
mjuu_localquat(_locquat, _quat, quat);
|
|
||||||
}
|
|
||||||
|
|
||||||
// local: copy
|
|
||||||
else {
|
|
||||||
mjuu_copyvec(_locpos, _pos, 3);
|
|
||||||
mjuu_copyvec(_locquat, _quat, 4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set explicitinertial to true
|
// set explicitinertial to true
|
||||||
@@ -825,9 +816,9 @@ void mjCBody::Compile(void) {
|
|||||||
}
|
}
|
||||||
userdata.resize(model->nuser_body);
|
userdata.resize(model->nuser_body);
|
||||||
|
|
||||||
// pos defaults to (0,0,0) in local coordinates
|
// pos defaults to (0,0,0)
|
||||||
if (!mjuu_defined(pos[0]) && !model->global) {
|
if (!mjuu_defined(pos[0])) {
|
||||||
mjuu_setvec(pos, 0, 0, 0);
|
mjuu_setvec(pos, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// normalize user-defined quaternions
|
// normalize user-defined quaternions
|
||||||
@@ -1112,12 +1103,8 @@ int mjCJoint::Compile(void) {
|
|||||||
mjuu_zerovec(locpos, 3);
|
mjuu_zerovec(locpos, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute local axis relative to specified body
|
// copy axis to local
|
||||||
if (model->global) {
|
mjuu_copyvec(locaxis, axis, 3);
|
||||||
mjuu_localaxis(locaxis, axis, body->quat);
|
|
||||||
} else {
|
|
||||||
mjuu_copyvec(locaxis, axis, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert reference angles to radians for hinge joints
|
// convert reference angles to radians for hinge joints
|
||||||
if (type==mjJNT_HINGE && model->degree) {
|
if (type==mjJNT_HINGE && model->degree) {
|
||||||
@@ -1930,14 +1917,8 @@ void mjCLight::Compile(void) {
|
|||||||
// ask parent body to compute our local pos and quat relative to itself
|
// ask parent body to compute our local pos and quat relative to itself
|
||||||
body->MakeLocal(locpos, locquat, pos, quat);
|
body->MakeLocal(locpos, locquat, pos, quat);
|
||||||
|
|
||||||
// copy/convert dir to local frame
|
// copy dir to local frame
|
||||||
if (model->global) {
|
mjuu_copyvec(locdir, dir, 3);
|
||||||
double mat[9], q[4] = {locquat[0], -locquat[1], -locquat[2], -locquat[3]};
|
|
||||||
mjuu_quat2mat(mat, q);
|
|
||||||
mjuu_mulvecmat(locdir, dir, mat);
|
|
||||||
} else {
|
|
||||||
mjuu_copyvec(locdir, dir, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
// get targetbodyid
|
// get targetbodyid
|
||||||
if (!targetbody.empty()) {
|
if (!targetbody.empty()) {
|
||||||
|
|||||||
@@ -863,7 +863,10 @@ void mjXReader::Compiler(XMLElement* section, mjCModel* mod) {
|
|||||||
mod->fitaabb = (n==1);
|
mod->fitaabb = (n==1);
|
||||||
}
|
}
|
||||||
if (MapValue(section, "coordinate", &n, coordinate_map, 2)) {
|
if (MapValue(section, "coordinate", &n, coordinate_map, 2)) {
|
||||||
mod->global = (n==1);
|
if (n==1) {
|
||||||
|
throw mjXError(section, "global coordinates no longer supported. To convert existing models, "
|
||||||
|
"load and save them in MuJoCo 2.3.3 or older");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (MapValue(section, "angle", &n, angle_map, 2)) {
|
if (MapValue(section, "angle", &n, angle_map, 2)) {
|
||||||
mod->degree = (n==1);
|
mod->degree = (n==1);
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ void mjXURDF::Parse(XMLElement* root) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// enforce required compiler defaults for URDF
|
// enforce required compiler defaults for URDF
|
||||||
model->global = false;
|
|
||||||
model->degree = false;
|
model->degree = false;
|
||||||
|
|
||||||
// get model name
|
// get model name
|
||||||
|
|||||||
Reference in New Issue
Block a user