10. Data transformation 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 given PCD

Introduce several tools for running several ROS nodes. Their role is the conversion between the format point cloud or package and point cloud data (PCD file format).

Start Astra Camera

Point cloud display: rviz (start the rviz command, select the corresponding topic, modify the 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 xyz 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 with image information.

10.2.4. pcd_to_pointcloud

Load a PCD file and publish 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 3D point cloud

PCL (Point Cloud Library) is a large-scale cross-platform open source C++ programming library established on the basis of absorbing previous researches on point cloud. 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 authorization method, which can be used for commercial and academic applications for free.

) under ROS (Robot Operating System). It is Munich an open source project maintained and developed by Dr. Radu With the accumulation of various algorithm modules, it became independent in 2011, and formally formed a strong development and maintenance team together with its counterparts in global 3D information acquisition and processing, mainly from many well-known universities, research institutes and related hardware and software companies. The development is very rapid, 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 institutes are constantly proposed. The development plan and code update 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

Publish the 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

The PCL visualization library is created to quickly restore and visualize the results obtained by calculating the 3D point cloud data through algorithms. Similar to OpenCV's highgui program, it is used to display 2D images or 2D 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