fork download
  1. #include "ros/ros.h"
  2. #include <pluginlib/class_list_macros.h>
  3. #include "openni_camera/openni_device_kinect.h"
  4. #include "openni_camera/openni_image.h"
  5. #include "openni_camera/openni_depth_image.h"
  6. #include <sensor_msgs/image_encodings.h>
  7. #include <pcl_ros/point_cloud.h>
  8. #include <pcl/point_types.h>
  9. #include <sensor_msgs/CameraInfo.h>
  10. #include <stereo_msgs/DisparityImage.h>
  11. #if ROS_VERSION_MINIMUM(1, 3, 0)
  12. #include <sensor_msgs/distortion_models.h>
  13. #endif
  14.  
  15. #define QUEUE_SIZE 15
  16. #define LOOP_RATE 33
  17.  
  18. //using namespace openni_wrapper;
  19.  
  20. typedef pcl::PointCloud<pcl::PointXYZ> DepthPoints; // depth/points
  21. typedef sensor_msgs::Image DepthImage; // depth/image
  22. typedef sensor_msgs::Image RGBImageColor; // rgb/image_color
  23. typedef sensor_msgs::Image RGBImageMono; // rgb/image_mono
  24. typedef pcl::PointCloud<pcl::PointXYZRGB> RGBPoints; // rgb/points
  25. typedef sensor_msgs::CameraInfo DepthCamInfo; // depth/camera_info
  26. typedef sensor_msgs::CameraInfo RGBCamInfo; // rgb/camera_info
  27. typedef stereo_msgs::DisparityImage DisparityImage; // depth/disparity
  28.  
  29. const char depth_points_topicStr[] = "/camera/depth/points",
  30. depth_image_topicStr[] = "/camera/depth/image",
  31. rgb_image_color_topicStr[] = "/camera/rgb/image_color",
  32. rgb_image_mono_topicStr[] = "/camera/rgb/image_mono",
  33. rgb_points_topicStr[] = "/camera/rgb/points",
  34. depthcamera_info_topicStr[] = "depth/camera_info",
  35. camera_info_topicStr[] = "rgb/camera_info",
  36. disparity_topicStr[] = "depth/disparity",
  37. depth_points_topicStr1[] = "/kinect1/depth/points",
  38. depth_image_topicStr1[] = "/kinect1/depth/image",
  39. rgb_image_color_topicStr1[] = "/kinect1/rgb/image_color",
  40. rgb_image_mono_topicStr1[] = "/kinect1/rgb/image_mono",
  41. rgb_points_topicStr1[] = "/kinect1/rgb/points";
  42.  
  43.  
  44. int ii=0;
  45. void cb_depth_points(const DepthPoints::ConstPtr& d){
  46. ROS_INFO("Depth Points: [%d]", ii);++ii;
  47. }
  48. void cb_depth_image(const DepthImage::ConstPtr& d){
  49. ROS_INFO("Depth Image: [%d]", 2);
  50. }
  51. void cb_rgb_image_color(const RGBImageColor::ConstPtr& d){
  52. ROS_INFO("RGB Image: [%d]", 3);
  53. }
  54. void cb_rgb_image_mono(const RGBImageMono::ConstPtr& d){
  55. ROS_INFO("Mono Image: [%d]", 4);
  56. }
  57. void cb_depth_points1(const DepthPoints::ConstPtr& d){
  58. ROS_INFO("Kinect1 Depth Points: [%d]",5);
  59. }
  60. void cb_depth_image1(const DepthImage::ConstPtr& d){
  61. ROS_INFO("Kinect1 Depth Image: [%d]",6);
  62. }
  63. void cb_rgb_image_color1(const RGBImageColor::ConstPtr& d){
  64. ROS_INFO("Kinect1 RGB Image: [%d]",7);
  65. }
  66. void cb_rgb_image_mono1(const RGBImageMono::ConstPtr& d){
  67. ROS_INFO("Kinect1 Mono Image: [%d]", 8);
  68. }
  69. int main(int argc, char **argv)
  70. {
  71. //Initialize the ROS system
  72. ros::init(argc, argv, "listener");
  73. ros::NodeHandle n;
  74. //Subscribe to the topic
  75.  
  76. ros::Subscriber depthPointsSub1 = n.subscribe(depth_points_topicStr1, QUEUE_SIZE , cb_depth_points1);
  77. ros::Subscriber depthImageSub1 = n.subscribe(depth_image_topicStr1, QUEUE_SIZE , cb_depth_image1);
  78. ros::Subscriber depthPointsSub = n.subscribe(depth_points_topicStr, QUEUE_SIZE , cb_depth_points);
  79. ros::Subscriber depthImageSub = n.subscribe(depth_image_topicStr, QUEUE_SIZE , cb_depth_image);
  80.  
  81. ros::Subscriber rgbImageSub1 = n.subscribe(rgb_image_color_topicStr1, QUEUE_SIZE , cb_rgb_image_color1);
  82. ros::Subscriber monoImageSub1 = n.subscribe(rgb_image_mono_topicStr1, QUEUE_SIZE , cb_rgb_image_mono1);
  83. ros::Subscriber rgbImageSub = n.subscribe(rgb_image_color_topicStr, QUEUE_SIZE , cb_rgb_image_color);
  84. ros::Subscriber monoImageSub = n.subscribe(rgb_image_mono_topicStr, QUEUE_SIZE , cb_rgb_image_mono);
  85. //Spin, waiting for messages to arrive
  86. ros::spin();
  87. return 0;
  88. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty