help with Solving a maze using BITMAP :/

hi,
i have this project where i must read a bitmap image of a maze (top view) from sd card , identify the exit , entrance , the location of a box and then navigate accordingly . The basic problem im facing is with reading the map. Is converting the map into a byte array the only option ? (since ill not be given a program to convert bitmap into byte array i must plug in the card and start the robot). Any help would be highly appreciated ... im completely lost :smiley:

So you're getting a standard windows bitmap? BMP file format - Wikipedia

Yeah... You'll need to get the offset data from the header, read in the pixel array and process it to get a map in a sensible format, and then solve it... then you get to start navigating it.

How many pixels in the bitmap, and what colour depth?
What Arduino are you using? Will there be enough SRAM?

...R

DrAzzy:
So you're getting a standard windows bitmap? BMP file format - Wikipedia

Yeah... You'll need to get the offset data from the header, read in the pixel array and process it to get a map in a sensible format, and then solve it... then you get to start navigating it.

yes id be given a monochromatic bitmap image. But my question is how do i convert the map into an array without using any convertor ( like within arduino itself) , since id be given an sd card wih the map inside and i'd be having no clue about the map .

Robin2:
How many pixels in the bitmap, and what colour depth?
What Arduino are you using? Will there be enough SRAM?

...R

its a monochromatic image of the map with obstacles in black and the box ( where i must first goto before the exit) marked as a cross. Id be using arduino mega . And the maze is small (5mx5m)

How large is the bitmap file? Do you have an example? What kind of Arduino are you using?

wildbill:
How large is the bitmap file? Do you have an example? What kind of Arduino are you using?

they havent provided the exact information about the size of the map , just that itll be a scaled version of it. Arduino Mega is what ill be using :slight_smile:

asimarif11:
they havent provided the exact information about the size of the map ,

It is absolutely essential that you know the maximum size of the bitmap. AND note that this has little to do with the size of the maze. Don't confuse "map" and "bitmap". You need to know how many bytes of data are needed to store the image.

Too big and you have no project. And on a Mega "too big" won't be very big.

You also need to know how many bytes there are per pixel. Colour normally uses 3 bytes - one each for red, green and blue. But you could just as easily store a greyscale image using 3 bytes per pixel. Ideally you need an image format that just uses 1 byte per pixel. Even better, of course, would be 1 bit per pixel.

...R

its a monochrome image so it must be 1 bpp , right ?

and about the size of map , i actually meant bitmap :stuck_out_tongue: sorry for the confusion but its not too big , its quite small actually so size wont be a problem ; i just want a direction of what to do if everything is just right . Like suppose I have the right size of the bmp image , what they need me to do is put the sc card containing the map in the sd card shield interfaced with the arduino , put the robot at the starting position and let it go through without any control . So what must i do ? what algorithms must i use ? i hope you've understood what im trying to say

cheers and thanks in advance :slight_smile:

asimarif11:
its a monochrome image so it must be 1 bpp , right ?

It might be, but it is not required to be.

As to figuring out code to find your way around the map, How would you (with your eyes) find the entrance? How would you identify where the target is?

The usual (laborious) way to traverse a maze is to follow it with the left hand (say) always touching the wall on the left.

If you want to make a "map" of all possible routes through the maze and pick the shortest route, that's another matter and I suspect there is plenty of literature on the subject. Whether it can be done by an Arduino rather than a PC is another matter. When you use Google maps to show you a route from A to B it does what you want. But they probably had a few PhDs to figure it out.

I recently wrote a PC program to derive paths for a router from a black and white bitmap - but that is somewhat different from a maze because it is required to traverse all the black areas. The concept is brutally simple. Go forward. If you can't go forward, turn right. Keep repeating the above until you can't move. For the maze you may want to allow it to retrace its steps.

...R

Maybe look at A* search algorithm?

Moderator edit: tags corrected

Robin2:
It might be, but it is not required to be.

As to figuring out code to find your way around the map, How would you (with your eyes) find the entrance? How would you identify where the target is?

The usual (laborious) way to traverse a maze is to follow it with the left hand (say) always touching the wall on the left.

If you want to make a "map" of all possible routes through the maze and pick the shortest route, that's another matter and I suspect there is plenty of literature on the subject. Whether it can be done by an Arduino rather than a PC is another matter. When you use Google maps to show you a route from A to B it does what you want. But they probably had a few PhDs to figure it out.

I recently wrote a PC program to derive paths for a router from a black and white bitmap - but that is somewhat different from a maze because it is required to traverse all the black areas. The concept is brutally simple. Go forward. If you can't go forward, turn right. Keep repeating the above until you can't move. For the maze you may want to allow it to retrace its steps.

...R

i have attached the images of the map ( the obstacles and the points where the yellow and green boxes are will vary and there comes a need for the map ) . Ofcourse you could use a wall following or some other algorithm , but the point is reading the map and reach the boxes , then reach the exit utilizing least possible time (its a competetion afterall :smiley: ).

I have also attached the sample bitmap images of this map (not the actual bitmap but how they will look ) .
I dont need to map anything ; im given a map , what i need to know is if there is a way to convert the bmp into array without the use of a pc (or within arduino itself) ; and if not , then is there any other way for an arduino to read a map and reach my goals . I hope im able to explain everything :slight_smile:

Have you looked up the specification for a BMP file?
I think it is fairly simple.
Explore the file using a PC program until you are familiar with it. Then you should be able to figure out an Arduino version.
Maybe you could read from the BMP file directly without converting it.

...R

Robin2:
read from the BMP file directly without converting it.

...R

if there is way to do it , then clearly i do not know it . Im tired of searching about it :confused:

and what do you mean by "you should be able to figure out an arduino version "

