Skip to content

Commit f7e26fb

Browse files
Fix world pose expectations in mesh_inertia_calulation integration tests
* Not all models of test/worlds/mesh_inertia_calculation.sdf are initialized with zero pose * Bug #2774 was forcing all `link.WorldPose` to be zero after calling `link.EnableVelocityChecks` Signed-off-by: Gabriel Pacheco <[email protected]>
1 parent eb0eada commit f7e26fb

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/integration/mesh_inertia_calculation.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <gz/sim/Model.hh>
2626
#include <gz/sim/Entity.hh>
2727
#include <gz/sim/EntityComponentManager.hh>
28+
#include <gz/sim/Util.hh>
2829

2930
#include <gz/sim/components/Inertial.hh>
3031
#include <gz/sim/components/Model.hh>
@@ -121,9 +122,11 @@ TEST(MeshInertiaCalculationTest, CylinderColladaMeshInertiaCalculation)
121122
EXPECT_TRUE(
122123
link.WorldInertiaMatrix(*ecm).value().Equal(inertiaMatrix, 0.005));
123124

124-
// Check the Inertial Pose and Link Pose
125-
EXPECT_EQ(link.WorldPose(*ecm).value(), gz::math::Pose3d::Zero);
126-
EXPECT_EQ(link.WorldInertialPose(*ecm).value(), gz::math::Pose3d::Zero);
125+
// Check the Inertial Pose and Link Pose. Their world poses should be the
126+
// same since the inertial pose relative to the link is zero.
127+
EXPECT_EQ(link.WorldPose(*ecm).value(), worldPose(linkEntity, *ecm));
128+
EXPECT_EQ(link.WorldInertialPose(*ecm).value(),
129+
worldPose(linkEntity, *ecm) * gz::math::Pose3d::Zero);
127130
}
128131

129132
TEST(MeshInertiaCalculationTest,
@@ -200,10 +203,10 @@ TEST(MeshInertiaCalculationTest,
200203
link.WorldInertiaMatrix(*ecm).value().Equal(inertiaMatrix, 0.005));
201204

202205
// Check the Inertial Pose and Link Pose
203-
EXPECT_EQ(link.WorldPose(*ecm).value(), gz::math::Pose3d::Zero);
206+
EXPECT_EQ(link.WorldPose(*ecm).value(), worldPose(linkEntity, *ecm));
204207

205208
// Since the height of cylinder is 2m and origin is at center of bottom face
206209
// the center of mass (inertial pose) will be 1m above the ground
207210
EXPECT_EQ(link.WorldInertialPose(*ecm).value(),
208-
gz::math::Pose3d(0, 0, 1, 0, 0, 0));
211+
worldPose(linkEntity, *ecm) * gz::math::Pose3d(0, 0, 1, 0, 0, 0));
209212
}

0 commit comments

Comments
 (0)