Creating the listener in each call to the function means it will never have any tf data in it.  You need to create it somewhere long-lasting and pass it in to the function.<div><br></div><div>Josh<br><br><div class="gmail_quote">

On Fri, Oct 22, 2010 at 4:51 PM, Daniel Chavez <span dir="ltr"><<a href="mailto:dchavez@stanford.edu">dchavez@stanford.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br>
I'm having some trouble getting TF to convert a point from /base_link frame<br>
to /map frame.  I made a function for it, shown below, based on code in the<br>
TF tutorials:<br>
<br>
geometry_msgs::PointStamped baseToMapFrame(geometry_msgs::PointStamped p)<br>
{<br>
        tf::TransformListener TFlistener(ros::Duration(1.0));  //Used for<br>
listening to transforms<br>
        geometry_msgs::PointStamped q;<br>
        try{<br>
                ros::Time now = ros::Time::now();<br>
                geometry_msgs::PointStamped p,q;<br>
                p.header.frame_id = "/base_link";<br>
                p.header.stamp = ros::Time(0);<br>
                TFlistener.transformPoint("/map",p,q);<br>
        } catch (tf::TransformException ex){<br>
            ROS_ERROR("%s",ex.what());<br>
       }<br>
        return q;<br>
}<br>
<br>
The error message I get when running is:<br>
<br>
[ERROR] [1287786203.075208516, 13.800000000]: Frame id /map does not exist!<br>
When trying to transform between /base_link and /map.<br>
<br>
This is even after initializing the map frame with AMCL.  Strangely, if I do<br>
tf_echo to see if TF knows this conversion, I get:<br>
<br>
$ rosrun tf tf_echo /map /base_link<br>
Failure at 75.200000000<br>
Exception thrown:Frame id /map does not exist! When trying to transform<br>
between /base_link and /map.<br>
The current list of frames is:<br>
<br>
At time 76.100<br>
- Translation: [46.885, 45.869, 0.000]<br>
- Rotation: in Quaternion [0.000, 0.000, 1.000, -0.022]<br>
            in RPY [0.000, -0.000, -3.097]<br>
At time 77.200<br>
- Translation: [46.885, 45.869, 0.000]<br>
- Rotation: in Quaternion [0.000, 0.000, 1.000, -0.022]<br>
            in RPY [0.000, -0.000, -3.097]<br>
<br>
<br>
Any thoughts on what might be happening?  It seems that tf_echo fails on the<br>
first try but succeeds later on.<br>
<br>
Help is appreciated.<br>
<font color="#888888">--<br>
View this message in context: <a href="http://ros-users.122217.n3.nabble.com/Trouble-converting-points-with-TF-tp1755749p1755749.html" target="_blank">http://ros-users.122217.n3.nabble.com/Trouble-converting-points-with-TF-tp1755749p1755749.html</a><br>


Sent from the ROS-Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
<a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
</font></blockquote></div><br></div>