Here is the structure of a bmp-file
You need to know the bits per pixel etc. to read the file correctly. So you have to get hold of an example of an actual BMP file that will be used and study it in an hex-editor (eg. notepad++).

What do you know about the course? It looks from the files you've given that it's of a very fixed format where the size is constant, perimeter walls are of constant thickness, the obstacles & goals can vary and the entrance and exits each have two possible positions.

If that's correct, then reading the map is very much simpler than it first appeared. You could parse it a line at a time, or come to that a bit at a time and knowing the shape of the map and what must appear on it, build a 5 by 10 cell map in memory that represents the maze.

Indeed, I'd suggest that reading the map is the easy part; building a robot to navigate it looks like a rather more significant task.

asimarif11:
if there is way to do it , then clearly i do not know it . Im tired of searching about it :confused:

Why do I get the impression you want us to do all the work?

You haven't given us any indication of what you already know about BMP files.
The image that @JAndersM kindly posted seems to come from the Wikipedia article. Have you read that? If not why not?
That article was the top of the list when I Googled "bmp file specification"

Have you taken a simple BMP file and explored its contents with a PC program - perhaps using Python?
That way you can understand what the different sections of the file contain and how they relate to each other?

Do you have any example BMP files of the actual type that you will be given?

If you have actually done all this reading and there is something you don't understand then tell us more specifically what it is.

...R

Robin2:
Why do I get the impression you want us to do all the work?

You haven't given us any indication of what you already know about BMP files.
The image that @JAndersM kindly posted seems to come from the Wikipedia article. Have you read that? If not why not?
That article was the top of the list when I Googled "bmp file specification"

Have you taken a simple BMP file and explored its contents with a PC program - perhaps using Python?
That way you can understand what the different sections of the file contain and how they relate to each other?

P.S im just a high school guy who dosent know much about stuff .I just need a direction , im sorry if im too dumb :expressionless:
Do you have any example BMP files of the actual type that you will be given?

If you have actually done all this reading and there is something you don't understand then tell us more specifically what it is.

...R

sir , i know only the stuff related to a monochrome bmp , i didnt know i needed to study bmp and i still dont understand why . the first thing i did was used notepad++ to edit a bmp file . I have converted bmp into array using lcd assistant , doc factory etc . I donot have any exmaple , the limited information they have provided i have shared it with you . And yes i have done lots of reading before coming here i just do not know if i was going in the right direction . I am like a complete noob so pardon me :slight_smile:
and yes i have read the wikipedia article .

wildbill:
What do you know about the course? It looks from the files you've given that it's of a very fixed format where the size is constant, perimeter walls are of constant thickness, the obstacles & goals can vary and the entrance and exits each have two possible positions.

If that's correct, then reading the map is very much simpler than it first appeared. You could parse it a line at a time, or come to that a bit at a time and knowing the shape of the map and what must appear on it, build a 5 by 10 cell map in memory that represents the maze.

Indeed, I'd suggest that reading the map is the easy part; building a robot to navigate it looks like a rather more significant task.

yes you are right .. the size is constant the thickness perimeter etc , and about creating a cell and all , sir how possibly can i do that ? how do i go from a bmp image to an array ? only this confuses me
P.S im just a high school guy who dosent know much about stuff .I just need a direction ; im sorry if im too dumb :expressionless:

asimarif11:
i didnt know i needed to study bmp and i still dont understand why . the first thing i did was used notepad++ to edit a bmp file .

You will be given a BMP file. You need to access the data in that file so you can use it to guide your robot. That means you have to know how the data is stored in a BMP file so that you can write a program to get at the data.

I did not know it would be possible to make sense of a BMP file with notepad++.

At the very least your Arduino program will have to be able to find the data in the file that tells how many rows and colums there are and it will have to be able to find where the picture data starts.

That's why I suggested putting together a simple PC program that allows you to explore the contents of BMP files - in other words to learn how to write a program to find stuff in the file. I reckon it is much easier to do that learning on a PC.

I can't learn this stuff for you. And until you start studying it you don't have the sort of specific questions that allow me to help.

And, please, there is no need to refer to me as "sir". "Robin" is fine, or @Robin2 if you prefer more formality.

...R

Robin2:
You will be given a BMP file. You need to access the data in that file so you can use it to guide your robot. That means you have to know how the data is stored in a BMP file so that you can write a program to get at the data.

I did not know it would be possible to make sense of a BMP file with notepad++.

At the very least your Arduino program will have to be able to find the data in the file that tells how many rows and colums there are and it will have to be able to find where the picture data starts.

That's why I suggested putting together a simple PC program that allows you to explore the contents of BMP files - in other words to learn how to write a program to find stuff in the file. I reckon it is much easier to do that learning on a PC.

I can't learn this stuff for you. And until you start studying it you don't have the sort of specific questions that allow me to help.

And, please, there is no need to refer to me as "sir". "Robin" is fine, or @Robin2 if you prefer more formality.

...R

thanks alot , i guess now i know what i have to do :slight_smile: ill do that and then get back to you

and about calling you " sir " , im in forces cant help it :smiley:

It seems to me that you need to get some more information about the contest rules. Or at least provide it here if you already have it. Perhaps I've missed it, but I don't see anything confirming that the file you're given actually is a bmp file - that seems to be an assumption made at the start of the thread.

You really need to get hold of one (actually several) of the real files to get an idea how to process it. Both to verify that you know what it is and for testing.

What's the story with the red & blue zones? The example shows them as mirror images - is that always the case? Do you get to tell the robot which arena it's being put in?

If there are strong restrictions on what can go where and how big things can be, you can probably figure out the maze from very few pixels in the bitmap but you need to know what those restrictions are.

For a high school contest using an arduino, I'd expect that reading the map isn't intended to be a terribly difficult thing to do so perhaps try to find out what the referees are thinking.