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

Pointcloud is only being published playing a certain bagfile

asked 2015-12-04 08:32:56 -0500

sven-hoek gravatar image

updated 2015-12-06 10:42:44 -0500

I'm writing a node that subscribes to rectified stereo images from stereo_image_proc and the camera_info from the camera node. It processes the images (using openCV) to compute and publish the camera pose as message and to /tf. Also I publish two image topics and a pointcloud topic.

The problem is it only works with one older bagfile I recorded. When I use another bagfile I recorded recently it does not publish the pointcloud and rostopic echo /pointcloud results in:

WARNING: no messages received and simulated time is active.
Is /clock being published?

I tried it with use_sim_time set as both true or false (and using rosbag play --clock). The only differences between the bags are that the older bag was recorded on another laptop running groovy or hydro. The topics where in another namespace but I adjusted everything so that my node receives and processes the rectified images correctly (by remapping, no recompiling of the node). Also when I try to let the node run with live images fed from the camera it receives and processes them but I can't publish my pointcloud. Even publishing a static pointcloud does not work athough it works while playing the old bagfile. Oh and the bagfiles only contain the topics from the camera node (images, camera_info), /rosout and /rosout_agg. The rqt_graphs look the same for both the old and new bagfiles.

This is part of my code:

typedef pcl::PointXYZ PointT;
typedef pcl::PointCloud<PointT> PointCloud;

class VisualOdometer
    ros::Publisher pcPub_;
    std::vector<cv::Point3d> map_;
    string worldFrame_;


        ros::NodeHandle nh;
        pcPub_ = nh.advertise<PointCloud>("pointcloud", 50);

    void publishPC()
        PointCloud pointCloud;
        pointCloud.height = 1;
        pointCloud.width = map_.size();
        for (unsigned int i = 0; i < map_.size(); ++i)
                pointCloud.points.push_back(PointT(map_[i].x, map_[i].y, map_[i].z));
        pointCloud.header.frame_id = worldFrame_;
        pointCloud.header.stamp = ros::Time::now().toNSec();

Does anyone have an idea why it's only working with the older bagfile? It seems that my node is not the problem or maybe somehow the way it manages time related stuff?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-12-11 19:07:20 -0500

sven-hoek gravatar image

Okay, I finally found the problem: I changed

pointCloud.header.stamp = ros::Time::now().toNSec();


pointCloud.header.stamp = ros::Time::now().toSec();

and it seems to be working with both the old bagfile and the new ones (and hopefully with the live image feed). I wonder why I didn't try this out (at least I tried just ros::Time::now()) but also why they use toNSec() in an example on the pcl_ros wiki page. Gonna send them a notification.

I don't know whether they changed the format of the time being published by bagfiles or if the timestamps in nanoseconds of the newer ones just were out of the 32bit range and I'm honestly too lazy to find out as it's working now but if anyone knows the details I'd be interested to hear.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-12-04 08:32:56 -0500

Seen: 222 times

Last updated: Dec 11 '15