I am trying to convert a laser scan into point cloud so i can use its cartesian cordintes for computer vision purpose. But when i do it it seems like the width of point cloud converted is only 1. Before this i was using kinect sensor where both height and width were not 1. i'm getting confused to use the hokuyo sensor/multisense sensor. I am using gazbo for getting the lidar scan data. To convert lidar scan into pointcloud2 data i'm using this

#include <ros/ros.h>
#include <tf/transform_listener.h>
#include <laser_geometry/laser_geometry.h>

class My_Filter {
        void scanCallback(const sensor_msgs::LaserScan::ConstPtr& scan);
        ros::NodeHandle node_;
        laser_geometry::LaserProjection projector_;
        tf::TransformListener tfListener_;

        ros::Publisher point_cloud_publisher_;
        ros::Subscriber scan_sub_;

            scan_sub_ = node_.subscribe<sensor_msgs::LaserScan> ("/multisense/lidar_scan", 100, 

&My_Filter::scanCallback, this);
            point_cloud_publisher_ = node_.advertise<sensor_msgs::PointCloud2> ("/my_cloud", 100, false);

    void My_Filter::scanCallback(const sensor_msgs::LaserScan::ConstPtr& scan){
        sensor_msgs::PointCloud2 cloud;
        projector_.transformLaserScanToPointCloud("/head", *scan, cloud, tfListener_);

int main(int argc, char** argv)
    ros::init(argc, argv, "my_filter");

    My_Filter filter;


    return 0;

Here when i run this node, the height of point cloud is fine but width is only 1. and when i visualize the laser scan or pointcloud or pointcloud2 in rviz even when the lidar is rotating i can only see 2-d points as shown in below screenshot. Why is this happening. what should i do to convert it into 3d point cloud? Here all the point lies in single plane. enter image description here

  • $\begingroup$ Could you please clarify what you're asking? Can you post a sample set of the data used to generate your visualized data? The image looks 3D to me. Also, I believe Hokuyo lidar units are all single plane, which means that all data from a single scan will exist in a single line. $\endgroup$
    – Chuck
    Jul 31, 2017 at 13:29

1 Answer 1


I think, that the following two video tutorials can help you with your problem. The first one shows how to convert a laser scan into a pointcloud, and the second shows how to mix several laser scans into a single pointcoud.

1- How to convert a laser scan into a pointcloud

2- How to assemble several laser scans into a single PointCloud


Your Answer

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