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:
committed by
Copybara-Service
parent
9370039015
commit
5004a4c8c5
Vendored
+35
-41
@@ -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
@@ -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
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
-->
|
||||
<option viscosity="1"/>
|
||||
|
||||
<size nconmax="500" njmax="1000"/>
|
||||
<size memory="10M"/>
|
||||
|
||||
<visual>
|
||||
<headlight diffuse=".2 .2 .2"/>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
<option timestep="0.002" solver="CG" tolerance="1e-6"/>
|
||||
|
||||
<size nconmax="300" njmax="1000" nstack="1000000"/>
|
||||
<size memory="10M"/>
|
||||
|
||||
<worldbody>
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<mujoco model="2D grid with pins">
|
||||
<include file="scene.xml"/>
|
||||
|
||||
<size nconmax="200" njmax="1000" nstack="1000000"/>
|
||||
<size memory="10M"/>
|
||||
|
||||
<worldbody>
|
||||
<composite type="grid" count="9 9 1" spacing="0.05" offset="0 0 1">
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
<option timestep="0.002" jacobian="dense"/>
|
||||
|
||||
<size nconmax="100" njmax="300" nstack="50000"/>
|
||||
<size memory="2M"/>
|
||||
|
||||
<worldbody>
|
||||
<body name="B0" pos="0 0 1">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
<option solver="CG" tolerance="1e-6" timestep=".01"/>
|
||||
|
||||
<size nconmax="6000" njmax="6000" nstack="50000000"/>
|
||||
<size memory="1G"/>
|
||||
|
||||
<visual>
|
||||
<map stiffness="100"/>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
<option timestep="0.002" jacobian="dense"/>
|
||||
|
||||
<size nconmax="100" njmax="300" nstack="50000"/>
|
||||
<size memory="2M"/>
|
||||
|
||||
<worldbody>
|
||||
<body name="B10" pos="0 0 1">
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<option solver="CG" tolerance="1e-6"/>
|
||||
|
||||
<size nconmax="500" njmax="5000" nstack="5000000"/>
|
||||
<size memory="30M"/>
|
||||
|
||||
<worldbody>
|
||||
<body pos="0 0 1">
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
<option timestep="0.005" solver="CG" iterations="30" tolerance="1e-6"/>
|
||||
|
||||
<size njmax="1000" nconmax="100" nstack="1000000"/>
|
||||
<size memory="20M"/>
|
||||
|
||||
<visual>
|
||||
<map force="0.1" zfar="30"/>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<mujoco model="22 Humanoids">
|
||||
<option timestep="0.005"/>
|
||||
|
||||
<size nconmax="1000" njmax="3000"/>
|
||||
<size memory="100M"/>
|
||||
|
||||
<asset>
|
||||
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512"/>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
<option timestep="0.005"/>
|
||||
|
||||
<size nconmax="500" njmax="1500" nstack="5000000"/>
|
||||
<size memory="100M"/>
|
||||
|
||||
<default>
|
||||
<geom solimp=".9 .9 .01"/>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
<compiler autolimits="true"/>
|
||||
|
||||
<size nconmax="100" njmax="300" nstack="500000"/>
|
||||
<size memory="2M"/>
|
||||
|
||||
<worldbody>
|
||||
<composite type="cable" curve="s" count="41 1 1" size="1" offset="-.3 0 .6" initial="none">
|
||||
@@ -53,4 +53,4 @@
|
||||
<actuator>
|
||||
<motor site="S_last" gear="0 0 0 1 0 0" ctrlrange="-.03 .03"/>
|
||||
</actuator>
|
||||
</mujoco>
|
||||
</mujoco>
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
<mujoco model="2-link 6-muscle arm">
|
||||
<option timestep="0.005" iterations="50" solver="Newton" tolerance="1e-10"/>
|
||||
|
||||
<size njmax="50" nconmax="10" nstack="200"/>
|
||||
|
||||
<visual>
|
||||
<rgba haze=".3 .3 .3 1"/>
|
||||
</visual>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <mujoco/mjtnum.h>
|
||||
#include <mujoco/mjvisualize.h>
|
||||
#include <mujoco/mjxmacro.h>
|
||||
#include <mujoco/mujoco.h>
|
||||
#include "glfw_dispatch.h"
|
||||
#include "uitools.h"
|
||||
#include "array_safety.h"
|
||||
@@ -478,7 +479,7 @@ void infotext(mj::Simulate* sim,
|
||||
// prepare info text
|
||||
mju::strcpy_arr(title, "Time\nSize\nCPU\nSolver \nFPS\nMemory");
|
||||
mju::sprintf_arr(content,
|
||||
"%-9.3f\n%d (%d con)\n%.3f\n%.1f (%d it)\n%.0f\n%.3f",
|
||||
"%-9.3f\n%d (%d con)\n%.3f\n%.1f (%d it)\n%.0f\n%.2g of %s",
|
||||
d->time,
|
||||
d->nefc, d->ncon,
|
||||
sim->run ?
|
||||
@@ -486,7 +487,8 @@ void infotext(mj::Simulate* sim,
|
||||
d->timer[mjTIMER_FORWARD].duration / mjMAX(1, d->timer[mjTIMER_FORWARD].number),
|
||||
solerr, d->solver_iter,
|
||||
1/interval,
|
||||
d->maxuse_arena/(double)(d->nstack * sizeof(mjtNum)));
|
||||
d->maxuse_arena/(double)(d->nstack * sizeof(mjtNum)),
|
||||
mju_writeNumBytes(d->nstack * sizeof(mjtNum)));
|
||||
|
||||
// add Energy if enabled
|
||||
{
|
||||
|
||||
@@ -2689,6 +2689,12 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
|
||||
njmax * m->nv * (2 * sizeof(int) + 2 * sizeof(mjtNum)) +
|
||||
njmax * njmax * (sizeof(int) + sizeof(mjtNum)));
|
||||
m->nstack += (arena_bytes / sizeof(mjtNum)) + (arena_bytes % sizeof(mjtNum) ? 1 : 0);
|
||||
|
||||
// round up to the nearest megabyte
|
||||
constexpr int kMegabyte = (1 << 20) / sizeof(mjtNum); // number of mjtNum's in 1 Mb
|
||||
int nstack_mb = m->nstack / kMegabyte;
|
||||
int residual_mb = m->nstack % kMegabyte ? 1 : 0;
|
||||
m->nstack = kMegabyte * (nstack_mb + residual_mb);
|
||||
}
|
||||
|
||||
// create data
|
||||
|
||||
@@ -847,6 +847,9 @@ void mjXWriter::Size(XMLElement* root) {
|
||||
WriteAttrInt(section, "nuser_tendon", model->nuser_tendon, 0);
|
||||
WriteAttrInt(section, "nuser_actuator", model->nuser_actuator, 0);
|
||||
WriteAttrInt(section, "nuser_sensor", model->nuser_sensor, 0);
|
||||
|
||||
// remove entire section if no attributes
|
||||
if (!section->FirstAttribute()) root->DeleteChild(section);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
<map force="0.1"/>
|
||||
</visual>
|
||||
|
||||
<size njmax="3000" nconmax="1000"/>
|
||||
<size memory="100M"/>
|
||||
|
||||
<asset>
|
||||
<mesh name="box" vertex="-1 -1 -1 1 -1 -1 1 1 -1 1 1 1 1 -1 1 -1 1 -1 -1 1 1 -1 -1 1"
|
||||
|
||||
Reference in New Issue
Block a user