According to the draftsman _ros document translation
Cartographer is a complex system, and it needs a good understanding of its internal work to adjust it. This page attempts to visually summarize the different subsystems used by cartographers and their configuration values. If you are not only interested in the introduction of the cartographer, you should also refer to the cartographer's paper. It only describes 2D SLAM, but it strictly defines most of the concepts described here. These concepts usually apply to 3D.
W.Hess, D. Kohler, H. Rapp and D. Andor, Real-time Loop Closure in 2D Laser Radar SLAM, ICRA, 20 16 IEEE International Conference. IEEE,20 16。 Page1271–1278.
Cartographers can be regarded as two independent but related subsystems. The first is LocalSLAM (sometimes called front-end or local trajectory generator). Its job is to construct a series of subgraphs. Each subgraph is locally consistent, but we accept that LocalSLAM drifts with time. You can find install _ isolated/share/cartoon/configuration _ files/artifact _ builder _ 2d. Lua is 2d and install _ isolated/share/cartoon/configuration _ files/monument _ builder _ 3d. Lua is 3d. (In the rest of this page, we will call trait _ builder _ nd a public option. )
The other subsystem is the global SLAM (sometimes called the back end). It runs in the background thread, and its main job is to find loop constraints. It is realized by scanning matching subgraphs. It also combines other sensor data to obtain a higher-level view and determine the most consistent global solution. In 3D, it also tries to find the direction of gravity. Most of its options can be found in install _ isolated/share/cartographer/configuration _ files/pose _ graph.lua.
At a higher level of abstraction, the job of LocalSLAM is to generate good subgraphs, while the job of global SLAM is to combine them most consistently.
Ranging sensors (such as lidar) provide depth information in multiple directions. However, some measurements have nothing to do with SLAM. If the sensor part is covered with dust or if it is guided to a part of the robot, some measured distances can be considered as SLAM noise. On the other hand, some farthest measurements may also come from unwanted sources (reflection, sensor noise) and have nothing to do with SLAM. In order to solve these problems, the cartographer first applies a band-pass filter and only keeps the range value between a certain minimum and maximum range. The minimum and maximum values should be selected according to the specifications of the robot and sensor.
pay attention to
In 2D, the cartographer will change the range of trajectory _ builder _ 2d. Missing _ data _ ray _ length exceeds the maximum range. It also provides max_z and min_z values for filtering 3D point clouds into 2D cuts.
pay attention to
In the draftsman profile, each distance is defined in meters.
Distance is measured over a period of time, and the robot is actually moving. However, the distance is provided by the "batch" sensor in the big ROS message. Cartographers can independently consider the timestamp of each message to consider the distortion caused by robot motion. The higher the measurement frequency of the cartographer, the better the combination of the measurement results into a single coherent scan that can be captured immediately. Therefore, it is strongly recommended to provide as much range data (ROS messages) as possible through scanning.
Range data is usually measured from a single point on the robot, but from multiple angles. This means that closed surfaces (such as roads) are often hit and provide many points. On the contrary, distant objects are not often hit and provide fewer points. In order to reduce the computational complexity of point cloud processing, we usually need to downsample point clouds. However, simple random sampling will remove points from areas with low-density measurements, while high-density areas will still have more points than needed. In order to solve this density problem, we can use voxel filter to downsample the original points into a cube with the same size, and only keep the center of mass of each cube.
Smaller cube size will lead to denser data representation, which will lead to more calculations. Larger multidimensional data sets lead to data loss, but at a faster speed.
After applying the fixed-size voxel filter, the cartographer also applied the adaptive voxel filter. The filter attempts to determine the optimal voxel size (at the maximum length) to achieve the target number of points. In 3D, two adaptive voxel filters are used to generate high-resolution and low-resolution point clouds, and their use will be clarified in LocalSLAM.
Inertial measurement unit can be a useful information source for SLAM, because it provides the precise direction of gravity (and therefore the ground) and a noisy but good overall indication of robot rotation. In order to filter IMU noise, gravity was observed for a certain time. If you use 2D SLAM, you can process the range data in real time without additional information sources, so you can choose whether to let the draftsman use IMU. Using 3D SLAM, IMU is needed, because it is the initial guess of scanning direction, which greatly reduces the complexity of scanning matching.
pay attention to
In the plotter configuration file, this value is defined in seconds every time.
Once you have scanned, combined and filtered from multiple ranges of data, you can prepare for the LocalSLAM algorithm. LocalSLAM uses the initial estimate from the attitude estimator to insert a new scan into its current subgraph construction through scan matching. The idea behind the attitude estimator is to use the sensor data of other sensors except the range finder to predict the position where the subgraph should be inserted in the next scan.
There are two scan matching strategies:
Either way, CeresScanMatcher can be configured to give each input a specific weight. Weight is a measure of data trust, which can be regarded as static covariance. The units of weight parameters are dimensionless quantities and cannot be compared with each other. The greater the weight of the data source, the more cartographers pay attention to this data source when scanning and matching. Data sources include occupied space (scanning point), translation and rotation of attitude extrapolator (or RealTimeCorrelativeScanMatcher).
pay attention to
In 3D, the parameters of placeholder _ space _ weight _0 and placeholder _ space _ weight _ 1 are related to high-resolution and low-resolution filtered point clouds, respectively.
CeresScanMatcher, named after Ceres Solver, uses Google as a library to solve nonlinear least squares problems. The scan matching problem is modeled as the minimization of the problem, in which the motion (transformation matrix) between two scans is the parameter to be determined. Ceres uses a descent algorithm to optimize the motion for a given number of iterations. Ceres can be configured to adjust the convergence speed according to its own needs.
RealTimeCorrelativeScanMatcher can switch according to your trust in the sensor. Its working principle is to search for similar scans in the search window, which is defined by the maximum distance radius and the maximum angle radius. When performing scan matching with scanning in this window, you can choose different weights for translation and rotation components. For example, if you know that the robot will not rotate too much, you can use these weights.
In order to avoid inserting too many scans in each sub-image, once the scan matcher finds the motion between two scans, it will pass through the motion filter. If the motion that caused it is not important enough, the scan will be deleted. Only when the motion of the scan is higher than a certain distance, angle or time threshold will the scan be inserted into the current subgraph.
When the local SLAM has received a given amount of range data, it is considered that the subgraph construction is completed. LocalSLAM will drift with time, and GlobalSLAM is used to solve this drift problem. The subgraph must be small enough to make the drift inside the subgraph lower than the resolution, so that the graph is locally correct. On the other hand, the subgraph should be large enough for the loop closure to work properly.
Subgraphs can store their range data in several different data structures: the most widely used representation method is called probabilistic grid. However, in 2D, you can also choose to use truncated signed distance field (TSDF).
Probability grid divides the space into 2D table or 3D table, in which each pixel has a fixed size, including the probability of being occupied by obstacles. Update the odds according to "hit" (measurement range data) and "miss" (free space between sensor and measurement point). Hit and miss can calculate different weights in the occupancy probability, giving more or less trust.
In 2D, only one probability grid is stored in each subgraph. In 3D, two mixed probability grids are used to scan matching performance. (The term "hybrid" only refers to the internal tree data representation, which is abstract to users)
Scan matching first aligns the distant points of the low-resolution point cloud with the low-resolution hybrid grid, and then refines the pose by aligning the high-resolution points with the high-resolution hybrid grid.
pay attention to
CartographerROS provides an RViz plug-in for visualizing subgraphs. You can select the subgraph to view from the number. In 3D, RViz only displays 2D projection (gray scale) of 3D mixed probability grid. The left pane of RViz provides the option to switch between low-resolution and high-resolution hybrid grid visualization.
TODO: record TSDF configuration
When LocalSLAM generates its continuous subgraphs, the global optimization (usually called "optimization problem" or "sparse attitude adjustment") task runs in the background. Its function is to rearrange subgraphs and make them form a coherent global graph. For example, optimization is responsible for changing the trajectory of the current construction to correctly align the subgraph about loop closure.
Once a certain number of trajectory nodes are inserted, the optimization will run in batches. Depending on how often you run it, you can resize these batches.
pay attention to
Set pose _ graph. Optimize _ every _ n _ nodes to 0 is a convenient way to disable global SLAM and focus on local SLAM behavior. This is usually the first thing to adjust the draftsman.
Global SLAM is a kind of "GraphSLAM", which is essentially a kind of attitude graph optimization. Its working principle is to construct constraints between nodes and subgraphs, and then optimize the constraint graph. Constraints can be intuitively regarded as small ropes that bind all nodes together. Sparse attitude adjustment completely fixed these ropes. The generated network is called "posture map".
pay attention to
Constraints can be visualized in RViz, and it is very convenient to adjust the global SLAM. You can also switch pose _ graph. constraint _ builder. log _ matches to get a regular report of the constraint generator in histogram format.
pay attention to
In fact, global constraints can not only find cyclic closures on a single trajectory. They can also align different trajectories recorded by multiple robots, but we will keep this usage and parameters related to global positioning, which is beyond the scope of this paper.
In order to limit the number of constraints (and calculations), the cartographer only considers the sub-sampling set of all closed nodes that construct constraints. This is controlled by the sampling rate constant. Sampling too few nodes may lead to missed constraints and invalid loop closures. Sampling too many nodes will slow down the global SLAM and prevent the real-time loop from closing.
When nodes and subgraphs are considered to establish constraints, they will pass through the first scan matcher named FastCorrelativeScanMatcher. The scan matcher is specially designed for cartographers, which can realize real-time closed scan matching. In FastCorrelativeScanMatcher, we rely on the "branch and bound" mechanism to work at different grid resolutions, effectively eliminating incorrect matching numbers. This mechanism is widely introduced in the cartographic articles introduced earlier in this paper. Suitable for exploration trees with controllable depth.
Once FastCorrelativeScanMatcher has a good enough suggestion (higher than the minimum matching score), it is input into Ceres scan matcher to improve posture.
Ceres is used to rearrange subgraphs according to multiple residuals when cartographers run optimization problems. The weighted loss function is used to calculate the residual. Global optimization has a cost function to consider a large number of data sources: global (closed loop) constraints, non-global (matcher) constraints, IMU acceleration and rotation measurements, local SLAM rough attitude estimation, ranging sources or fixed frames (such as GPS systems). You can configure the weights and Ceres options as described in the LocalSLAM section.
pay attention to
By switching, we can find the useful information of the residual used in the optimization problem: pose _ graph. Maximum number of final iterations.
As a part of its IMU residual, the optimization problem provides some flexibility for IMU attitude. By default, Ceres is free to optimize the external calibration between IMU and tracking framework. If you don't believe your IMU posture, you can record the results of Ceres global optimization and use it to improve your external calibration. If Ceres does not optimize your IMU posture correctly, and you fully trust your external calibration, you can keep this posture unchanged.
In the residual, the influence of outliers is dealt with by Huber loss function with Huber scale. The larger the Huber scale, the greater the influence of (potential) outliers.
Once the trajectory is completed, the cartographer will run a new global optimization, usually much more than the previous global optimization. This is done to improve the final result of the cartographer, which usually does not need real-time, so a large number of iterations are usually the right choice.