Hello everybody,
I am new with programming and arduino, so thats why my questions are maybe so stupid..:) I
am trying to write code (my version of adaptive mapping) for this robot platform - http://i40.tinypic.com/tz9kl.jpg
It has two motors and two wheel encoders. Now what about code:
There are three main parts of code:
- Robot goes, scans area where he can go and where no, and stores this information(map) to SD.
- When the area is scanned and the map is complete. We can give a command to robot - go there or here(go to the target).
- If on the way to target the old way (that is stored to SD) not more actual, because there is something on the way (chair or something else). He need to change the map on SD and write that this way is no more possible. Calculate a new way to target and go there.
The first part of the code I think I know how to write. Map would look like on the picture, should be discretized into square units exactly the same size as the robot. The robot can turn only 90 degrees.
And I will store the the information to the map like this 500500, the first three digits are X and the second 500 is Y. The docking station will be 500500(X=0,Y=0)
If x = 12, y = 74 it will be 512574
If x = -50, y = -20 it will be 450480
And now comes the question:
For example
500500 – Robot is here(docking station).
497502 - Target.
So the code must look something like this
read current position;
read target position;
currentpostion = 500500;
target position = 497502;
if(current position != target position)
and here comes the clever algorithm.. that should tell go to the 500501
if (500501 == free(read PING)) {
go to new postion = 500501;
}
else
write to map(SD) 500501 is not free;
clever algorithm();
So maybe can give me a tip how should look like this clever algorithm that calculate the way to target?
Why Iam I using 500500 and not x=0,y=0, because for me(newbie) this way seem more easy. So the result should be something like this http://www.youtube.com/watch?v=N7zDiSPa3_E P.S. Why I don
t use the code from clever guy thats on the video? Because the code is to difficult for me and I can
t understand it. So it is better to write my own then I will able to change or to configure it.
Thank you very much!