Rosanswers logo

Previously, I posted how to get started on the point cloud data for the Openni. Many of you posted that i need to get through the tutorials for ROS to have a better understanding. I have done that now.One posted this code(for the subscriber) for me... which was very helpful.I have some qns on this code:

  1. We need to have both a publisher and subscriber node for the Kinect in order to get point cloud data.Am i right to say that?
  2. how do u get the depth data from the point cloud data?

Really need of help. I am sorry if i ask stupid questions.

    #include <ros/ros.h>
    #include <pcl_ros/point_cloud.h>
    #include <sensor_msgs/PointCloud2.h>

using namespace ros;
using namespace sensor_msgs;

class processPoint {
    NodeHandle nh;
    Subscriber sub;

    processPoint() {
        sub = nh.subscribe<sensor_msgs::PointCloud2>("/camera/rgb/points", 1, &processPoint::processCloud, this);

    ~processPoint() {   

    void processCloud( const sensor_msgs::PointCloud2ConstPtr& cloud );

void processPoint::processCloud( const sensor_msgs::PointCloud2ConstPtr& cloud ) {


int main(int argc, char **argv) {

    init(argc, argv, "processPoint");

    processPoint processPoint;

    Rate spin_rate(1);

    while( ok() ) {


Originally posted by lakshmen on ROS Answers with karma: 101 on 2011-06-14

Post score: 0

Original comments

Comment by lakshmen on 2011-06-15:
hi ppl ... is the page that give the correct code for point cloud : http://www.ros.org/wiki/pcl_ros


1 Answer 1


Rosanswers logo

Are you working with ROS node system or do you want to read in the pointcloud from a single c/cpp file?

  • In the first case you should roslaunch the openni_camera openni_node.launch file. This will publish the pointclouds on the /camera/rgb/points or /camera/depth/points topics (depending if you want XYZ or XYZRGB pointcloud). Look at roslaunch and the openni camera package.

  • In the second case you should look at the PCL library (pointclouds.org) as they have a ROS agnostic implementation.

Originally posted by KoenBuys with karma: 2314 on 2011-06-16

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by lakshmen on 2011-06-21:
I actually have written a code in C++ for the depth data and the point cloud data.I would like to publish the data, how should i do that?

Comment by lakshmen on 2011-06-17:
publishing and subscribing to the same topic u mean?

Comment by KoenBuys on 2011-06-17:
this requires subscribing to the topic of the openni camera and publishing to a new topic

Comment by lakshmen on 2011-06-16:
basically what i am trying to do is that i have written a code for the point cloud in C++ and want to implement it using ROS and plot it out in RVIZ... Any suggestions how i can go about doing it?

Comment by lakshmen on 2011-06-16:
thanks.... will read thru it... if i have qns, i will ask you....

Comment by KoenBuys on 2011-06-16:
Have a look here: http://www.pointclouds.org/documentation/tutorials/openni_grabber.php#openni-grabber

Comment by lakshmen on 2011-06-16:
i need to include both the publisher and subscriber code right?

Comment by lakshmen on 2011-06-16:
i just want to have point cloud information.which method is better?


Your Answer

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