Fix a bug that was causing a mismatch between the orientation of the mesh frame and the vertex coordinates.

PiperOrigin-RevId: 502624466
Change-Id: Ib28fd2a118b6572be98fadb078fa2262b21cbfc0
This commit is contained in:
Alessio Quaglino
2023-01-17 10:30:58 -08:00
committed by Copybara-Service
parent 06557c1489
commit 6ba4d6f0de
4 changed files with 29 additions and 1 deletions
+8
View File
@@ -0,0 +1,8 @@
<mujoco>
<asset>
<mesh file="torus.obj"/>
</asset>
<worldbody>
<geom type="mesh" mesh="torus" shellinertia="true"/>
</worldbody>
</mujoco>
+17
View File
@@ -38,6 +38,8 @@ static const char* const kCubePath =
"user/testdata/cube.xml";
static const char* const kTorusPath =
"user/testdata/torus.xml";
static const char* const kTorusShellPath =
"user/testdata/torus_shell.xml";
static const char* const kConvexInertiaPath =
"user/testdata/inertia_convex.xml";
static const char* const kConcaveInertiaPath =
@@ -352,6 +354,21 @@ TEST_F(MjCMeshTest, FlippedFaceAllowedNegligibleArea) {
mj_deleteModel(model);
}
TEST_F(MjCMeshTest, ShellUsesVolumeFrame) {
const std::string xml_path_v = GetTestDataFilePath(kTorusPath);
const std::string xml_path_s = GetTestDataFilePath(kTorusShellPath);
std::array<char, 1024> error;
mjModel* mv = mj_loadXML(xml_path_v.c_str(), 0, error.data(), error.size());
mjModel* ms = mj_loadXML(xml_path_s.c_str(), 0, error.data(), error.size());
mjtNum tolerance = std::numeric_limits<float>::epsilon();
EXPECT_NEAR(mv->geom_quat[0], ms->geom_quat[0], tolerance);
EXPECT_NEAR(mv->geom_quat[1], ms->geom_quat[1], tolerance);
EXPECT_NEAR(mv->geom_quat[2], ms->geom_quat[2], tolerance);
EXPECT_NEAR(mv->geom_quat[3], ms->geom_quat[3], tolerance);
mj_deleteModel(mv);
mj_deleteModel(ms);
}
TEST_F(MjCMeshTest, AreaTooSmall) {
static constexpr char xml[] = R"(
<mujoco>