Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 171

subscribe to sensor_msg::PointCloud2

$
0
0
Hi, my ros subscriber is having trouble entering the callback. I'm using ROS_INFO to tell me if the callback is in. In the rqt_graph, it shows that the subscriber node is subscribed to the topic that the publisher is publishing. Using rostopic echo "topic", it is displaying a lots of numbers that i'm presuming that it is the pointcloud. below is my code. Publisher typedef pcl::PointCloud PointCloud; int main(int argc, char** argv) { ros::init (argc, argv, "pub_pcl"); ros::Publisher pub; pub = nh.advertise ("input_cloud", 1); pcl::PCLPointCloud2::Ptr cloud_blob (new pcl::PCLPointCloud2); pcl::PCDReader reader; reader.read (argv[1], *cloud_blob); sensor_msgs::PointCloud2 output; pcl_conversions::fromPCL(*cloud_blob, output); ros::Rate loop_rate(10); while (nh.ok()) { pub.publish (output); ros::spinOnce (); loop_rate.sleep (); } } Subscriber 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; while (nh.ok()) { sub = nh.subscribe ("input_cloud", 1, cloud_callback); ros::spinOnce (); loop_rate.sleep (); } }

Viewing all articles
Browse latest Browse all 171

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>