Added support for msh2.2

Now we can load flex with format 2.2 binary and ASCII.
There are two different parsing strategies. One for gmsh app and the other is for ftetwild.

Used the shark model from Scanned Objects by Google Research:
https://app.gazebosim.org/GoogleResearch/fuel/models/Weisshai_Great_White_Shark

PiperOrigin-RevId: 619229499
Change-Id: I6eb876afcbc8a00631914b093c45bde10c0caaf6
This commit is contained in:
Google DeepMind
2024-03-26 10:11:07 -07:00
committed by Copybara-Service
parent 4d2aa46e56
commit 4f0293c6cb
35 changed files with 38103 additions and 219 deletions
+8 -4
View File
@@ -3808,8 +3808,12 @@ saving the XML:
in MuJoCo can be used as a rigid geom attached to a single body. In contrast, the flex generated here corresponds to
a soft mesh with the same initial shape, where each vertex is a separate moving body (unless pinned).
**gmsh** is similar to mesh, but it loads a `GMSH file <https://gmsh.info//doc/texinfo/gmsh.html#MSH-file-format>`__
in format 4.1 (ascii or binary). The file extension can be anything; the parser recognizes the format by examining
.. _gmsh-file-docs:
**gmsh** is similar to mesh, but it loads a GMSH file in
`format 4.1 <https://gmsh.info//doc/texinfo/gmsh.html#MSH-file-format>`__
and `format 2.2 <https://gmsh.info//doc/texinfo/gmsh.html#MSH-file-format-version-2-_0028Legacy_0029>`__
(ascii or binary). The file extension can be anything; the parser recognizes the format by examining
the file header. This is a very rich file format, allowing all kinds of elements with different dimensionality and
topology. MuJoCo only supports GMSH element types 1, 2, 4 which happen to correspond to our 1D, 2D and 3D flexes and
assumes that the nodes are specified in a single block. Only the Nodes and Elements sections of the GMHS file are
@@ -3817,7 +3821,7 @@ saving the XML:
GMSH file contains meshes that are not supported by MuJoCo. :at:`dim` is automatically set to the dimensionality
specified in the GMSH file. Presently this is the only mechanism to load a large tetrahedral mesh in MuJoCo and
generate a corresponding soft entity. If such a mesh is available in a different file format, use the freely
available `GMSH software <https://gmsh.info/>`__ to convert it to GMSH 4.1.
available `GMSH software <https://gmsh.info/>`__ to convert it to GMSH in one of the supported versions.
**direct** allows the user to specify the point and element data of the flexcomp directly in the XML. Note that
flexcomp will still generate moving bodies automatically, as well as automate other settings; so it still provides
@@ -3873,7 +3877,7 @@ saving the XML:
:at:`file`: :at-val:`string, optional`
The name of the file from which a **mesh** or a **gmsh** is loaded. For mesh, the file extentsion is used to
determine the file format. Supported formats are the same as in :ref:`mesh assets<asset-mesh>`. For gmsh, the file is
expected to be in GMSH format 4.1, ascii or binary.
expected to be in GMSH format 4.1 or 2.2, ascii or binary, see :ref:`here<gmsh-file-docs>`.
.. _body-flexcomp-rigid:
+9 -5
View File
@@ -5,16 +5,20 @@ Changelog
Upcoming version (not yet released)
-----------------------------------
General
^^^^^^^
1. Added support for gmsh format 2.2, as generated by e.g. `fTetwild <https://github.com/wildmeshing/fTetWild>`__.
MJX
^^^
1. Improved performance of SAT for convex collisions.
2. Fixed bug for sphere/capsule-convex deep penetration.
3. Fixed bug where ``mjx.Data`` produced by ``mjx.put_data`` had different treedef than ``mjx.make_data``.
4. Throw an error for margin/gap for convex mesh collisions, since they are not supported.
2. Improved performance of SAT for convex collisions.
3. Fixed bug for sphere/capsule-convex deep penetration.
4. Fixed bug where ``mjx.Data`` produced by ``mjx.put_data`` had different treedef than ``mjx.make_data``.
5. Throw an error for margin/gap for convex mesh collisions, since they are not supported.
Version 3.1.3 (March 5th, 2024)
-----------------------------------
-------------------------------
General
^^^^^^^
+468 -208
View File
File diff suppressed because it is too large Load Diff
+5
View File
@@ -50,6 +50,11 @@ class mjCFlexcomp {
bool MakeMesh(mjCModel* model, char* error, int error_sz);
bool MakeGMSH(mjCModel* model, char* error, int error_sz);
void LoadGMSH(mjCModel* model, mjResource* resource);
void LoadGMSH41(char* buffer, int binary, int nodeend, int nodebegin,
int elemend, int elembegin);
void LoadGMSH22(char* buffer, int binary, int nodeend, int nodebegin,
int elemend, int elembegin);
int GridID(int ix, int iy);
int GridID(int ix, int iy, int iz);
+8 -2
View File
@@ -32,8 +32,14 @@ test_model() {
# this test can take several minutes under ASAN
return 0
fi
if [[ "$model" == */benchmark/testdata/humanoid200.xml
|| "$model" == */engine/testdata/collision_convex/stacked_boxes.xml
if [[ "$model" == */benchmark/testdata/humanoid200.xml ||
"$model" == */engine/testdata/collision_convex/stacked_boxes.xml ||
"$model" == */user/testdata/shark_41_ascii_gmshApp.xml ||
"$model" == */user/testdata/shark_22_ascii_fTetWild.xml ||
"$model" == */user/testdata/shark_22_ascii_gmshApp.xml ||
"$model" == */user/testdata/shark_22_binary_fTetWild.xml ||
"$model" == */user/testdata/shark_41_binary_gmshApp.xml ||
"$model" == */user/testdata/shark_22_binary_gmshApp.xml
]]; then
iterations=2
fi
@@ -0,0 +1,25 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG"/>
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512"/>
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3" rgb2=".2 .3 .4"/>
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2"/>
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0"/>
<map force="0.1" zfar="30"/>
<rgba haze="0.15 0.25 0.35 1"/>
<quality shadowsize="4096"/>
<global offwidth="800" offheight="800"/>
</visual>
<worldbody>
<geom name="floor" size="20 20 .05" type="plane" material="grid" condim="3"/>
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1"/>
<flexcomp name="shark" type="gmsh" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 4" mass="10" scale="1 1 1" file="shark_22_ascii_missing_element.msh">
<edge equality="true"/>
</flexcomp>
</worldbody>
</mujoco>
@@ -0,0 +1,27 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG" />
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512" />
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3"
rgb2=".2 .3 .4" />
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2" />
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0" />
<map force="0.1" zfar="30" />
<rgba haze="0.15 0.25 0.35 1" />
<quality shadowsize="4096" />
<global offwidth="800" offheight="800" />
</visual>
<worldbody>
<geom name="floor" size="20 20 .05" type="plane" material="grid" condim="3" />
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1" />
<flexcomp name="shark" type="gmsh" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 4" mass="10"
scale="1 1 1" file="shark_22_ascii_missing_node.msh">
<edge equality="true" />
</flexcomp>
</worldbody>
</mujoco>
@@ -0,0 +1,27 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG" />
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512" />
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3"
rgb2=".2 .3 .4" />
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2" />
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0" />
<map force="0.1" zfar="30" />
<rgba haze="0.15 0.25 0.35 1" />
<quality shadowsize="4096" />
<global offwidth="800" offheight="800" />
</visual>
<worldbody>
<geom name="floor" size="20 20 .05" type="plane" material="grid" condim="3" />
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1" />
<flexcomp name="shark" type="gmsh" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 4" mass="10"
scale="1 1 1" file="shark_22_ascii_missing_num_elements.msh">
<edge equality="true" />
</flexcomp>
</worldbody>
</mujoco>
@@ -0,0 +1,27 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG" />
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512" />
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3"
rgb2=".2 .3 .4" />
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2" />
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0" />
<map force="0.1" zfar="30" />
<rgba haze="0.15 0.25 0.35 1" />
<quality shadowsize="4096" />
<global offwidth="800" offheight="800" />
</visual>
<worldbody>
<geom name="floor" size="20 20 .05" type="plane" material="grid" condim="3" />
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1" />
<flexcomp name="shark" type="gmsh" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 4" mass="10"
scale="1 1 1" file="shark_22_ascii_missing_num_nodes.msh">
<edge equality="true" />
</flexcomp>
</worldbody>
</mujoco>
@@ -0,0 +1,27 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG" />
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512" />
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3"
rgb2=".2 .3 .4" />
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2" />
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0" />
<map force="0.1" zfar="30" />
<rgba haze="0.15 0.25 0.35 1" />
<quality shadowsize="4096" />
<global offwidth="800" offheight="800" />
</visual>
<worldbody>
<geom name="floor" size="20 20 .05" type="plane" material="grid" condim="3" />
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1" />
<flexcomp name="shark binary 2.2" type="gmsh" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 4"
mass="10" scale="1 1 1" file="shark_41_ascii_missing_element.msh">
<edge equality="true" />
</flexcomp>
</worldbody>
</mujoco>
@@ -0,0 +1,27 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG" />
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512" />
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3"
rgb2=".2 .3 .4" />
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2" />
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0" />
<map force="0.1" zfar="30" />
<rgba haze="0.15 0.25 0.35 1" />
<quality shadowsize="4096" />
<global offwidth="800" offheight="800" />
</visual>
<worldbody>
<geom name="floor" size="20 20 .05" type="plane" material="grid" condim="3" />
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1" />
<flexcomp name="shark binary 2.2" type="gmsh" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 4"
mass="10" scale="1 1 1" file="shark_41_ascii_missing_element_header.msh">
<edge equality="true" />
</flexcomp>
</worldbody>
</mujoco>
@@ -0,0 +1,27 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG" />
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512" />
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3"
rgb2=".2 .3 .4" />
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2" />
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0" />
<map force="0.1" zfar="30" />
<rgba haze="0.15 0.25 0.35 1" />
<quality shadowsize="4096" />
<global offwidth="800" offheight="800" />
</visual>
<worldbody>
<geom name="floor" size="20 20 .05" type="plane" material="grid" condim="3" />
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1" />
<flexcomp name="shark binary 2.2" type="gmsh" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 4"
mass="10" scale="1 1 1" file="shark_41_ascii_missing_node_header.msh">
<edge equality="true" />
</flexcomp>
</worldbody>
</mujoco>
@@ -0,0 +1,27 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG" />
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512" />
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3"
rgb2=".2 .3 .4" />
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2" />
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0" />
<map force="0.1" zfar="30" />
<rgba haze="0.15 0.25 0.35 1" />
<quality shadowsize="4096" />
<global offwidth="800" offheight="800" />
</visual>
<worldbody>
<geom name="floor" size="20 20 .05" type="plane" material="grid" condim="3" />
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1" />
<flexcomp name="shark binary 2.2" type="gmsh" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 4"
mass="10" scale="1 1 1" file="shark_41_ascii_missing_node_index.msh">
<edge equality="true" />
</flexcomp>
</worldbody>
</mujoco>
File diff suppressed because it is too large Load Diff
+25
View File
@@ -0,0 +1,25 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG"/>
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512"/>
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3" rgb2=".2 .3 .4"/>
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2"/>
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0"/>
<map force="0.1" zfar="30"/>
<rgba haze="0.15 0.25 0.35 1"/>
<quality shadowsize="4096"/>
<global offwidth="800" offheight="800"/>
</visual>
<worldbody>
<geom name="floor" size="1 1 .05" type="plane" material="grid" condim="3"/>
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1"/>
<flexcomp name="shark" type="gmsh" dim="3" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 .3" mass="10" scale="1 1 1" file="shark_22_ascii_fTetWild.msh">
<edge equality="true"/>
</flexcomp>
</worldbody>
</mujoco>
File diff suppressed because it is too large Load Diff
+25
View File
@@ -0,0 +1,25 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG"/>
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512"/>
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3" rgb2=".2 .3 .4"/>
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2"/>
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0"/>
<map force="0.1" zfar="30"/>
<rgba haze="0.15 0.25 0.35 1"/>
<quality shadowsize="4096"/>
<global offwidth="800" offheight="800"/>
</visual>
<worldbody>
<geom name="floor" size="1 1 .05" type="plane" material="grid" condim="3"/>
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1"/>
<flexcomp name="shark" type="gmsh" dim="3" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 0.3" mass="10" scale="1 1 1" file="shark_22_ascii_gmshApp.msh">
<edge equality="true"/>
</flexcomp>
</worldbody>
</mujoco>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.
+25
View File
@@ -0,0 +1,25 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG"/>
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512"/>
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3" rgb2=".2 .3 .4"/>
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2"/>
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0"/>
<map force="0.1" zfar="30"/>
<rgba haze="0.15 0.25 0.35 1"/>
<quality shadowsize="4096"/>
<global offwidth="800" offheight="800"/>
</visual>
<worldbody>
<geom name="floor" size="1 1 .05" type="plane" material="grid" condim="3"/>
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1"/>
<flexcomp name="shark" type="gmsh" dim="3" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 0.3" mass="10" scale="1 1 1" file="shark_22_binary_fTetWild.msh">
<edge equality="true"/>
</flexcomp>
</worldbody>
</mujoco>
Binary file not shown.
+25
View File
@@ -0,0 +1,25 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG"/>
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512"/>
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3" rgb2=".2 .3 .4"/>
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2"/>
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0"/>
<map force="0.1" zfar="30"/>
<rgba haze="0.15 0.25 0.35 1"/>
<quality shadowsize="4096"/>
<global offwidth="800" offheight="800"/>
</visual>
<worldbody>
<geom name="floor" size="1 1 .05" type="plane" material="grid" condim="3"/>
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1"/>
<flexcomp name="shark" type="gmsh" dim="3" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 0.3" mass="10" scale="1 1 1" file="shark_22_binary_gmshApp.msh">
<edge equality="true"/>
</flexcomp>
</worldbody>
</mujoco>
File diff suppressed because it is too large Load Diff
+25
View File
@@ -0,0 +1,25 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG"/>
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512"/>
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3" rgb2=".2 .3 .4"/>
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2"/>
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0"/>
<map force="0.1" zfar="30"/>
<rgba haze="0.15 0.25 0.35 1"/>
<quality shadowsize="4096"/>
<global offwidth="800" offheight="800"/>
</visual>
<worldbody>
<geom name="floor" size="20 20 .05" type="plane" material="grid" condim="3"/>
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1"/>
<flexcomp name="shark" type="gmsh" dim="3" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 4" mass="10" scale="1 1 1" file="shark_41_ascii_gmshApp.msh">
<edge equality="true"/>
</flexcomp>
</worldbody>
</mujoco>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.
+25
View File
@@ -0,0 +1,25 @@
<mujoco model="gmsh">
<option timestep="0.01" integrator="implicitfast" solver="CG"/>
<asset>
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="512" height="512"/>
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3" rgb2=".2 .3 .4"/>
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2"/>
</asset>
<visual>
<headlight diffuse="0.9 0.9 0.9" ambient="0.3 0.3 0.3" specular="0 0 0"/>
<map force="0.1" zfar="30"/>
<rgba haze="0.15 0.25 0.35 1"/>
<quality shadowsize="4096"/>
<global offwidth="800" offheight="800"/>
</visual>
<worldbody>
<geom name="floor" size="20 20 .05" type="plane" material="grid" condim="3"/>
<light directional="false" diffuse=".2 .2 .2" specular="0 0 0" pos="0 0 5" dir="0 0 -1"/>
<flexcomp name="shark" type="gmsh" dim="3" rgba=".8 .2 .2 1" radius="0.001" pos="0 0 4" mass="10" scale="1 1 1" file="shark_41_binary_gmshApp.msh">
<edge equality="true"/>
</flexcomp>
</worldbody>
</mujoco>
+172
View File
@@ -227,5 +227,177 @@ TEST_F(UserFlexTest, CreateBVHSuccess) {
mj_deleteData(d);
}
TEST_F(UserFlexTest, LoadMSHBinaryGMSH_41_Success) {
const std::string xml_path =
GetTestDataFilePath("user/testdata/shark_41_binary_gmshApp.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
mjData* d = mj_makeData(m);
EXPECT_THAT(m, NotNull()) << error.data();
EXPECT_EQ(m->nflexvert, 652);
EXPECT_EQ(m->nflexelem, 1654);
mj_step(m, d);
mj_deleteModel(m);
mj_deleteData(d);
}
TEST_F(UserFlexTest, LoadMSHBinaryGMSH_22_Success) {
const std::string xml_path =
GetTestDataFilePath("user/testdata/shark_22_binary_gmshApp.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
mjData* d = mj_makeData(m);
EXPECT_THAT(m, NotNull()) << error.data();
EXPECT_EQ(m->nflexvert, 644);
EXPECT_EQ(m->nflexelem, 1635);
mj_step(m, d);
mj_deleteModel(m);
mj_deleteData(d);
}
TEST_F(UserFlexTest, LoadMSHBinaryFTETWILD_22_Success) {
const std::string xml_path =
GetTestDataFilePath("user/testdata/shark_22_binary_fTetWild.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
mjData* d = mj_makeData(m);
EXPECT_THAT(m, NotNull()) << error.data();
EXPECT_EQ(m->nflexvert, 644);
EXPECT_EQ(m->nflexelem, 1635);
mj_step(m, d);
mj_deleteModel(m);
mj_deleteData(d);
}
TEST_F(UserFlexTest, LoadMSHASCIIGMSH_41_Success) {
const std::string xml_path =
GetTestDataFilePath("user/testdata/shark_41_ascii_gmshApp.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
mjData* d = mj_makeData(m);
EXPECT_THAT(m, NotNull()) << error.data();
EXPECT_EQ(m->nflexvert, 652);
EXPECT_EQ(m->nflexelem, 1654);
mj_step(m, d);
mj_deleteModel(m);
mj_deleteData(d);
}
TEST_F(UserFlexTest, LoadMSHASCIIGMSH_22_Success) {
const std::string xml_path =
GetTestDataFilePath("user/testdata/shark_22_ascii_gmshApp.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
mjData* d = mj_makeData(m);
EXPECT_THAT(m, NotNull()) << error.data();
EXPECT_EQ(m->nflexvert, 652);
EXPECT_EQ(m->nflexelem, 1654);
mj_step(m, d);
mj_deleteModel(m);
mj_deleteData(d);
}
TEST_F(UserFlexTest, LoadMSHASCIIFTETWILD_22_Success) {
const std::string xml_path =
GetTestDataFilePath("user/testdata/shark_22_ascii_fTetWild.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
mjData* d = mj_makeData(m);
EXPECT_THAT(m, NotNull()) << error.data();
EXPECT_EQ(m->nflexvert, 652);
EXPECT_EQ(m->nflexelem, 1654);
mj_step(m, d);
mj_deleteModel(m);
mj_deleteData(d);
}
TEST_F(UserFlexTest, LoadMSHASCII_41_MissingNodeHeader_Fail) {
const std::string xml_path =
GetTestDataFilePath(
"user/testdata/malformed_shark_41_ascii_missing_node_header.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
EXPECT_THAT(error.data(), HasSubstr(
"XML Error: Error: All nodes must be in single block"));
mj_deleteModel(m);
}
TEST_F(UserFlexTest, LoadMSHASCII_41_MissingNodeIndex_Fail) {
const std::string xml_path =
GetTestDataFilePath(
"user/testdata/malformed_shark_41_ascii_missing_node_index.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
EXPECT_THAT(error.data(), HasSubstr(
"XML Error: Element size must be a multiple of dim+1"));
mj_deleteModel(m);
}
TEST_F(UserFlexTest, LoadMSHASCII_41_MissingElementHeader_Fail) {
const std::string xml_path =
GetTestDataFilePath(
"user/testdata/malformed_shark_41_ascii_missing_element_header.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
EXPECT_THAT(error.data(), HasSubstr(
"XML Error: Error: All elements must be in single block"));
mj_deleteModel(m);
}
TEST_F(UserFlexTest, LoadMSHASCII_41_MissingElement_Fail) {
const std::string xml_path =
GetTestDataFilePath(
"user/testdata/malformed_shark_41_ascii_missing_element.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
EXPECT_THAT(error.data(), HasSubstr(
"XML Error: Error: Error reading Elements"));
mj_deleteModel(m);
}
TEST_F(UserFlexTest, LoadMSHASCII_22_MissingNumNodes_Fail) {
const std::string xml_path =
GetTestDataFilePath(
"user/testdata/malformed_shark_22_ascii_missing_num_nodes.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
EXPECT_THAT(error.data(), HasSubstr(
"XML Error: Element size must be a multiple of dim+1"));
mj_deleteModel(m);
}
TEST_F(UserFlexTest, LoadMSHASCII_22_MissingNode_Fail) {
const std::string xml_path =
GetTestDataFilePath(
"user/testdata/malformed_shark_22_ascii_missing_node.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
EXPECT_THAT(error.data(), HasSubstr(
"XML Error: Error: Error reading node tags"));
mj_deleteModel(m);
}
TEST_F(UserFlexTest, LoadMSHASCII_22_MissingNumElements_Fail) {
const std::string xml_path =
GetTestDataFilePath(
"user/testdata/malformed_shark_22_ascii_missing_num_elements.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
EXPECT_THAT(error.data(), HasSubstr(
"XML Error: Element size must be a multiple of dim+1"));
mj_deleteModel(m);
}
TEST_F(UserFlexTest, LoadMSHASCII_22_MissingElement_Fail) {
const std::string xml_path =
GetTestDataFilePath(
"user/testdata/malformed_shark_22_ascii_missing_element.xml");
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
EXPECT_THAT(error.data(), HasSubstr(
"XML Error: Error: Error reading Elements"));
mj_deleteModel(m);
}
} // namespace
} // namespace mujoco
+1
View File
@@ -1204,6 +1204,7 @@ TEST_F(XMLWriterTest, WriteReadCompare) {
if (absl::StrContains(p.path().string(), "malformed_") ||
absl::StrContains(p.path().string(), "touch_grid") ||
absl::StrContains(p.path().string(), "gmsh_") ||
absl::StrContains(p.path().string(), "shark_") ||
absl::StrContains(p.path().string(), "cow")) {
continue;
}