Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00039 #include <flirtlib_ros/common.h>
00040
00041 namespace flirtlib_ros
00042 {
00043
00044 gm::Pose getCurrentPose (const tf::TransformListener& tf,
00045 const std::string& frame)
00046 {
00047 tf::StampedTransform trans;
00048 tf.lookupTransform("/map", frame, ros::Time(), trans);
00049 gm::Pose pose;
00050 tf::poseTFToMsg(trans, pose);
00051 return pose;
00052 }
00053
00054
00055 gm::Pose makePose (const double x, const double y, const double theta)
00056 {
00057 gm::Pose p;
00058 p.position.x = x;
00059 p.position.y = y;
00060 p.orientation = tf::createQuaternionMsgFromYaw(theta);
00061 return p;
00062 }
00063
00064 gm::Pose transformPose (const gm::Pose& p, const OrientedPoint2D& trans)
00065 {
00066 tf::Transform laser_pose(tf::Quaternion(0, 0, 0, 1), tf::Vector3(-0.275, 0, 0));
00067 tf::Transform tr;
00068 tf::poseMsgToTF(p, tr);
00069 tf::Transform rel(tf::createQuaternionFromYaw(trans.theta),
00070 tf::Vector3(trans.x, trans.y, 0.0));
00071 gm::Pose ret;
00072 tf::poseTFToMsg(tr*rel*laser_pose, ret);
00073 return ret;
00074 }
00075
00076 gm::Pose transformPose (const tf::Transform& trans, const gm::Pose& pose)
00077 {
00078 tf::Transform p;
00079 tf::poseMsgToTF(pose, p);
00080 gm::Pose ret;
00081 tf::poseTFToMsg(trans*p, ret);
00082 return ret;
00083 }
00084
00085 tf::Transform getLaserOffset (const tf::TransformListener& tf)
00086 {
00087 const std::string LASER_FRAME = "base_laser_link";
00088 const std::string BASE_FRAME = "base_footprint";
00089 while (ros::ok())
00090 {
00091 tf.waitForTransform(LASER_FRAME, BASE_FRAME, ros::Time(),
00092 ros::Duration(5.0));
00093 try {
00094 tf::StampedTransform trans;
00095 tf.lookupTransform(LASER_FRAME, BASE_FRAME, ros::Time(),
00096 trans);
00097 return trans;
00098 }
00099 catch (tf::TransformException& e)
00100 {
00101 ROS_INFO ("Waiting for transform between %s and %s",
00102 LASER_FRAME.c_str(), BASE_FRAME.c_str());
00103 }
00104 }
00105 return tf::Transform();
00106 }
00107
00108 }