In this project, we utilized SlamToolbox and TurtleBot3 Waffle Pi to achieve 2D SLAM (Simultaneous Localization and Mapping) in a 500 m² indoor environment. The process involved recording bag files as the robot moved around the space, followed by parameter tuning to optimize the quality of the generated maps.
The resulting map clearly demonstrates significant inaccuracies. However, these experiments provided valuable insights into the specific conditions under which the algorithm struggled and which parameters should be better tuned.
- Poor scan correlation accuracy during complex robot movements, fast turns and abrupt maneuvers caused significant inaccuracies in scan matching.
- Error accumulation in feature-scarce areas.
- Loop closure recognition was not working properly, parameter tuning needed.
General parameter tuning involves adjusting settings influenced by the robot's sensor capabilities, movement conditions, and the environment features. To tune these parameters, we conducted a series of small experiments where the robot followed simple trajectories such as straight lines, circles, and loops. This approach allowed us to ensure fast iteration in the tuning process while obtaining reliable results under various movement conditions.
The map generated for one of the rooms demonstrates significant improvement. However, due to incomplete loop closure settings, some areas that should overlap are misaligned.
As it is illustrated in the main diagram of the Slam Toolbox package, the loop closure identication is performed by the funtion TryCloseLoop.
With an understanding of how the TryCloseLoop function operates, we decided to fine-tune the following parameters, which primarily serve as thresholds. Parameters related to scan correlation and matching were set to the default recommended values provided by Slam Toolbox.
- loop_match_minimum_chain_size
- loop_match_maximum_variance_coarse
- loop_match_minimum_response_coarse
- loop_match_minimum_response_fine
The TryCloseLoop
function performs the following steps to identify and confirm loop closures:
-
Candidate Chain Evaluation: The function first generates a
candidateChain
—a vector of potential nodes in the pose graph that could establish a loop closure with the current node. If the size of this chain is smaller than the parameterloop_match_minimum_chain_size
, the loop closure is discarded. -
Initial Scan Matching: Next, the
MatchScan
function is called to identify the node within thecandidateChain
that best matches the current node. This matching process is performed at a coarse or low resolution. For the loop closure identification to proceed, the computed variance and coarse response of the best candidate must be below and above the thresholds set by the parametersloop_match_maximum_variance_coarse
andloop_match_minimum_response_coarse
, respectively. -
Refined Scan Matching: The
MatchScan
function is then called again, but this time at a finer resolution to achieve more precise correlation and improve pose estimation. The fine response value must exceed the threshold defined by theloop_match_minimum_response_fine
parameter. -
Loop Closure Confirmation: If all the specified conditions are met, a loop closure is confirmed. The best candidate node is then linked to the current node, and the poses in the pose graph are optimized to incorporate the new loop closure information.
By printing the computed values for the candidate chain size, covariance, and coarse and fine responses to the terminal, we were able to tune the parameters effectively in order to generate loop closures where they were expected and avoid undesired ones.
In this example, a correct loop closure is identified which aligns the walls and obstables of the previous map.
We recorded a ROS2 bag file for each room. Using the functionalities of SlamToolbox, we merged the generated maps into a single, unified map.