Skip to content

Loop Closure Tutorial

Florian Tschopp edited this page Jun 28, 2019 · 1 revision

Loop-Closure Tutorial

Some note about the tools available to to close loops.

Looking for loop-closures

Open a map in the maplab console and run lc. This searches for loop-closures across all missions of the loaded map. Whenever a loop is found, duplicate landmarks in that region are merged, and a loop-closure edge is added between the query vertex and the nearest vertex in the overlapping pose-graph segment. Note that at this stage, the pose-graph of the map is left unchanged and the found loops are not actually being closed yet.

The following parameters are good to know about:

  • pl_num_neighbors: Common values are in the range of 3-10. Determines the number of nearest-neighbor descriptors retrieved for each query descriptor. This number per default depends on the number of landmarks/observation in the map. Setting it to a larger value increases recall but may decrease precision.
  • lc_ransac_pixeL_sigma: Default 2.0. The pixel sigma used for the PnP RANSAC pose estimation. Increasing this value increases recall, but increases the chance of accepting geometrically bogus loop-closures. This parameter often also depends on the number, configuration and calibration quality of the camera(s). In general, the better the calibration (both intrinsics and extrinsics), the lower this value can be chosen.
  • ld_min_image_time_seconds: Default 10. Whenever a vertex is queries against the database for a loop-closure, all descriptor matches associated with vertices that are less than ld_min_image_time_seconds seconds before or after the time of the query vertex are ignored. This makes sure that loops are closed against immediately following or preceding structure.

Loop-closure edges are visualized in RViz as green lines on topic `/vi_map_edges/loop_closure'.

Closing the loops

After loop-closures have been found, the pose-graph needs to closed at the corresponding trajectory segments. This can be achieved by running Bundle-Adjustment in specific configurations. In theory, loops may be closed solely based on the merged landmarks. However, in practice, this is often difficult to achieve, especially in the presence of m-estimators on the reprojection error-terms (default). This is where the loop-closure edges come in handy. You can add them to the BA problem with ba_include_loop_closure_edges=true. Since the loop-closure edges are strong constraints between vertices, any wrong loop-closure could immediately heavily distort the pose-graph. Therefore, automatic outlier detection is available and comes in two flavors for these type of error-terms:

  • Switch-variable: A variable in taking a value between 0.0 and 1.0, indicating how much the BA trusts the geometric correctness of a particular loop-closure. Jointly estimating the value of this variable alongside the rest of the error-terms (odometry, perhaps visual, ...) during BA allows for dynamically disabling wrong loop-closure constraints. The switch-variables are enabled by default and can be disabled with ba_use_switchable_constriants_for_loop_closure_edges. Also note that a prior error-term is added on every switch variable with a variance specified in the loop-closure edge. This error-term prevents BA from readily disabling all loop-closure edges in order to eliminate the costs associated with these error terms. Therefore, if BA seems to keep trusting wrong loop-closures, try increasing the variance on the switch variable. Otherwise, decrease it. You can set the variance with the command `assign_switch_variable_uncertainties_for_loop-closure_edges --lc_switch_variable_variance=<some_variance>".
  • Cauchy M-Estimator: If the switch variables are disabled (i.e. ba_use_switchable_constriants_for_loop_closure_edges=false), a Cauchy M-Estimator is used on the loop-closure error terms instead. The Cauchy loss parameter can be specified with ba_loop_closure_error_term_cauchy_loss (default: 10.0).

If the gaps to close are large, it usually makes sense to first run a pose-graph-relaxation-like BA with only odometry and loop-closure error terms: optvi -ba_include_visual=false -ba_include_wheel_odometry=true ba_include_inertial=true -ba_include_loop_closure_edges=true. This should close the loops. In a second optimization step, do a normal BA optimization: optvi -ba_include_visual=true -ba_include_wheel_odometry=true ba_include_inertial=true -ba_include_loop_closure_edges=false. This should further refine the pose-graph and landmarks.

Clone this wiki locally