31 #include <nav_msgs/Path.h> 32 #include <geometry_msgs/PoseWithCovarianceStamped.h> 33 #include <geometry_msgs/TransformStamped.h> 37 #include <gtest/gtest.h> 47 nh.
param(
"cnt_max", cnt_max, 10);
50 const boost::function<void(const geometry_msgs::PoseWithCovarianceStamped::ConstPtr&)> cb_pose =
51 [&tfbuf, &cnt, &cnt_max, &tf_ex_cnt](
const geometry_msgs::PoseWithCovarianceStamped::ConstPtr& msg) ->
void 53 geometry_msgs::PoseStamped pose;
56 geometry_msgs::PoseStamped pose_bl;
57 pose_bl.header.frame_id =
"base_link";
58 pose_bl.header.stamp = msg->header.stamp;
59 pose_bl.pose.orientation.w = 1.0;
60 geometry_msgs::TransformStamped trans =
69 const float x_error = pose.pose.position.x - msg->pose.pose.position.x;
70 const float y_error = pose.pose.position.y - msg->pose.pose.position.y;
71 const float z_error = pose.pose.position.z - msg->pose.pose.position.z;
72 const float error = sqrtf(powf(x_error, 2.0) + powf(y_error, 2.0) + powf(z_error, 2.0));
74 fprintf(stderr,
"compare_tf[%d/%d]:\n", cnt, cnt_max);
75 fprintf(stderr,
" error=%0.3f\n", error);
81 ASSERT_FALSE(error > 0.05)
82 <<
"tf output diverges from amcl_pose.";
94 ASSERT_FALSE(tf_ex_cnt > 1)
95 <<
"tf exception occures more than once.";
97 fprintf(stderr,
"compare_tf finished\n");
100 int main(
int argc,
char** argv)
102 testing::InitGoogleTest(&argc, argv);
105 return RUN_ALL_TESTS();
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
virtual geometry_msgs::TransformStamped lookupTransform(const std::string &target_frame, const std::string &source_frame, const ros::Time &time, const ros::Duration timeout) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void doTransform(const T &data_in, T &data_out, const geometry_msgs::TransformStamped &transform)
int main(int argc, char **argv)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
ROSCPP_DECL void shutdown()
ROSCPP_DECL void spinOnce()