diff --git a/doc/XMLreference.rst b/doc/XMLreference.rst index 207f55a9..6a2ca6c7 100644 --- a/doc/XMLreference.rst +++ b/doc/XMLreference.rst @@ -47,7 +47,7 @@ in the second column of the table have the following meaning: | | | +-------------------------+-------------------------+-------------------------+ | | | | | :at:`inertiafromgeom` | :at:`inertiagrouprange` | :at:`exactmeshinertia` | | | | | +-------------------------+-------------------------+-------------------------+ | -| | | | :at:`autolimits` | | | | +| | | | :at:`autolimits` | :at:`assetdir` | | | | | | +-------------------------+-------------------------+-------------------------+ | +--------------------------+----+------------------------------------------------------------------------------------+ | |_2|:el:`lengthrange` | ? | .. table:: | @@ -1549,11 +1549,11 @@ any effect. The settings here are global and apply to the entire model. :ref:`mj_setTotalmass`. :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 - 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 condition is violated. :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. :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 @@ -1585,6 +1585,9 @@ any effect. The settings here are global and apply to the entire model. :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 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` 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 diff --git a/doc/changelog.rst b/doc/changelog.rst index ec79d663..9cef90fe 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -47,6 +47,9 @@ General 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. +- 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 ^^^^^^^^^^^^^^^ diff --git a/src/user/user_model.h b/src/user/user_model.h index bf976e60..46c50c55 100644 --- a/src/user/user_model.h +++ b/src/user/user_model.h @@ -117,8 +117,8 @@ class mjCModel { //------------------------ compiler settings bool autolimits; // infer "limited" attribute based on range - double boundmass; // enfore minimum body mass - double boundinertia; // enfore minimum body diagonal inertia + double boundmass; // enforce minimum body mass + double boundinertia; // enforce minimum body diagonal inertia double settotalmass; // rescale masses and inertias; <=0: ignore bool balanceinertia; // automatically impose A + B >= C rule bool strippath; // automatically strip paths from mesh files diff --git a/src/xml/xml_native_reader.cc b/src/xml/xml_native_reader.cc index a0167cfb..a4d33b71 100644 --- a/src/xml/xml_native_reader.cc +++ b/src/xml/xml_native_reader.cc @@ -79,10 +79,11 @@ static const int nMJCF = 183; static const char* MJCF[nMJCF][mjXATTRNUM] = { {"mujoco", "!", "1", "model"}, {"<"}, - {"compiler", "*", "19", "autolimits", "boundmass", "boundinertia", "settotalmass", + {"compiler", "*", "20", "autolimits", "boundmass", "boundinertia", "settotalmass", "balanceinertia", "strippath", "coordinate", "angle", "fitaabb", "eulerseq", "meshdir", "texturedir", "discardvisual", "convexhull", "usethread", - "fusestatic", "inertiafromgeom", "inertiagrouprange", "exactmeshinertia"}, + "fusestatic", "inertiafromgeom", "inertiagrouprange", "exactmeshinertia", + "assetdir"}, {"<"}, {"lengthrange", "?", "10", "mode", "useexisting", "uselimit", "accel", "maxforce", "timeconst", "timestep", @@ -853,6 +854,11 @@ void mjXReader::Compiler(XMLElement* section, mjCModel* mod) { } 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, "texturedir", mod->texturedir); if (MapValue(section, "discardvisual", &n, bool_map, 2)) { diff --git a/src/xml/xml_urdf.cc b/src/xml/xml_urdf.cc index eddbaff5..58d9058c 100644 --- a/src/xml/xml_urdf.cc +++ b/src/xml/xml_urdf.cc @@ -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->degree = false; diff --git a/test/user/testdata/textured_torus.xml b/test/user/testdata/textured_torus.xml index 6c5d8be0..6a5b664c 100644 --- a/test/user/testdata/textured_torus.xml +++ b/test/user/testdata/textured_torus.xml @@ -1,5 +1,5 @@ - +