[Documentation] [TitleIndex] [WordIndex

Note: This tutorial assumes that you have read tutorial 1, as it shares the same code base..
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

How to activate loop closure optimization (tutorial2.cpp)

Description: This tutorial describe how to set the internal solver inside Karto to activate the loop closure mechanism. It's based on the file tutorial2.cpp

Tutorial Level: INTERMEDIATE

What does it do ?

This tutorials shows you how to add a loop closure solver (in this case ROS SPA) to correct the map in the event of a loop closure. If you are not setting the solver, the loop closure will not happen.

Show me the code ?

The entire code for this tutorial is in the samples directory and is appropriately called tutorial2.cpp

Setting the solver

Karto can use several loop-closure solvers, the current best one is called SPA (Sparse Pose Adjustment) in the sba ROS package. The other solvers that have been tested but are not included are PCG (Preconditioned Conjugate Gradient) and TORO.

To activate SPA in Karto:

   1 // Get karto default mapper
   2 karto::Mapper* pMapper = new karto::Mapper();
   3 
   4 // set solver
   5 SpaSolver* pSolver = new SpaSolver();
   6 pMapper->SetScanSolver(pSolver);

What is the correct output of tutorial1 ?

$ ./tutorial2
Registering sensor:  laser0
Pose: 0 0 0 Corrected Pose: 0 0 0
Pose: 1 0 1.57 Corrected Pose: 0.799804 -0.156715 1.48971
Pose: 1 -1 2.35619 Corrected Pose: 0.756943 -1.03575 2.27242
Generating map...
width = 69, height = 68, scale = 10, offset: -2.8885, -3
****************************XXX              XXXX********************
*************************XXX                    XXX******************
***********************XXX  *               *   *  XX****************
**********************XX                          * *XX**************
********************XX*                               *X*************
*******************X*   *                        * *   *XX***********
******************X*   *                             *  *XX**********
*****************X* *    *             XXXXXX   * *   *  *XX*********
****************X* *  *                     XXXXX    *  *  XX********
***************X* * *  * *                       XXX  *   * XX*******
**************X* * *  *XXXXXXXXXXXXXXX             XXX   *  *X*******
*************X* * * XXXX             XXXX          * XXX*  * *X******
*************X   XXX                     XX            XX     *X*****
************X*  XX                         XX           XX* *  X*****
***********XX XX  *                          XX          *XX   *X****
***********XXXX                               XX           XX*  X****
**********XXX                                   XX          XX   X***
**********XX                                     XX          XX  X***
*********XX                                       XX          X * X**
********XX *                                        X         *X  X**
*******XXX                                          XX         XX X**
******XX X                                                      X* X*
******X*XX                                                       X X*
*****X* X                                                        XXX*
****XX  X                                                         XX*
****X* *X                                                         XX*
***X*  *X                                                          XX
***X  *   *                                                        XX
**XX*   *         *                                                XX
**X   *   * **  *                                                   X
**X     *                                                           X
*X *                                                                X
*X    *                                                             X
*X                                                                   
*X                                    *                              
X  *                                 **                              
X                                   ***                              
X                                  ****                              
X                                ******                              
X                               *******                              
X                              ********                              
X                             *********                              
X                            **********                             X
X                          ************                             X
X                         *************                             X
XX *                     **************                        *  * X
*X                      ***************                           *XX
*X                     ****************                        *   X*
*X *  *              ******************                  *       * X*
*XX*                *******************                           X**
**X   *            ********************               *  *        X**
**X *       *   * *********************           *    *      *  X***
***X             **********************             *     * *   *X***
***X           ************************              *  *  * *  X****
****X  *    * *************************                * *     XX****
****X*   * * **************************           *  *  * * * *X*****
*****X    * ***************************               *  * * *X******
*****XX *  ****************************                *  * *X*******
******X* ******************************               *  * *X********
*******X*******************************          *      * *XX********
***************************************              *   *X**********
***************************************        * **     *X***********
***************************************               *XX************
***************************************           ** XX**************
***************************************     *   *  XXX***************
***************************************         XXXX*****************
***************************************     XXXXX********************
***************************************XXXXXX************************


2019-10-19 12:50