Ask Your Question

Changing from tf::Transform to tf::StampedTransform

asked 2012-02-02 04:45:42 -0500

alfa_80 gravatar image

Could someone try to change any part of my code in order to use tf::StampedTransform. I've been trying to just replace it in place of tf::Transform directly, it doesn't work. I should have been missing something I think. This is needed because I cannot see the base_link movement with respect to the world. I think the tf is not correctly published with the below code.

sensor_msgs::PointCloud2 cloud; //Class variable

//    In a callback function
sensor_msgs::PointCloud2 c_tmp;

static tf::TransformBroadcaster tfb;
tf::Transform xform;
xform.setOrigin(tf::Vector3(pose3D_LDD.pose.position.x, pose3D_LDD.pose.position.y, pose3D_LDD.pose.position.z));
xform.setRotation(tf::Quaternion(pose3D_LDD.pose.orientation.x, pose3D_LDD.pose.orientation.y, pose3D_LDD.pose.orientation.z, pose3D_LDD.pose.orientation.w));
tfb.sendTransform(tf::StampedTransform(xform, ros::Time(pose3D_LDD.header.stamp), "world", "base_link"));
tfListener_.waitForTransform("world", "base_link", previous_scan_.header.stamp, ros::Duration(1.0));

    projector_.transformLaserScanToPointCloud("laser", previous_scan_, c_tmp, tfListener_);

    if (!initialized_cloud_)
        cloud = c_tmp;
        initialized_cloud_ = true;
         pcl::concatenatePointCloud(cloud, c_tmp, cloud);

         ROS_INFO("From c_tmp: Got cloud with %u of width and %u of height", c_tmp.width, c_tmp.height);
         ROS_INFO("From cloud: Got cloud with %u of width and %u of height", cloud.width, cloud.height);

Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-02-02 06:33:42 -0500

DimitriProsser gravatar image

I do exactly the same thing, and it works for me. The only difference is that I put a "/" in front of all my frame_id's (so "world" becomes "/world"). That, and instead of ros::Time(pose3D_LDD.header.stamp), I just use pose3D_LDD.header.stamp directly.

edit flag offensive delete link more


What frame did you check/tick each for Fixed Frame and Target Frame in your rviz? or in the above case supposedly?
alfa_80 gravatar image alfa_80  ( 2012-02-02 06:59:15 -0500 )edit
As long as the distance between /world and /base_link is not large, I'd set both target and fixed frames to /world
DimitriProsser gravatar image DimitriProsser  ( 2012-02-03 00:22:16 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-02-02 04:45:42 -0500

Seen: 2,157 times

Last updated: Feb 02 '12