Maze Solving

From RoboWiki
Jump to: navigation, search

Maze solving, or maze following, is the act of traversing a maze to a goal location, usually combing simple forms of Path Planning and Wall Following. Maze solving is commonly used for Tabletop Robotics, most notably the Trinity Firefighting Competition. Much like path planning, maze solving is a complex topic, though with certain Sensors and algorithms, you can easily beat out the competition!

Contents

Maze Types

A maze is defined as a series of branching passages which may, or may not, lead from a starting to an end position. In certain tabletop robotics competitions, starting and ending positions vary. For example, your robot may start at a given location, but must find a certain object in the maze which is placed at random locations (such as a lit candle).

File:LinearMaze.png
A sample linear maze. Note that all the walls are connected, and there are no free-floating walls.

Also note that some mazes are not built on a desecrate set of coordinates; meaning that a maze doesn't have to fit to a grid of set positions or uniform lengths. The image of the sample linear maze is a discrete world, because the maze fits in a grid. Having a discrete maze greatly helps with movement and simplifies the competition.

Linear Maze

Linear mazes, or "simple mazes", are the most basic type of maze to solve. It means that all walls in a maze are connected to the maze wall, and no walls "float" by themselves. This special property allows for many simple, but powerful, algorithms to work. This kind of maze does not have to be of a certain size, nor does it have to have a certain number of paths or junctions.

Complex Maze

A sample complex maze. Note that in the top-right, there is a free-floating room in which no walls connect to it.

A complex maze can have any number of free-floating walls or halls. A "complex maze" does not have to be a certain size or have any number of junctions or halls, but must have at least one free-floating structure. We consider these mazes hard to solve because a robot may have to go down an incorrect path to "explore", since there is not necessarily a single path to take. General approaches to complex mazes are much more complex than simple mazes, and usually involve the usage of data structures, which requires advanced Programming knowledge.

Solution Approach

Many approaches exist for solving a maze. The best approach would be to combine normal Wall Following with right-handed or left-handed wall follow. In certain cases, especially with complex mazes, it would be better to focus on graph theory algorithms. Graph theory is a topic in Computer Science that studies paths and how to optimally navigate them. Related algorithms, such as "depth-first search" or simply DFS, are a good way of dealing with complex mazes that have uniform sizes.

Note of caution: Never "hard-core", or "dead-reckon", a solution! Your robot should never blindly go forward a certain distance, then turn and expect to be where you want it to be. Never pre-program distances to travel or turn a certain time, use feed-back! Sensors can misread and are not perfect; you shouldn't rely on only one to give you accurate enough information to move and turn correctly. Use wheel encoders to measure distance, and read multiple times your sensor before you commit to a turn.

Make sure your movement primitives (driving forward, rotation, wall following, etc.) work well before programming your maze solving logic!

Linear Maze

Solving linear mazes is the most simple approach. Usually right or left hand wall follow is the best approach, though sometimes a slight modification, or special "exception", is added to the logic to handle special aspects of a maze.

Right or Left Wall Follow

Since linear mazes always have their walls connected, your robot can just follow a wall and is guaranteed to visit all of the maze. Assuming there aren't big open rooms and that there are only hallways in the maze, this approach is the most simple and easy to program.

The algorithm is as follows:

  1. Move forward
  2. Check for collisions on the front and both sides
  3. If the preferred turning side is open
    1. Turn 90 degrees towards that side
    2. Move ahead a small distance (To be parallel to the next wall)
  4. If the front is blocked
    1. See which side (left or right) is open
    2. Turn towards the side that is both open and preferred
    3. If the preferred turn direction is blocked, turn the opposite direction

To improve on the above algorithm, you can continue moving forward with the robot while taking a "smooth" turn. You can achieve this by lightly rotating one wheel faster than another, while both are running, to make a wide turn. PID Controllers can also be used to make a smooth turn.

Overall:

  • Good: Simple and quick to program.
  • Bad: Can't deal with complex mazes.

Complex Maze

Complex mazes are significantly more difficult, as described, because of the "floating walls" issue. From graph theory to using state machines, there are many possible solution approaches. The best approach, in general, is to mix a graph theory algorithm (i.e. depth-first search) with a state machine (to note which room you are in).

Many of the following algorithms assume some sort of basic movement algorithm are already implemented, such as right-hand wall follow algorithm.

State Machine

A state machine is a simple structure that represents the state your robot is in, but allows for complex rules defining when to change states. This is helpful as this can be used as a way to identify which room you are in, and which logic to use when changing rooms. Read more about it on wikipedia.

  • Good: Simple and clear to plan out
  • Bad: Lacks any intelligence or a dynamic approach, similar to dead-reckoning (which is very bad!)

Graph Theory Search

Breadth-first search or depth-first search, based off of graph theory, is a powerful way of searching rooms and halls for an object, as well as back-tracking to a previous location. This can be done by saving movement history in memory (in a queue or stack), and re-visitng locations by running running through "inverted" movement instructions.

  • Good: Formal, proven, quick
  • Bad: Hard to program, needs data structures, requires a uniform maze

Pledge Algorithm

Follows a favored direction, only making right-follow a zero-sum turn.

  • Good: Formal, proven, good with "island" structured
  • Bad: Hard to program, not used in the club before

Experimentation

It has hard to experiment a maze-solving approach, even with a working robot and a maze. If you have any experience programming, you should pick up a quick prototyping language such as Java, MatLab, or Processing, and run through virtualized implementations of your maze-solving algorithm. Player/Stage also provides robotis simulation functionality, but may be overly difficult to use for new members.

External Links

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox