0
$\begingroup$

Rosanswers logo

Refer the code in velodyne_camera_calibration , when I run the code, it doesn't terminate and has no error but it doesn't continue in the middle(line 198 and line 190). In order to have convenient debug, I add some "cout" to print something.

  message_filters::Subscriber<sensor_msgs::Image> image_sub(n, CAMERA_FRAME_TOPIC, 1);
  message_filters::Subscriber<sensor_msgs::CameraInfo> info_sub(n, CAMERA_INFO_TOPIC, 1);
  message_filters::Subscriber<sensor_msgs::PointCloud2> cloud_sub(n, VELODYNE_TOPIC, 1);

 typedef sync_policies::ApproximateTime<sensor_msgs::Image, sensor_msgs::CameraInfo, sensor_msgs::PointCloud2> MySyncPolicy;
 Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), image_sub, info_sub, cloud_sub);
 cout << "breakpoint 1 " << endl;
 sync.registerCallback(boost::bind(&callback, _1, _2, _3)); // Add "cout << "breakpoint 2" << endl;" at the beginning of callback function
cout << "breakpoint 3" << endl;
  ros::spin();
cout <<"breakpoint 4" << endl;

After I run the code, only "breakpoint 1" and "breakpoint 3" show up. It means that the callback function is skipped and ros::spin is not implementing.

Can anyone help me figure out where the problem is ? Thanks!


Originally posted by KWL on ROS Answers with karma: 3 on 2016-08-02

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

It looks like this code is fine.

If you're not getting callbacks, you should use rqt_graph or rostopic to confirm that the calibration node is subscribed to the correct topics, and that data is published on all topics. If one of the topics is not present, the synchronizer will never call its callback.

ros::spin() is supposed to block until the program terminates, so that seems to be working properly.


Originally posted by ahendrix with karma: 47576 on 2016-08-02

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by KWL on 2016-08-03:
Thank you! As you suggest, I checked rqt_graph and found out that the node is not subscribed to the correct topics! :)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.