Better memory setting and reporting, updated example models.

- Memory heuristic rounds up to the nearest MB.
- `simulate` reports total memory currently allocated in the info box.
- All example models use `<size memory/>` rather than legacy attributes.
- Regenerated `example_saved.xml` and reformatted original model in [overview chapter](https://mujoco.readthedocs.io/en/latest/overview.html?#examples).
- `<size>` top-level section does not get written if empty.

PiperOrigin-RevId: 486702670
Change-Id: I0306e335f32344c59562ba606664ec9d2101f8a8
This commit is contained in:
Yuval Tassa
2022-11-07 10:35:50 -08:00
committed by Copybara-Service
parent 9370039015
commit 5004a4c8c5
18 changed files with 107 additions and 101 deletions
+35 -41
View File
@@ -1,44 +1,38 @@
<mujoco model="example">
<compiler angle="radian" />
<size njmax="500" nconmax="100" />
<default class="main">
<geom size="0" rgba="0.8 0.6 0.4 1" />
<site size="0" />
</default>
<asset>
<texture type="skybox" builtin="gradient" rgb1="1 1 1" rgb2="0.6 0.8 1" width="256" height="1536" />
</asset>
<worldbody>
<light pos="0 1 1" dir="0 -0.707107 -0.707107" diffuse="1 1 1" />
<body pos="0 0 0.8">
<inertial pos="0 0 0" mass="5.20248" diaginertia="0.0964192 0.0964192 0.00936446" />
<joint pos="0 0 0.2" type="ball" />
<geom type="capsule" size="0.06 0.2" />
<body pos="0.15 0 -0.2" quat="0.707107 0 -0.707107 0">
<inertial pos="0 0 0" mass="1.70903" diaginertia="0.0171472 0.0171472 0.00136722" />
<joint pos="0 0 0.15" axis="0 1 0" />
<joint pos="0 0 0.15" axis="0 0 -1" />
<geom type="capsule" size="0.04 0.15" />
<body pos="0 0 -0.25" quat="0.707107 0 0.707107 0">
<inertial pos="0 0 0" mass="0.670206" diaginertia="0.000911481 0.00139403 0.00219828" />
<joint pos="-0.1 0 0" axis="0 1 0" />
<joint pos="-0.1 0 0" axis="0 0 1" />
<geom type="ellipsoid" size="0.1 0.08 0.02" />
<site name="end1" pos="0.1 0 0" size="0.01" />
</body>
</body>
<compiler angle="radian" autolimits="true"/>
<default class="main">
<geom rgba="0.8 0.6 0.4 1"/>
</default>
<asset>
<texture type="skybox" builtin="gradient" rgb1="1 1 1" rgb2="0.6 0.8 1" width="256" height="1536"/>
</asset>
<worldbody>
<light pos="0 1 1" dir="0 -0.707107 -0.707107" diffuse="1 1 1"/>
<body pos="0 0 0.8" gravcomp="0">
<joint pos="0 0 0.2" type="ball"/>
<geom size="0.06 0.2" type="capsule"/>
<body pos="0.15 0 -0.2" quat="0.707107 0 -0.707107 0" gravcomp="0">
<joint pos="0 0 0.15" axis="0 1 0"/>
<joint pos="0 0 0.15" axis="0 0 -1"/>
<geom size="0.04 0.15" type="capsule"/>
<body pos="0 0 -0.25" quat="0.707107 0 0.707107 0" gravcomp="0">
<joint pos="-0.1 0 0" axis="0 1 0"/>
<joint pos="-0.1 0 0" axis="0 0 1"/>
<geom size="0.1 0.08 0.02" type="ellipsoid"/>
<site name="end1" pos="0.1 0 0" size="0.01"/>
</body>
<body pos="0.5 0 0.1">
<inertial pos="0 0 0" mass="3.07876" diaginertia="0.014034 0.014034 0.00754296" />
<joint type="free" />
<geom type="cylinder" size="0.07 0.1" />
<site name="end2" pos="0 0 0.1" size="0.01" />
</body>
</worldbody>
<tendon>
<spatial limited="true" width="0.005" range="0 0.6">
<site site="end1" />
<site site="end2" />
</spatial>
</tendon>
</body>
</body>
<body pos="0.5 0 0.1" gravcomp="0">
<joint type="free"/>
<geom size="0.07 0.1" type="cylinder"/>
<site name="end2" pos="0 0 0.1" size="0.01"/>
</body>
</worldbody>
<tendon>
<spatial range="0 0.6" width="0.005">
<site site="end1"/>
<site site="end2"/>
</spatial>
</tendon>
</mujoco>
+46 -43
View File
@@ -177,14 +177,14 @@ objects and cast shadows, and a floating box with 6 DOFs (this is what the "free
.. code:: xml
<mujoco>
<worldbody>
<light diffuse=".5 .5 .5" pos="0 0 3" dir="0 0 -1"/>
<geom type="plane" size="1 1 0.1" rgba=".9 0 0 1"/>
<body pos="0 0 1">
<joint type="free"/>
<geom type="box" size=".1 .2 .3" rgba="0 .9 0 1"/>
</body>
</worldbody>
<worldbody>
<light diffuse=".5 .5 .5" pos="0 0 3" dir="0 0 -1"/>
<geom type="plane" size="1 1 0.1" rgba=".9 0 0 1"/>
<body pos="0 0 1">
<joint type="free"/>
<geom type="box" size=".1 .2 .3" rgba="0 .9 0 1"/>
</body>
</worldbody>
</mujoco>
The built-in OpenGL visualizer renders this model as:
@@ -244,43 +244,46 @@ Next we provide a more elaborate example illustrating several features of MJCF.
.. code:: xml
<mujoco model="example">
<compiler coordinate="global"/>
<default>
<geom rgba=".8 .6 .4 1"/>
</default>
<asset>
<texture type="skybox" builtin="gradient" rgb1="1 1 1" rgb2=".6 .8 1"
width="256" height="256"/>
</asset>
<worldbody>
<light pos="0 1 1" dir="0 -1 -1" diffuse="1 1 1"/>
<compiler coordinate="global"/>
<default>
<geom rgba=".8 .6 .4 1"/>
</default>
<asset>
<texture type="skybox" builtin="gradient" rgb1="1 1 1" rgb2=".6 .8 1" width="256" height="256"/>
</asset>
<worldbody>
<light pos="0 1 1" dir="0 -1 -1" diffuse="1 1 1"/>
<body>
<geom type="capsule" fromto="0 0 1 0 0 0.6" size="0.06"/>
<joint type="ball" pos="0 0 1"/>
<body>
<geom type="capsule" fromto="0 0 0.6 0.3 0 0.6" size="0.04"/>
<joint type="hinge" pos="0 0 0.6" axis="0 1 0"/>
<joint type="hinge" pos="0 0 0.6" axis="1 0 0"/>
<body>
<geom type="capsule" fromto="0 0 1 0 0 0.6" size="0.06"/>
<joint type="ball" pos="0 0 1"/>
<body>
<geom type="capsule" fromto="0 0 0.6 0.3 0 0.6" size="0.04"/>
<joint type="hinge" pos="0 0 0.6" axis="0 1 0"/>
<joint type="hinge" pos="0 0 0.6" axis="1 0 0"/>
<body>
<geom type="ellipsoid" pos="0.4 0 0.6" size="0.1 0.08 0.02"/>
<site name="end1" pos="0.5 0 0.6" type="sphere" size="0.01"/>
<joint type="hinge" pos="0.3 0 0.6" axis="0 1 0"/>
<joint type="hinge" pos="0.3 0 0.6" axis="0 0 1"/>
</body>
</body>
<geom type="ellipsoid" pos="0.4 0 0.6" size="0.1 0.08 0.02"/>
<site name="end1" pos="0.5 0 0.6" type="sphere" size="0.01"/>
<joint type="hinge" pos="0.3 0 0.6" axis="0 1 0"/>
<joint type="hinge" pos="0.3 0 0.6" axis="0 0 1"/>
</body>
<body>
<geom type="cylinder" fromto="0.5 0 0.2 0.5 0 0" size="0.07"/>
<site name="end2" pos="0.5 0 0.2" type="sphere" size="0.01"/>
<joint type="free"/>
</body>
</worldbody>
<tendon>
<spatial limited="true" range="0 0.6" width="0.005">
<site site="end1"/>
<site site="end2"/>
</spatial>
</tendon>
</body>
</body>
<body>
<geom type="cylinder" fromto="0.5 0 0.2 0.5 0 0" size="0.07"/>
<site name="end2" pos="0.5 0 0.2" type="sphere" size="0.01"/>
<joint type="free"/>
</body>
</worldbody>
<tendon>
<spatial limited="true" range="0 0.6" width="0.005">
<site site="end1"/>
<site site="end2"/>
</spatial>
</tendon>
</mujoco>
.. raw:: html