ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Getting Point cloud data from Openni driver

asked 2011-06-14 19:24:39 -0500

lakshmen gravatar image

updated 2016-10-24 09:02:35 -0500

ngrennan gravatar image

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() ) {

edit retag flag offensive close merge delete


hi ppl ... is the page that give the correct code for point cloud :
lakshmen gravatar image lakshmen  ( 2011-06-15 01:27:59 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2011-06-16 07:00:25 -0500

KoenBuys gravatar image

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 ( as they have a ROS agnostic implementation.

edit flag offensive delete link more


i just want to have point cloud information.which method is better?
lakshmen gravatar image lakshmen  ( 2011-06-16 17:41:29 -0500 )edit
i need to include both the publisher and subscriber code right?
lakshmen gravatar image lakshmen  ( 2011-06-16 17:50:23 -0500 )edit
thanks.... will read thru it... if i have qns, i will ask you....
lakshmen gravatar image lakshmen  ( 2011-06-16 18:27:42 -0500 )edit
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?
lakshmen gravatar image lakshmen  ( 2011-06-16 19:12:40 -0500 )edit
this requires subscribing to the topic of the openni camera and publishing to a new topic
KoenBuys gravatar image KoenBuys  ( 2011-06-17 07:25:16 -0500 )edit
publishing and subscribing to the same topic u mean?
lakshmen gravatar image lakshmen  ( 2011-06-17 08:03:55 -0500 )edit
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?
lakshmen gravatar image lakshmen  ( 2011-06-21 16:34:05 -0500 )edit

Question Tools


Asked: 2011-06-14 19:24:39 -0500

Seen: 3,451 times

Last updated: Jun 16 '11