34 #include <gtest/gtest.h>
36 static const double EPS = 1e-6;
40 return tf2::Vector3(1.0, 2.0, 3.0);
54 h.frame_id =
"foobar";
89 geometry_msgs::QuaternionStamped&
value_initialize(geometry_msgs::QuaternionStamped &m1)
124 void expect_near(
const std_msgs::Header & h1,
const std_msgs::Header & h2)
126 EXPECT_NEAR(h1.stamp.toSec(), h2.stamp.toSec(),
EPS);
127 EXPECT_STREQ(h1.frame_id.c_str(), h2.frame_id.c_str());
133 void expect_near(
const geometry_msgs::Vector3 & v1,
const tf2::Vector3 & v2)
135 EXPECT_NEAR(v1.x, v2.x(),
EPS);
136 EXPECT_NEAR(v1.y, v2.y(),
EPS);
137 EXPECT_NEAR(v1.z, v2.z(),
EPS);
140 void expect_near(
const geometry_msgs::Vector3 & v1,
const geometry_msgs::Vector3 & v2)
142 EXPECT_NEAR(v1.x, v2.x,
EPS);
143 EXPECT_NEAR(v1.y, v2.y,
EPS);
144 EXPECT_NEAR(v1.z, v2.z,
EPS);
147 void expect_near(
const tf2::Vector3 & v1,
const tf2::Vector3 & v2)
149 EXPECT_NEAR(v1.x(), v2.x(),
EPS);
150 EXPECT_NEAR(v1.y(), v2.y(),
EPS);
151 EXPECT_NEAR(v1.z(), v2.z(),
EPS);
154 void expect_near(
const geometry_msgs::Vector3Stamped & p1,
const geometry_msgs::Vector3Stamped & p2)
163 void expect_near(
const geometry_msgs::Point & p1,
const tf2::Vector3 & v2)
165 EXPECT_NEAR(p1.x, v2.x(),
EPS);
166 EXPECT_NEAR(p1.y, v2.y(),
EPS);
167 EXPECT_NEAR(p1.z, v2.z(),
EPS);
170 void expect_near(
const geometry_msgs::Point & p1,
const geometry_msgs::Point & v2)
172 EXPECT_NEAR(p1.x, v2.x,
EPS);
173 EXPECT_NEAR(p1.y, v2.y,
EPS);
174 EXPECT_NEAR(p1.z, v2.z,
EPS);
177 void expect_near(
const geometry_msgs::PointStamped & p1,
const geometry_msgs::PointStamped & p2)
189 EXPECT_NEAR(q1.x, v2.x(),
EPS);
190 EXPECT_NEAR(q1.y, v2.y(),
EPS);
191 EXPECT_NEAR(q1.z, v2.z(),
EPS);
194 void expect_near(
const geometry_msgs::Quaternion & q1,
const geometry_msgs::Quaternion & v2)
196 EXPECT_NEAR(q1.x, v2.x,
EPS);
197 EXPECT_NEAR(q1.y, v2.y,
EPS);
198 EXPECT_NEAR(q1.z, v2.z,
EPS);
201 void expect_near(
const geometry_msgs::QuaternionStamped & p1,
const geometry_msgs::QuaternionStamped & p2)
216 void expect_near(
const geometry_msgs::Pose & p1,
const geometry_msgs::Pose & p2)
222 void expect_near(
const geometry_msgs::PoseStamped & p1,
const geometry_msgs::PoseStamped & p2)
237 void expect_near(
const geometry_msgs::Transform & p1,
const geometry_msgs::Transform & p2)
243 void expect_near(
const geometry_msgs::TransformStamped & p1,
const geometry_msgs::TransformStamped & p2)
253 template <
typename T>
263 TEST(tf2_geometry_msgs, Vector3)
265 geometry_msgs::Vector3 m1;
269 SCOPED_TRACE(
"m1 v1");
271 geometry_msgs::Vector3 m2 =
toMsg(v1);
272 SCOPED_TRACE(
"m1 m2");
278 geometry_msgs::Point m1;
281 SCOPED_TRACE(
"m1 v1");
284 geometry_msgs::Point m2 =
toMsg(v1, m2);
285 SCOPED_TRACE(
"m1 m2");
289 TEST(tf2_geometry_msgs, Quaternion)
291 geometry_msgs::Quaternion m1;
294 SCOPED_TRACE(
"m1 q1");
297 geometry_msgs::Quaternion m2 =
toMsg(q1);
298 SCOPED_TRACE(
"m1 m2");
304 geometry_msgs::Pose m1;
308 SCOPED_TRACE(
"m1 t1");
310 geometry_msgs::Pose m2 =
toMsg(t1, m2);
311 SCOPED_TRACE(
"m1 m2");
315 TEST(tf2_geometry_msgs, Transform)
317 geometry_msgs::Transform m1;
321 SCOPED_TRACE(
"m1 t1");
323 geometry_msgs::Transform m2 =
toMsg(t1);
324 SCOPED_TRACE(
"m1 m2");
328 TEST(tf2_geometry_msgs, Vector3Stamped)
330 geometry_msgs::Vector3Stamped m1;
334 SCOPED_TRACE(
"m1 v1");
336 geometry_msgs::Vector3Stamped m2;
338 SCOPED_TRACE(
"m1 m2");
342 TEST(tf2_geometry_msgs, PointStamped)
344 geometry_msgs::PointStamped m1;
348 SCOPED_TRACE(
"m1 v1");
350 geometry_msgs::PointStamped m2;
352 SCOPED_TRACE(
"m1 m2");
356 TEST(tf2_geometry_msgs, QuaternionStamped)
358 geometry_msgs::QuaternionStamped m1;
362 SCOPED_TRACE(
"m1 v1");
364 geometry_msgs::QuaternionStamped m2;
366 SCOPED_TRACE(
"m1 m2");
370 TEST(tf2_geometry_msgs, PoseStamped)
372 geometry_msgs::PoseStamped m1;
375 SCOPED_TRACE(
"m1 v1");
378 geometry_msgs::PoseStamped m2;
380 SCOPED_TRACE(
"m1 m2");
384 TEST(tf2_geometry_msgs, TransformStamped)
386 geometry_msgs::TransformStamped m1;
390 SCOPED_TRACE(
"m1 v1");
392 geometry_msgs::TransformStamped m2;
394 SCOPED_TRACE(
"m1 m2");
401 int main(
int argc,
char **argv){
402 testing::InitGoogleTest(&argc, argv);
403 int ret = RUN_ALL_TESTS();