1 #include <gtest/gtest.h> 32 Matrix3d inertia_C(1.4, 0., 0., 0., 2., 0., 0., 0., 3.);
34 SpatialMatrix reference_inertia(4.843, -1.98, -2.145, 0, -1.43, 1.32, -1.98, 6.334, -1.716, 1.43, 0, -1.65, -2.145, -1.716, 7.059, -1.32, 1.65, 0, 0, 1.43, -1.32,
35 1.1, 0, 0, -1.43, 0, 1.65, 0, 1.1, 0, 1.32, -1.65, 0, 0, 0, 1.1);
55 EXPECT_STREQ(e.
what(),
"Error: cannot join bodies as both have zero mass!");
63 Matrix3d inertia_C(8.286, -3.96, -4.29, -3.96, 10.668, -3.432, -4.29, -3.432, 11.118);
65 Body body(mass, com, inertia_C);
67 SpatialMatrix reference_inertia(11.729, -5.94, -6.435, 0, -1.43, 1.32, -5.94, 15.002, -5.148, 1.43, 0, -1.65, -6.435, -5.148, 15.177, -1.32, 1.65, 0, 0, 1.43, -1.32,
68 1.1, 0, 0, -1.43, 0, 1.65, 0, 1.1, 0, 1.32, -1.65, 0, 0, 0, 1.1);
80 Body joined_body = body;
86 ASSERT_EQ(1.1, body.
mMass);
96 Body body_joined(body_a);
101 SpatialMatrix reference_inertia(9.918, 0, 0, 0, -0, 2.86, 0, 9.062, 0, 0, 0, -0, 0, 0, 12.98, -2.86, 0, 0, 0, 0, -2.86, 2.2, 0, 0, -0, 0, 0, 0, 2.2, 0, 2.86, -0, 0,
104 ASSERT_EQ(2.2, body_joined.
mMass);
114 Body body_joined(body_a);
119 SpatialMatrix reference_inertia(9.918, 0, 0, 0, -0, 2.86, 0, 9.062, 0, 0, 0, -0, 0, 0, 12.98, -2.86, 0, 0, 0, 0, -2.86, 2.2, 0, 0, -0, 0, 0, 0, 2.2, 0, 2.86, -0, 0,
122 ASSERT_EQ(2.2, body_joined.
mMass);
132 Body body_joined(body_a);
133 body_joined.
join(
Xrotx(-M_PI * 0.5), body_b);
137 SpatialMatrix reference_inertia(6.2, 0., 0., 0., 0., 0., 0., 6.4, 0., 0., 0., 0., 0., 0., 6.6, 0., 0., 0., 0., 0., 0., 2.2, 0., 0., 0., 0., 0., 0., 2.2, 0., 0., 0.,
140 ASSERT_EQ(2.2, body_joined.
mMass);
150 Body body_joined(body_a);
155 SpatialMatrix reference_inertia(6.2, 0., 0., 0., 0., 0., 0., 6.4, 0., 0., 0., 0., 0., 0., 6.6, 0., 0., 0., 0., 0., 0., 2.2, 0., 0., 0., 0., 0., 0., 2.2, 0., 0., 0.,
158 ASSERT_EQ(2.2, body_joined.
mMass);
198 int main(
int argc,
char** argv)
200 ::testing::InitGoogleTest(&argc, argv);
201 return RUN_ALL_TESTS();
Describes all properties of a single body.
SpatialTransform Xtrans(const Vector3d &r)
Get pure translation transform.
void join(const Math::SpatialTransform &transform, const Body &other_body)
Joins inertial parameters of two bodies to create a composite body.
double mMass
The mass of the body.
Math::Matrix3d mInertia
Inertia matrix at the center of mass.
void createFromMatrix(const SpatialMatrix &Ic)
Create a Math::RigidBodyInertia object from a 6x6 Math::SpatialMatrix.
SpatialTransform Xrotz(const double &zrot)
Get transform with zero translation and pure rotation about z axis.
static bool checkVector3dEq(const RobotDynamics::Math::Vector3d &v1, const RobotDynamics::Math::Vector3d &v2)
This class stores a bodies mass, center of mass, and inertia information. The inertia elements are st...
virtual const char * what() const
SpatialTransform Xrotx(const double &xrot)
Get transform with zero translation and pure rotation about x axis.
static bool checkSpatialMatrixEpsilonClose(const RobotDynamics::Math::SpatialMatrix &t1, const RobotDynamics::Math::SpatialMatrix &t2, const double epsilon)
Math types such as vectors and matrices and utility functions.
static bool checkSpatialVectorsEpsilonClose(const RobotDynamics::Math::SpatialVector &v1, const RobotDynamics::Math::SpatialVector &v2, const double epsilon)
Math::Vector3d mCenterOfMass
The position of the center of mass in body coordinates.
SpatialMatrix toMatrix() const
static bool checkVector3dEpsilonClose(const RobotDynamics::Math::Vector3d &v1, const RobotDynamics::Math::Vector3d &v2, const double epsilon)
TEST_F(RdlBodyTests, TestComputeSpatialInertiaFromAbsoluteRadiiGyration)
int main(int argc, char **argv)
Namespace for all structures of the RobotDynamics library.
static bool checkMatrix3dEpsilonClose(const RobotDynamics::Math::Matrix3d &t1, const RobotDynamics::Math::Matrix3d &t2, const double epsilon)
static RigidBodyInertia createFromMassComInertiaC(double mass, const Vector3d &com, const Matrix3d &inertia_C)