ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

tranformation using static publisher and listener

asked 2015-04-27 06:32:23 -0600

RSA_kustar gravatar image

Hi,

If I have two frames I want to do transformation.. in my code i have the following:

 void laserCallback (const sensor_msgs::LaserScan::ConstPtr& scan_in)
{
    double t1 = ros::Time::now().toSec() ;
    //std::cout<<"LASER" << scan_in->header.frame_id << std::endl ;
    if(!listener_.waitForTransform(scan_in->header.frame_id,
                                   "/uav/baselink_ENU",
                                   scan_in->header.stamp + ros::Duration().fromSec(scan_in->ranges.size()*scan_in->time_increment),
                                   ros::Duration(1.0)))
    {
        std::cout << "RETURN" << std::endl ;
        return;
    }
    sensor_msgs::PointCloud msg;

     // Which one of the follwoing should I use ? 
    //projector_.projectLaser(*scan_in, msg);
//projector_.transformLaserScanToPointCloud("/uav/baselink_ENU",*scan_in, msg,listener_);

}

Is this part needed if I have a static transformation :

   if(!listener_.waitForTransform(scan_in->header.frame_id,
                                   "/uav/baselink_ENU",
                                   scan_in->header.stamp + ros::Duration().fromSec(scan_in->ranges.size()*scan_in->time_increment),
                                   ros::Duration(1.0)))
    {
        std::cout << "RETURN" << std::endl ;
        return;
    }

I mean is it enough to have a static tf publisher and the following line ?

 projector_.transformLaserScanToPointCloud("/uav/baselink_ENU",*scan_in, msg,listener_);
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-04-27 11:46:23 -0600

tfoote gravatar image

Your code looks reasonable. The waitForTransform might not be needed if the static transform information has already been recieved. However you should keep it to be robust to things like network delays in cases like node startup where the static transforms have not been recieved by the node yet.

You should also never make the assumption that your code will always only be traversing a static part of the tree. It's quite possible that you or someone else will try to use this code at another time in the future with a different laser position and if that is in a different link your assumptions about the tf tree may be invalid.

If you have a static transform segment only waitForTransform will return immediately for any time query so it will only cost you the check that everything is connected which is relatively light weight.

edit flag offensive delete link more
0

answered 2015-04-27 09:06:14 -0600

MarkyMark2012 gravatar image

Hi RSA_kustar,

In short yes, make sure they are both running that the same frequency.

Mark

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-04-27 06:32:23 -0600

Seen: 279 times

Last updated: Apr 27 '15