8 #include <mrpt/poses/CPosePDFGaussian.h> 9 #include <mrpt/poses/CPose3DPDFGaussian.h> 10 #include <mrpt/math/CQuaternion.h> 11 #include <geometry_msgs/PoseWithCovariance.h> 12 #include <geometry_msgs/Pose.h> 13 #include <geometry_msgs/Quaternion.h> 16 #include <gtest/gtest.h> 22 const double roll,
const double pitch,
const double yaw)
27 rotation.
setRPY(roll, pitch, yaw);
32 mrpt::poses::CPose3D mrpt_original_pose;
33 mrpt_original_pose.setYawPitchRoll(yaw, pitch, roll);
35 mrpt_original_pose.getRotationMatrix();
37 for (
int i = 0; i < 3; i++)
38 for (
int j = 0; j < 3; j++)
39 EXPECT_NEAR(basis[i][j], mrpt_basis(i, j), 0.01);
42 TEST(PoseConversions, copyMatrix3x3ToCMatrixDouble33)
47 for (
int r = 0; r < 3; r++)
48 for (
int c = 0; c < 3; c++) EXPECT_FLOAT_EQ(des(r, c), src[r][c]);
50 TEST(PoseConversions, copyCMatrixDouble33ToMatrix3x3)
53 src << 0, 1, 2, 3, 4, 5, 6, 7, 8;
56 for (
int r = 0; r < 3; r++)
57 for (
int c = 0; c < 3; c++) EXPECT_FLOAT_EQ(des[r][c], src(r, c));
71 TEST(PoseConversions, reference_frame_change_with_rotations)
75 ros_msg_original_pose.pose.position.x = 1;
76 ros_msg_original_pose.pose.position.y = 0;
77 ros_msg_original_pose.pose.position.z = 0;
78 ros_msg_original_pose.pose.orientation.x = 0;
79 ros_msg_original_pose.pose.orientation.y = 0;
80 ros_msg_original_pose.pose.orientation.z = 0;
81 ros_msg_original_pose.pose.orientation.w = 1;
84 mrpt::poses::CPose3DPDFGaussian mrpt_original_pose;
87 ros_msg_original_pose.pose.position.x, mrpt_original_pose.mean[0]);
94 mrpt::poses::CPose3D rotation_mrpt;
95 double yaw = M_PI / 2.0;
96 rotation_mrpt.setFromValues(0, 0, 0, yaw, 0, 0);
97 mrpt::poses::CPose3D mrpt_result = rotation_mrpt + mrpt_original_pose.mean;
98 EXPECT_NEAR(mrpt_result[1], 1.0, 0.01);
102 rotation_tf.
setRPY(0, 0, yaw);
106 tf::Pose tf_result = rotation_pose_tf * tf_original_pose;
107 EXPECT_NEAR(tf_result.
getOrigin()[1], 1.0, 0.01);
112 EXPECT_NEAR(mrpt_ros_result.position.x, tf_result.
getOrigin()[0], 0.01);
113 EXPECT_NEAR(mrpt_ros_result.position.y, tf_result.
getOrigin()[1], 0.01);
114 EXPECT_NEAR(mrpt_ros_result.position.z, tf_result.
getOrigin()[2], 0.01);
118 double x,
double y,
double z,
double yaw,
double pitch,
double roll)
120 const mrpt::poses::CPose3D p3D(x, y, z, yaw, pitch, roll);
128 p3D.getAsQuaternion(q);
130 EXPECT_NEAR(ros_p3D.position.x, p3D.x(), 1e-4) <<
"p: " << p3D << endl;
131 EXPECT_NEAR(ros_p3D.position.y, p3D.y(), 1e-4) <<
"p: " << p3D << endl;
132 EXPECT_NEAR(ros_p3D.position.z, p3D.z(), 1e-4) <<
"p: " << p3D << endl;
134 EXPECT_NEAR(ros_p3D.orientation.x, q.x(), 1e-4) <<
"p: " << p3D << endl;
135 EXPECT_NEAR(ros_p3D.orientation.y, q.y(), 1e-4) <<
"p: " << p3D << endl;
136 EXPECT_NEAR(ros_p3D.orientation.z, q.z(), 1e-4) <<
"p: " << p3D << endl;
137 EXPECT_NEAR(ros_p3D.orientation.w, q.r(), 1e-4) <<
"p: " << p3D << endl;
140 mrpt::poses::CPose3D p_bis;
145 (p_bis.getAsVectorVal() - p3D.getAsVectorVal())
150 <<
"p_bis: " << p_bis << endl
151 <<
"p3D: " << p3D << endl;
168 TEST(PoseConversions, check_CPose2D_to_ROS)
170 const mrpt::poses::CPose2D p2D(1, 2, 0.56);
177 const mrpt::poses::CPose3D p3D = mrpt::poses::CPose3D(p2D);
178 mrpt::poses::CPose3D p3D_ros;
183 (p3D_ros.getAsVectorVal() - p3D.getAsVectorVal())
188 <<
"p3D_ros: " << p3D_ros << endl
189 <<
"p3D: " << p3D << endl;
static void poseMsgToTF(const geometry_msgs::Pose &msg, Pose &bt)
void checkPoseMatrixFromRotationParameters(const double roll, const double pitch, const double yaw)
math::CQuaternion< double > CQuaternionDouble
void setRPY(const tfScalar &roll, const tfScalar &pitch, const tfScalar &yaw)
bool convert(const mrpt_msgs::ObservationRangeBeacon &_msg, const mrpt::poses::CPose3D &_pose, mrpt::obs::CObservationBeaconRanges &_obj)
TEST(PoseConversions, copyMatrix3x3ToCMatrixDouble33)
void check_CPose3D_tofrom_ROS(double x, double y, double z, double yaw, double pitch, double roll)