Add assetdir compiler option.

PiperOrigin-RevId: 478117894
Change-Id: I4a93108e00558034aa02d22047da80adfa4232b2
This commit is contained in:
Kevin Zakka
2022-09-30 17:58:51 -07:00
committed by Copybara-Service
parent 8a8305d3ca
commit cce35e1816
6 changed files with 21 additions and 9 deletions
+6 -3
View File
@@ -47,7 +47,7 @@ in the second column of the table have the following meaning:
| | | +-------------------------+-------------------------+-------------------------+ | | | | +-------------------------+-------------------------+-------------------------+ |
| | | | :at:`inertiafromgeom` | :at:`inertiagrouprange` | :at:`exactmeshinertia` | | | | | | :at:`inertiafromgeom` | :at:`inertiagrouprange` | :at:`exactmeshinertia` | |
| | | +-------------------------+-------------------------+-------------------------+ | | | | +-------------------------+-------------------------+-------------------------+ |
| | | | :at:`autolimits` | | | | | | | | :at:`autolimits` | :at:`assetdir` | | |
| | | +-------------------------+-------------------------+-------------------------+ | | | | +-------------------------+-------------------------+-------------------------+ |
+--------------------------+----+------------------------------------------------------------------------------------+ +--------------------------+----+------------------------------------------------------------------------------------+
| |_2|:el:`lengthrange` | ? | .. table:: | | |_2|:el:`lengthrange` | ? | .. table:: |
@@ -1549,11 +1549,11 @@ any effect. The settings here are global and apply to the entire model.
:ref:`mj_setTotalmass`. :ref:`mj_setTotalmass`.
:at:`balanceinertia`: :at-val:`[false, true], "false"` :at:`balanceinertia`: :at-val:`[false, true], "false"`
A valid diagonal inertia matrix must satisfy A+B>=C for all permutations of the three diagonal elements. Some poorly A valid diagonal inertia matrix must satisfy A+B>=C for all permutations of the three diagonal elements. Some poorly
designed models violate this constraint, which will normally result in compile error. If this attribute is set to designed models violate this constraint, which will normally result in a compile error. If this attribute is set to
"true", the compiler will silently set all three diagonal elements to their average value whenever the above "true", the compiler will silently set all three diagonal elements to their average value whenever the above
condition is violated. condition is violated.
:at:`strippath`: :at-val:`[false, true], "false" for MJCF, "true" for URDF` :at:`strippath`: :at-val:`[false, true], "false" for MJCF, "true" for URDF`
The this attribute is "true", the parser will remove any path information in file names specified in the model. This When this attribute is "true", the parser will remove any path information in file names specified in the model. This
is useful for loading models created on a different system using a different directory structure. is useful for loading models created on a different system using a different directory structure.
:at:`coordinate`: :at-val:`[local, global], "local" for MJCF, always "local" for URDF` :at:`coordinate`: :at-val:`[local, global], "local" for MJCF, always "local" for URDF`
This attribute specifies whether the frame positions and orientations in the MJCF model are expressed in local or This attribute specifies whether the frame positions and orientations in the MJCF model are expressed in local or
@@ -1585,6 +1585,9 @@ any effect. The settings here are global and apply to the entire model.
:at:`texturedir`: :at-val:`string, optional` :at:`texturedir`: :at-val:`string, optional`
This attribute is used to instruct the compiler where to look for texture files. It works in the same way as meshdir This attribute is used to instruct the compiler where to look for texture files. It works in the same way as meshdir
above. above.
:at:`assetdir`: :at-val:`string, optional`
This attribute sets the values of both :at:`meshdir` and :at:`texturedir` above. Values in the latter attributes take
precedence over :at:`assetdir`.
:at:`discardvisual`: :at-val:`[false, true], "false" for MJCF, "true" for URDF` :at:`discardvisual`: :at-val:`[false, true], "false" for MJCF, "true" for URDF`
This attribute instructs the parser to discard "visual geoms", defined as geoms whose contype and conaffinity This attribute instructs the parser to discard "visual geoms", defined as geoms whose contype and conaffinity
attributes are both set to 0. This functionality is useful for models that contain two sets of geoms, one for attributes are both set to 0. This functionality is useful for models that contain two sets of geoms, one for
+3
View File
@@ -47,6 +47,9 @@ General
as global overrides. Note the new mechanism is currently undocumented except in code, as we test it internally. as global overrides. Note the new mechanism is currently undocumented except in code, as we test it internally.
If you are interested in using the plugin mechanism, please get in touch first. If you are interested in using the plugin mechanism, please get in touch first.
- Added :at:`assetdir` compiler option, which sets the values of both :at:`meshdir` and :at:`texturedir`. Values in
the latter attributes take precedence over :at:`assetdir`.
Python bindings Python bindings
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
+2 -2
View File
@@ -117,8 +117,8 @@ class mjCModel {
//------------------------ compiler settings //------------------------ compiler settings
bool autolimits; // infer "limited" attribute based on range bool autolimits; // infer "limited" attribute based on range
double boundmass; // enfore minimum body mass double boundmass; // enforce minimum body mass
double boundinertia; // enfore minimum body diagonal inertia double boundinertia; // enforce minimum body diagonal inertia
double settotalmass; // rescale masses and inertias; <=0: ignore double settotalmass; // rescale masses and inertias; <=0: ignore
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
+8 -2
View File
@@ -79,10 +79,11 @@ static const int nMJCF = 183;
static const char* MJCF[nMJCF][mjXATTRNUM] = { static const char* MJCF[nMJCF][mjXATTRNUM] = {
{"mujoco", "!", "1", "model"}, {"mujoco", "!", "1", "model"},
{"<"}, {"<"},
{"compiler", "*", "19", "autolimits", "boundmass", "boundinertia", "settotalmass", {"compiler", "*", "20", "autolimits", "boundmass", "boundinertia", "settotalmass",
"balanceinertia", "strippath", "coordinate", "angle", "fitaabb", "eulerseq", "balanceinertia", "strippath", "coordinate", "angle", "fitaabb", "eulerseq",
"meshdir", "texturedir", "discardvisual", "convexhull", "usethread", "meshdir", "texturedir", "discardvisual", "convexhull", "usethread",
"fusestatic", "inertiafromgeom", "inertiagrouprange", "exactmeshinertia"}, "fusestatic", "inertiafromgeom", "inertiagrouprange", "exactmeshinertia",
"assetdir"},
{"<"}, {"<"},
{"lengthrange", "?", "10", "mode", "useexisting", "uselimit", {"lengthrange", "?", "10", "mode", "useexisting", "uselimit",
"accel", "maxforce", "timeconst", "timestep", "accel", "maxforce", "timeconst", "timestep",
@@ -853,6 +854,11 @@ void mjXReader::Compiler(XMLElement* section, mjCModel* mod) {
} }
memcpy(mod->euler, text.c_str(), 3); memcpy(mod->euler, text.c_str(), 3);
} }
if (ReadAttrTxt(section, "assetdir", text)) {
mod->meshdir = text;
mod->texturedir = text;
}
// meshdir and texturedir take precedence over assetdir
ReadAttrTxt(section, "meshdir", mod->meshdir); ReadAttrTxt(section, "meshdir", mod->meshdir);
ReadAttrTxt(section, "texturedir", mod->texturedir); ReadAttrTxt(section, "texturedir", mod->texturedir);
if (MapValue(section, "discardvisual", &n, bool_map, 2)) { if (MapValue(section, "discardvisual", &n, bool_map, 2)) {
+1 -1
View File
@@ -96,7 +96,7 @@ void mjXURDF::Parse(XMLElement* root) {
} }
} }
// enfore required compiler defaults for URDF // enforce required compiler defaults for URDF
model->global = false; model->global = false;
model->degree = false; model->degree = false;
+1 -1
View File
@@ -1,5 +1,5 @@
<mujoco> <mujoco>
<compiler meshdir="textured_torus" texturedir="textured_torus"/> <compiler assetdir="textured_torus"/>
<asset> <asset>
<mesh name="torus" file="textured_torus.obj"/> <mesh name="torus" file="textured_torus.obj"/>
<mesh name="flipped_torus" file="textured_torus.obj" scale="-1 1 1"/> <mesh name="flipped_torus" file="textured_torus.obj" scale="-1 1 1"/>