Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <ros/ros.h>
  2. #include <sensor_msgs/PointCloud2.h> // For sensor_msgs::PointCloud2
  3.  
  4. #include "include/PointCloud.hpp"
  5.  
  6. void pointCloudReceived(const sensor_msgs::PointCloud2& msg, PointCloudHandler pointCloud);
  7.  
  8. int main(int argc, char **argv) {
  9. // Initialize the ROS system and become a node.
  10. ros::init(argc, argv, "pcl_obstacle_detector");
  11. ros::NodeHandle nh;
  12. ros::Subscriber sub_point_cloud;
  13.  
  14. PointCloudHandler pointCloud;
  15.  
  16. // 1. Subscribes to the point cloud topic /point_cloud
  17. // Type: sensor_msgs/PointCloud2
  18. sub_point_cloud = nh.subscribe("/point_cloud", 1000,
  19. &pointCloudReceived(pointCloud));
  20.  
  21. // Let ROS take over.
  22. ros::spin();
  23. }
  24.  
  25. void pointCloudReceived(const sensor_msgs::PointCloud2& msg, PointCloudHandler pointCloud) {
  26. pointCloud.setMsgPointCloud(msg);
  27. // ROS_INFO_STREAM("End of pointCloudReceived");
  28.  
  29. // 2. Processes the received point cloud to find clusters of points
  30. pointCloud.processReceivedPointCloud();
  31.  
  32. // 3. Publishes the clusters as a detection array on a ROS topic
  33. pointCloud.pubClusters();
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement