Screenshots     Download     Purchase     Documentation     Tutorials     Resources     Contact     Forum     Search  

 
<<Prev 1 2 3 4 5 6 Next>>

Maze Model

To solve the maze we will need to know 3 things:

1. What is open (green) and what is blocked (blue)?
2. Where is the ball?
3. Where is the destination?

#1 is best represented (or modeled) as a two dimensional array with each array bucket containing a number that represents if the spot in the array is open (green) or blocked (blue). This can be thought of as a bitmap image with each "pixel" representing if the spot is open or closed. Note that you cannot use the image bitmap directly as there are too many pixels that represent an "open" or "closed" spot. The current image needs to be simplified to an ideal model.

#2 and #3 would then just be two x,y coordinates within that two dimensional array.

Thus the ideal maze model is a two dimensional square array. Since the maze is created using Lego blocks there are only so many blocks that can be placed in the maze. In this case the maze can contain a maximum of 14 2x2 blocks in either the horizontal and vertical direction. The array can then be a 14x14 array which is nice and small and can be quickly processed. Therefore, the first part of transforming the image into a small 14x14 array is to align the image into a square. With this alignment the image is now a scale factor representation of the array.

In order to continue the transformation we cannot simply scale the image into a 14x14 bitmap as the resulting array would contain variations of blue, green and gray pixels. This would still be hard to process as it would require a range of pixel colors to be interpreted in order to know that a current position is free or an obstacle.

Instead, the next step in our simplification process is to filter the image for the blue blocks using the RGB Filter module. We then remove small blobs as they are mainly due to noise and are not part of the blue blocks.

Blue Filtered

As we can see this certainly helps to isolate the blue blocks. We then scale the image down using the Scale module to a 16x16 image. For viewing purposes the following is that image scaled back up to a larger size so that we can see each individual pixel.

Scaled

We can see that the blocks are better defined (in terms of accuracy) but we still need a blocked/unblocked signal instead of a varying gray value. We can do this by thresholding the image. We also crop the image as the border pixels are not needed. This creates a 14x14 sized image.

Final

With the final threshold we can see the blocks nicely defined within a grid. This image can now be accessed as a 14x14 bitmap image which will have an RGB value of blue (0,0,255) in those positions where a blue Lego block occurs otherwise each pixel will be zero (black color).

If you notice closely you will see a single blue block in the lower part of the image being represented as two blocks instead of one. This is due to a single block being offset outside of the 2x2 grid. This breaks our 2x2 alignment requirement but is included to illustrate what happens when this requirement is not met.

Bad block

Now that we have the idealized grid model let's find out where the ball is!

<<Prev 1 2 3 4 5 6 Next>>

© 2005 - 2010 RoboRealm. All Rights Reserved. | Contact | Glossary | Privacy | Disclaimer | Link to Us | Resources | Site Map