7、Cartographer graph building algorithm

 

Cartographer:https://google-cartographer.readthedocs.io/en/latest/

Cartographer ROS2:https://github.com/ros2/cartographer_ros

The operating environment and software and hardware reference configurations are as follows:

7.1、Introduction

Cartographer is a 2D and 3D SLAM (simultaneous localization and mapping) library supported by Google's open source ROS system. Method graph construction algorithm based on graph optimization (multi-threaded backend optimization, problem optimization built by CERE). Data from multiple sensors, such as LIDAR, IMUs, and cameras, can be combined to simultaneously calculate the sensor's position and map the environment around the sensor.

The source code of Cartographer mainly includes three parts: Cartographer, cartographer_ros, and Cers-Solver (back-end optimization).

image-20230420170956628

 

Cartographer adopts the mainstream SLAM framework, that is, the three-stage of feature extraction, closed-loop detection, and back-end optimization. A certain number of LaserScan forms a submap submap, and a series of submap submaps make up the global map. The cumulative error of the short-term process of building a submap with LaserScan is not large, but the long-term process of building a global map with a submap will have a large cumulative error, so it is necessary to use closed-loop detection to correct the position of these submaps, the basic unit of closed-loop detection is submap, and closed-loop detection adopts a scan_match strategy. The focus of cartographer is the creation of submap submaps that fuse multi-sensor data (odometry, IMU, LaserScan, etc.) and the implementation of scan_match strategies for closed-loop inspection.

cartographer_ros is running under ROS and can accept various sensor data in the form of ROS messages

After processing, it is published in the form of a message for easy debugging and visualization.

7.2、use

7.2.1、pre-use configuration

Note: Since ROSMASTER series robots are divided into multiple robots and multiple devices, the factory system has been configured with routines for multiple devices, but because the product cannot be automatically identified, it is necessary to manually set the machine type and radar model.

Raspberry Pi PI5 master control needs to enter the docker container first, Orin master control does not need to enter,

according to the model of the car, the type of radar and the type of camera, make the following modifications:

9e93005c-1684146808579-1

After the modification is complete, save and exit vim, and then execute:

You can see the model of the currently modified car, the type of radar and the type of camera.

7.2.2、specific use

Note: When building the image, the slower the effect, the better (note if the rotation speed is slower), too fast the effect, the effect will be poor.

First of all, you need to do port binding operations in the host [that is, on the jetson of the car] [see the port binding tutorial chapter], which mainly uses two devices: radar and serial port;

Then check whether the radar and serial device are in the port binding state: on the host [that is, the jetson of the car], refer to the following command to view, and the successful binding is the following state:

image-20230421151543423

If the radar or serial device is not bound to the display, you can plug and unplug the USB cable to view it again

Raspberry Pi PI5 master needs to enter the docker container first, Orin master does not need to enter,

Enter the docker container (for steps, please refer to [docker course chapter ----- 5. Enter the robot's docker container]),

and execute the following launch file in the terminal:

  1. Start mapping

  1. Start rviz to display the map, this step is recommended to be executed in the virtual machine, and multi-machine communication needs to be configured in the virtual machine

image-20230420173657374

 

  1. Start the keyboard control node, this step is recommended to be executed in the virtual machine, and multi-machine communication needs to be configured in the virtual machine

    Or use the remote control [Move the trolley slowly] to start building the map until the complete map is built

image-20230420173816269

  1. Save the map, the path is as follows:

The save path is as follows:

image-20230420161956140

A PGM image, a YAML file yahboomcar.yaml

Parameter parsing:

7.3、node parsing

7.3.1、display the computational graph

7.3.2、cartographer_node details

image-20230420174247512

image-20230420174327717

7.3.3、TF transform

image-20230420174517180