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

Pointcloud from Xtion in Matlab with ROS IO package

asked 2015-02-18 07:56:59 -0600

dd_diode gravatar image

Hey there,

I'm trying to get a Pointcloud from ROS to MATLAB via ROS IO. Getting the Data works so far with

function pointCloudMessage( message )
    pclmsg.width = message.getWidth();
    pclmsg.height = message.getHeight();
    pclmsg.offset = message.getData().arrayOffset();
    pclmsg.pointStep = message.getPointStep();
    pclmsg.rowStep = message.getRowStep();
    pclmsg.isDense = message.getIsDense();
    pclmsg.isBigendian = message.getIsBigendian(); = uint8(message.getData().array());

    numberOfPoints = pclmsg.width*pclmsg.height;

    pcl = : numberOfPoints * pclmsg.pointStep+pclmsg.offset);
    pcl = reshape(pcl, pclmsg.pointStep, numberOfPoints );

as file, and

>> roscore.RosMasterUri='http://localhost:11311';
>> node = rosmatlab.node('MATLAB', roscore.RosMasterUri);
>> ir_subscriber = rosmatlab.subscriber('/camera/depth_registered/points','sensor_msgs/PointCloud2',1,node);
>> ir_subscriber.setOnNewMessageListeners({@pointCloudMessage});

in the console. This code generates a 32x307200 matrix with uint8 data.

Now I'm stuck at interpreting the resulting data. Is is float (4 byte) data? Is the reshaping of the data correct? What is included in the data? RGBD as floats would be 6*4= 24 byte.

Thanks for the help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-02-21 12:08:41 -0600

paulbovbel gravatar image

It depends on the number of fields, and the size of the fields. These are defined in the message ( ) fields[] array ( ).

If you're doing something quick and dirty and you know the shape of your incoming data, you can always hardcode the sizes, however the more robust approach would be to process based on the fields[] data.

edit flag offensive delete link more

Question Tools


Asked: 2015-02-18 07:56:59 -0600

Seen: 430 times

Last updated: Feb 21 '15