9 #include "gmock/gmock.h" 10 #include "gtest/gtest.h" 18 EXPECT_EQ(M_PI / 4.,
deg2rad(45.));
19 EXPECT_EQ(45,
rad2deg(M_PI / 4.));
28 a << 1, 2, 3, 4, 5, 6, 7, 8, 9.2;
29 b << 1, 2, 3, 4, 5, 6, 7, 8, 9.1;
44 testDynamicMat << 1, 2, 3, 4, 5, 6, 7, 8, 9.2;
45 testDynamicMat2 << 1, 2, 3, 4, 5, 6, 7, 8, 9.1;
46 EXPECT_EQ(
true,
almostEqual(testDynamicMat, testDynamicMat2, .3));
47 EXPECT_EQ(
false,
almostEqual(testDynamicMat, testDynamicMat2, .01));
56 double s = std::sin(.2);
57 double c = std::cos(.2);
59 R_ref_x << 1, 0, 0, 0, c, s, 0, -s, c;
60 R_ref_y << c, 0, -s, 0, 1, 0, s, 0, c;
61 R_ref_z << c, s, 0, -s, c, 0, 0, 0, 1;
74 A << 8, 1, 6, 3, 5, 7, 4, 9, 2;
75 B << 0, -3, 2, 3, 0, -1, -2, 1, 0;
89 TEST(Orientation, quatToRotm) {
93 R << .8799, .3720, -.2955, -.3276, .9256, .1898, .3441, -.0702, .9363;
113 TEST(Orientation, quatToRpy2) {
125 TEST(Orientation, quatToRpy3) {
138 TEST(Orienation, quaternionDerivative) {
148 TEST(Orientation, quaternionProduct) {
155 TEST(Orientation, quaternionProductDirection) {
178 TEST(Orientation, quaternionIntegration) {
212 std::cout <<
"1: " << rpy.transpose() <<
"\n2: " << rpyAgain.transpose()
219 TEST(Orientation, allOrientationConversions) {
233 EXPECT_TRUE(
almostEqual(refRPY, rpyFromQuat, .0001));
236 EXPECT_TRUE(
almostEqual(rFromQuat, rFromRPY, .0001));
238 EXPECT_TRUE(
almostEqual(quatFromR, quatFromRPY, .0001));
Mat3< T > coordinateRotation(CoordinateAxis axis, T theta)
Mat3< typename T::Scalar > rpyToRotMat(const Eigen::MatrixBase< T > &v)
typename Eigen::Matrix< T, 3, 3 > Mat3
typename Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > DMat
typename Eigen::Matrix< T, 4, 1 > Quat
typename Eigen::Matrix< T, 3, 1 > Vec3
Quat< typename T::Scalar > integrateQuat(const Eigen::MatrixBase< T > &quat, const Eigen::MatrixBase< T2 > &omega, T3 dt)
Vec3< typename T::Scalar > quatToRPY(const Eigen::MatrixBase< T > &q)
Quat< typename T::Scalar > rotationMatrixToQuaternion(const Eigen::MatrixBase< T > &r1)
Quat< typename T::Scalar > quatProduct(const Eigen::MatrixBase< T > &q1, const Eigen::MatrixBase< T > &q2)
bool almostEqual(const Eigen::MatrixBase< T > &a, const Eigen::MatrixBase< T > &b, T2 tol)
Quat< typename T::Scalar > rpyToQuat(const Eigen::MatrixBase< T > &rpy)
Mat3< typename T::Scalar > vectorToSkewMat(const Eigen::MatrixBase< T > &v)
typename Eigen::Matrix< T, Eigen::Dynamic, 1 > DVec
Vec3< typename T::Scalar > matToSkewVec(const Eigen::MatrixBase< T > &m)
Vec3< typename T::Scalar > rotationMatrixToRPY(const Eigen::MatrixBase< T > &R)
Mat3< typename T::Scalar > quaternionToRotationMatrix(const Eigen::MatrixBase< T > &q)
Quat< typename T::Scalar > quatDerivative(const Eigen::MatrixBase< T > &q, const Eigen::MatrixBase< T2 > &omega)
typename Eigen::Matrix< T, 3, 3 > RotMat