Ask Your Question

Revision history [back]

The output of rostopic echo is likely to be OK. To be sure you can open Rviz and visualize the pointcloud. The subscriber declaration.

sub = nh.subscribe ("input_cloud", 1, cloud_callback); has to be done outside the while loop. Most likely this will fix your issue, as so far I do not see any other problem.

The output of rostopic echo is likely to be OK. To be sure you can open Rviz and visualize the pointcloud. The subscriber declaration.

declaration. sub = nh.subscribe ("input_cloud", 1, cloud_callback);

has to be done outside the while loop. Most likely this will fix your issue, as so far I do not see any other problem.

In fact, defining a rate in the subscriber does nothing helpful in this case. That is, you are executing your callbacks queue at 10 hz, but this frequency is already given by the publisher. Even if you have two publishers and only one subscriber, the 10 hz frequency will not be followed in the callback. Therefore, I would require as:

void cloud_callback (const sensor_msgs::PointCloud2ConstPtr& cloud_msg){
     ROS_INFO("inside callback");
}

int main (int argc, char** argv) {
     ros::init (argc, argv, "cloud_sub");
     ros::NodeHandle nh;
     ros::Rate loop_rate(10);
     ros::Subscriber sub;
     sub = nh.subscribe ("input_cloud", 1, cloud_callback);
     ros::spin();
 }