Skip to main content
. 2022 Nov 28;22(23):9269. doi: 10.3390/s22239269
Algorithm 1 Pseudocode for the spanning tree
  • 1:

    Input: occupancyGridMap, currentPose

  • 2:

    Output: spanningTree

  • 3:

    insert starting cell which contains the robot’s position in the queue spanningTree

  • 4:

    while all free cells in occupancyGridMap have been visited do

  • 5:

        determine all orthogonal and unvisited neighbors of the current cell moving counterclockwise and add them to the queue neighbor

  • 6:

        for all cells in queue neighbor do

  • 7:

            if distance of current cell in spanningTree and neighbor 1 then

  • 8:

               add current cell to the queue spanningTree

  • 9:

               set current cell in occupancyGridMap as visited

  • 10:

             go to the neighbor cell

  • 11:

          end if

  • 12:

        end for

  • 13:

        if distance of current cell in spanningTree and neighbor >1 then

  • 14:

            for cells in queue spanningTree do

  • 15:

               if distance of current cell in spanningTree and neighbor 1 then

  • 16:

                   go to the neighbor cell

  • 17:

               else

  • 18:

                   move to the previous cell in queue spanningTree

  • 19:

               end if

  • 20:

            end for

  • 21:

        end if

  • 22:

    end while

  • 23:

    return the spanning tree