Time issue after changing type of time
I received a warning that is related to timing issue. This warning causes my node that is supposed to transform LaserScan to PointCloud not working. If I use my dataset's timestamp, it will be fine, but then, I need to refactor the code by using ROS timestamp to resolve timing issue.
I'm actually confused when to use ros::Time::now() and likewise, when to use ros::Time(0). Perhaps I wrongly assigned those values somewhere.
By the way, when publishing all my messages(LaserScan, Pose, etc), I just assigned them ros::Time::now. Is that right doing that?
The code snippet that is needed to be refactored to use ROS timestamp:
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), "base_link", "laser"));
tfListener_.waitForTransform("base_link", "laser", previous_scan_.header.stamp, ros::Duration(2.0));
try
{
projector_.transformLaserScanToPointCloud("base_link", previous_scan_, cloud, tfListener_);
}
catch (tf::TransformException ex)
{
ROS_WARN("Problem: %s", ex.what());
}
The code snippet after refactored to use ROS timestamp, but obtained a serious warning:
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));
tfListener_.waitForTransform("base_link", "laser", ros::Time(0), ros::Duration(2.0));
try
{
projector_.transformLaserScanToPointCloud("base_link", previous_scan_, cloud, tfListener_);
}
catch (tf::TransformException ex)
{
ROS_WARN("Problem: %s", ex.what());
}
All my callback functions are coded this way:
void PointCloudBuilder::poseLDCallback(const geometry_msgs::PoseStampedConstPtr& poseLD_ptr)
{
previous_poseLD_ = *poseLD_ptr;
poseLD_updated_ = true;
if(poseLD_updated_ && yaw_updated_ && scan_updated_)
computePointCloud();
}
The emitted warning:
[ INFO] [1327752242.614698280]: pointcloud_builder_node started
[ WARN] [1327752243.045818408]: Problem: Frame id / does not exist! Frames (3): Frame /laser exists with parent /base_link.
Frame /base_link exists with parent NO_PARENT.
[ WARN] [1327752243.364658771]: Problem: Unable to lookup transform, cache is empty, when looking up transform from frame [/laser] to frame [/base_link]
What I can see the warning was originated from the catch block, looking at the warning message of "Problem:..". But then, I'm stuck to proceed with this kind of warning.
Is this just a startup issue? Have you resolved it?
Yes, it's resolved. Thanks for reminding me to update it!