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
+3
View File
@@ -18,6 +18,9 @@ General
Bug fixes
^^^^^^^^^
- Fixed a bug that for :at:`shellinertia` equal to ``true`` caused the mesh orientation to be overwritten by the
principal components of the shell inertia, while the vertex coordinates are rotated using the volumetric inertia.
Now the volumetric inertia orientation is used also in the shell case.
- Fixed misalignment bug in mesh-to-primitive fitting when using the bounding box fitting option :at:`fitaabb`.
- The ``launch_repl`` functionality in the Python viewer is fixed.
+1 -1
View File
@@ -1152,7 +1152,7 @@ void mjCMesh::Process() {
// copy quat
for (j=0; j<4; j++) {
GetQuatPtr(type)[j] = quattmp[j];
GetQuatPtr(type)[j] = type == mjVOLUME_MESH ? quattmp[j] : GetQuatPtr(mjVOLUME_MESH)[j];
}
// rotate vertices and normals into axis-aligned frame
+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>