[ros-users] About tf and synchronization

Rodrigo Baravalle rbaravalle at gmail.com
Wed Dec 22 11:07:46 UTC 2010


Hi Tully.

You are right. The problem is solved!. I hope this information is
useful for Jack.

So, for the future, I suppose I always have to try to match the time
of one of the messages, in this case, the point cloud, but, it could
have been the timestamp of the odometry of amcl_pose?. Is it correct?

So, the final code is:

void MergePC::callback(const geometry_msgs::PoseWithCovarianceStampedPtr& o) {
...
   // Read data from the Camera
   pc_current.header.frame_id = "swissranger";
   dev_->readData(pc_current,pc2_current,image_d_, image_i_,
image_c_, image_d16_);

    tlistener.waitForTransform("/map", pc_current.header.frame_id,
                              pc_current.header.stamp, ros::Duration(3.0));

    // pc_current is the point cloud arriving from the camera
    tlistener.transformPointCloud("/map", pc_current, pc_tf);
...
}


Thanks a lot for your help!

2010/12/22 Tully Foote <tfoote at willowgarage.com>:
>
>
> On Tue, Dec 21, 2010 at 4:16 PM, Rodrigo Baravalle <rbaravalle at gmail.com>
> wrote:
>>
>> Hi!
>>
>> Here are the lines of code of the callback, when an amcl pose arrives..
>>
>> I used the same frame_id, but, is the timestamp correct? I used the
>> same as in the tutorial:
>> http://www.ros.org/wiki/tf/Tutorials/tf%20and%20Time%20(C%2B%2B)
>>
>> void MergePC::callback(const geometry_msgs::PoseWithCovarianceStampedPtr&
>> o) {
>> ...
>>    // Read data from the Camera
>>    pc_current.header.frame_id = "swissranger";
>>    dev_->readData(pc_current,pc2_current,image_d_, image_i_,
>> image_c_, image_d16_);
>>
>>     // I put 100.0, but is the same if I put 20.0, 3.0, or whatever
>>     tlistener.waitForTransform("/map", "/swissranger",
>>                               ros::Time(0), ros::Duration(100.0));
>>
>>     // pc_current is the point cloud arriving from the camera, so it
>> has the "swissranger" frame_id
>>     // here is where it fails..
>>     tlistener.transformPointCloud("/map", pc_current, pc_tf);
>> ...
>> }
>>
>> Thanks in advance!
>
>
> Hi Rodrigo,
>
> Your call to wait for transform is going to wait until any transform between
> "/map" and "/swissranger".  Time(0) is special and will match anything.
>
> you want to waitForTransform betwen "/map" and pc_current.header.frame_id at
> time pc_current.header.stamp, as that is what you are about to call with
> transformPointCloud.
>
> Tully
>
>
>>
>> 2010/12/21 Wim Meeussen <meeussen at willowgarage.com>:
>> >> The problem is that I always get an error message like this:
>> >>
>> >> "You requested a transform that is 12.571 miliseconds in the past,
>> >> but the most recent transform in the tf buffer is 49.194 miliseconds
>> >> old.
>> >>  When trying to transform between /swissranger and /map."
>> >
>> >> I have already tried with "waitForTransform" between the two frames,
>> >> but nothing seems to happen. I can see by using "rosrun tf
>> >> view_frames" that amcl is publishing things in the future: "
>> >> Broadcaster: /amcl ... Most recent transform: -0.086 sec old ... ".
>> >
>> > Based on this information your tf tree looks fine. You are just
>> > requesting a transformation before that information is in the tf
>> > buffer.  Calling waitForTransform before you request the actual
>> > transform should work.  Did you call waitForTransform with the same
>> > frame id's and timestamp as the actual transform? Could you show the
>> > few lines of code where you do the tf calls?
>> >
>> > Wim
>> >
>> >
>> > --
>> > --
>> > Wim Meeussen
>> > Willow Garage Inc.
>> > <http://www.willowgarage.com)
>> > _______________________________________________
>> > ros-users mailing list
>> > ros-users at code.ros.org
>> > https://code.ros.org/mailman/listinfo/ros-users
>> >
>> _______________________________________________
>> ros-users mailing list
>> ros-users at code.ros.org
>> https://code.ros.org/mailman/listinfo/ros-users
>
>
>
> --
> Tully Foote
> Systems Engineer
> Willow Garage, Inc.
> tfoote at willowgarage.com
> (650) 475-2827
>
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
>



More information about the ros-users mailing list