Hello arduino folks! I need some guidance of how to build my algorithm for my robot. I want my robot to get as far from its starting point as possible. The robot is fairly simple, I have an arduino which controlls the two motors a servo(180 degrees) a maxsonar distance sensor mounted on the servo
So far I have though of an algorithm which looks something like this
- Read the distance from the Sonar at every degree and store them in an array.
- Using trigonometric formulas calculate every coordinates distance from origo.(which will be the same place as the robots position in the first cycle)
- Chose the coordinate with the greatest value from origo.
- Turn robot so its facing in that direction
- Drive until the distance sensor gives a reading of 30 cm.
What do you think of that algorithm? It's very easy to write the algorithm like that but when coding it becomes a lot more difficult. In that algorithm for example my robot has to keep track of its own position relative to origo which might be difficult cause i dont have any encoders on my robots wheels. I might also buy a compass sensor so i at least can get the robots exact degree. Thank you very much!