10. Data conversion and point cloud

10.1, scan to image

image-20210903144710184

image-20220304174440287

Create subscribers and publishers

Process the data in the callback function [self.laserCallback()] and publish it

10.2, ROS and PCD

Introducing several tools run by several ROS nodes. Their function is to convert between format point clouds or packages and point cloud data (PCD file format).

Launch Astra Camera

Point cloud display: rviz (start the rviz command, select the corresponding topic, modify parameters, and present different effects); pcl_visualization tool.

10.2.1, pointcloud_to_pcd

Save ROS point cloud messages in the specified PCD file.

10.2.2, convert_pcd_to_image

Load a PCD file (must have x y z rgb) and publish it as a ROS image message five times per second.

10.2.3, convert_pointcloud_to_image

Subscribe to a ROS point cloud topic and publish it as image information.

10.2.4, pcd_to_pointcloud

Load a PCD file and publish it one or more times as a ROS point cloud message.

10.2.5, bag_to_pcd

rosbag recording

Command: rosbag record topic1 [topic2 topic3 ...]

bag_to_pcd

Read a package file and save the ROS point cloud message in the specified PCD file. This requires a bag file.

10.3, PCL three-dimensional point cloud

PCL (Point Cloud Library) is a large cross-platform open source C++ programming library built on the basis of previous point cloud-related research. It implements a large number of point cloud-related general algorithms and efficient data structures, involving point cloud acquisition, Filtering, segmentation, registration, retrieval, feature extraction, recognition, tracking, surface reconstruction, visualization, etc. It supports multiple operating system platforms and can run on Windows, Linux, Android, Mac OS X, and some embedded real-time systems. If OpenCV is the crystallization of 2D information acquisition and processing, then PCL has the same status in 3D information acquisition and processing. PCL is a BSD authorized method and can be used for free commercial and academic applications.

PCL was originally developed under ROS (Robot Operating System) from Technische Universität München (TUM - Technische Universität München) and Stanford University ) is an open source project maintained and developed by Dr. Radu and others. It is mainly used in the field of robot research and application. With the accumulation of various algorithm modules, it became independent in 2011 and officially formed a powerful team with peers in global 3D information acquisition and processing. The development and maintenance teams are mainly from many well-known universities, research institutes and related hardware and software companies. It is developing very rapidly, and new research institutions are constantly joining. With the financial support of many world-renowned companies such as Willow Garage, NVidia, Google (GSOC 2011), Toyota, Trimble, Urban Robotics, Honda Research Institute, etc., new research solutions are constantly being proposed. The development plan and code updates are very active, and it has been released from version 1.0 to version 1.7.0 in less than a year.

This section mainly explains random point cloud publishing and point cloud visualization.

10.3.1. Point cloud release

To publish a point cloud, the launch file contains the startup of rviz. So I can clearly see a point cloud flashing in the middle of rviz.

image-20210903152536091

The source code comments are very clear, please check the source code directly. ~/yahboomcar_ws/src/yahboomcar_visual/src/pub_pointCloud.cpp

10.3.2. Point cloud visualization

-rviz

The PCL visualization library was created to quickly restore and visualize the results obtained after calculating three-dimensional point cloud data through algorithms. A highgui program similar to OpenCV is used to display two-dimensional images or two-dimensional shapes on the screen.

Start command

image-20210903153621551

[Ctrl]+[-]: Zoom out.

[Shift]+[+]: Zoom in.

[Alt]+[-]: Zoom out.

[Alt]+[+]: Pull in.

The mouse wheel and left and right buttons are also controllable.

The source code comments are very clear, please check the source code directly. ~/yahboomcar_ws/src/yahboomcar_visual/src/pcl_visualize.cpp