5 #include <gtest/gtest.h> 19 RigidBodyInertia I(6.1,
Vector3d(12.2, 5.3, 2.7),
Matrix3d(4.1, 1.5, 2.3, 5.3, 4.1, 1.5, 1.1, 4.5, 5.6));
20 RigidBodyInertia I2(11.1,
Vector3d(2.2, 2.3, 1.7),
Matrix3d(1.1, 2.5, 3.3, 2.3, 1.1, 3.5, 2.1, 1.5, 1.6));
26 EXPECT_EQ(I2.
h[0], I.
h[0]);
27 EXPECT_EQ(I2.
h[1], I.
h[1]);
28 EXPECT_EQ(I2.
h[2], I.
h[2]);
40 RigidBodyInertia I(6.1,
Vector3d(12.2, 5.3, 2.7),
Matrix3d(4.1, 1.5, 2.3, 5.3, 4.1, 1.5, 1.1, 4.5, 5.6));
42 for (
int i = 0; i < 6; i++)
44 for (
int j = 0; j < 3; j++)
46 m(i, j) = (double)i + j + i * j;
57 RigidBodyInertia I(6.1,
Vector3d(12.2, 5.3, 2.7),
Matrix3d(4.1, 1.5, 2.3, 5.3, 4.1, 1.5, 1.1, 4.5, 5.6));
58 SpatialMatrix m(0.1, 0.2, 0.3, 0.3, 0.2, 0.1, 0.1, 0.2, 0.3, 0.3, 0.2, 0.1, 0.1, 0.2, 0.3, 0.3, 0.2, 0.1, 0.1, 0.2, 0.3, 0.3, 0.2, 0.1, 0.1, 0.2, 0.3, 0.3, 0.2, 0.1,
59 0.1, 0.2, 0.3, 0.3, 0.2, 0.1);
68 RigidBodyInertia I(6.1,
Vector3d(12.2, 5.3, 2.7),
Matrix3d(4.1, 1.5, 2.3, 5.3, 4.1, 1.5, 1.1, 4.5, 5.6));
76 RigidBodyInertia I_a(1.1,
Vector3d(1.2, 1.3, 1.4),
Matrix3d(1.1, 0.5, 0.3, 0.5, 1.2, 0.4, 0.3, 0.4, 1.3));
77 RigidBodyInertia I_b(6.1,
Vector3d(12.2, 5.3, 2.7),
Matrix3d(4.1, 1.5, 2.3, 5.3, 4.1, 1.5, 1.1, 4.5, 5.6));
88 RigidBodyInertia inertia(1.1,
Vector3d(1.2, 1.3, 1.4),
Matrix3d(1.1, 0.5, 0.3, 0.5, 1.2, 0.4, 0.3, 0.4, 1.3));
105 Matrix3d inertia(1.1, 0.5, 0.3, 0.5, 1.2, 0.4, 0.3, 0.4, 1.3);
113 EXPECT_EQ(mass, rbi.
m);
121 Matrix3d Ic(1., 2., 3., 2., 3., 4., 3., 4., 5.);
131 m.block<3, 3>(0, 0) = Ic + comTilde * comTilde.transpose() * mass;
133 m.block<3, 3>(3, 0) = mass * comTilde.transpose();
134 m.block<3, 3>(3, 3) = mIdentity;
144 RigidBodyInertia rbi(1.1,
Vector3d(1.2, 1.3, 1.4),
Matrix3d(1.1, 0.5, 0.3, 0.5, 1.2, 0.4, 0.3, 0.4, 1.3));
154 RigidBodyInertia rbi(1.1,
Vector3d(1.2, 1.3, 1.4),
Matrix3d(1.1, 0.5, 0.3, 0.5, 1.2, 0.4, 0.3, 0.4, 1.3));
168 Matrix3d inertia(1.1, 0.5, 0.3, 0.5, 1.2, 0.4, 0.3, 0.4, 1.3);
176 EXPECT_EQ(mass, rbi.
m);
182 int main(
int argc,
char** argv)
184 ::testing::InitGoogleTest(&argc, argv);
185 return RUN_ALL_TESTS();
RigidBodyInertia transform_copy(const SpatialTransform &X) const
Copy, transform, and return a Math::RigidBodyInertia.
TEST(RigidBodyInertiaTests, testSet)
Matrix3d Matrix3dIdentity
SpatialTransform Xroty(const double &yrot)
Get transform with zero translation and pure rotation about y axis.
SpatialTransform Xtrans(const Vector3d &r)
Get pure translation transform.
static Matrix3d toTildeForm(const Point3d &p)
void createFromMatrix(const SpatialMatrix &Ic)
Create a Math::RigidBodyInertia object from a 6x6 Math::SpatialMatrix.
void set(const RigidBodyInertia &I)
Setter.
static bool checkMatrix3dEq(const RobotDynamics::Math::Matrix3d &t1, const RobotDynamics::Math::Matrix3d &t2)
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...
SpatialTransform Xrotx(const double &xrot)
Get transform with zero translation and pure rotation about x axis.
static bool checkMatrixNdEpsilonClose(const RobotDynamics::Math::MatrixNd &t1, const RobotDynamics::Math::MatrixNd &t2, const double epsilon)
SpatialMatrix subtractSpatialMatrix(const SpatialMatrix &m) const
Given Math::RigidBodyInertia ad Math::SpatialMatrix , returns Math::SpatialMatrix such that ...
static bool checkSpatialMatrixEpsilonClose(const RobotDynamics::Math::SpatialMatrix &t1, const RobotDynamics::Math::SpatialMatrix &t2, const double epsilon)
void transform(const SpatialTransform &X)
Transform a Math::RigidBodyInertia matrix.
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)
Eigen::Matrix< double, 6, 3 > Matrix63
SpatialMatrix toMatrix() const
int main(int argc, char **argv)
static RigidBodyInertia createFromMassComInertiaC(double mass, const Vector3d &com, const Matrix3d &inertia_C)