I'm planning a small autonomous car project which supposed to drive in boarded area and keep 25cm distance from the fence that used to be the board of the area.(the fence can be any shape and not just circle).
I'm using arduino mega 2560, the car has 4 wheels controled by using the PWM option.
I though about using 2 ultrasonic sensors, the first one in the front side and the second at the left side of the car (the car will drive clockwise and "keep the fence").
I will be happy to get some ideas for possible algorithms to solve the problem!
the problem is how to write the code that will make the car drive and keep 30cm from the fence no matter what shape the fence is (with two ultrasonic sensors one at the front and the other at the side of the car)
Gilr:
the problem is how to write the code that will make the car drive and keep 30cm from the fence no matter what shape the fence is (with two ultrasonic sensors one at the front and the other at the side of the car)
thanks
How would YOU walk along the fence, keeping an arms length away, having one arm out to the side and one sticking out front? How is the arm sticking out front going to help?
The algorithm for following a fence is pretty simple. Assuming the fence is on the left,
Check distance to fence.
If you are closer to the fence than desired, steer right.
If you are farther from the fence than desired, steer left.
Check for obstacles and take appropriate action.
Go back to check distance.
the car has 4 wheels controled by using the PWM option.
Thank you! I steer by driving faster with the wheels of the other side i wang to steer.
Now i have problem with the turnning radius which is like 1.5m.
Any help to improve it?
Thanks
Have you played with the sensors and seen how accurate/inaccurate/noisy the values they return
are? You will probably have to code round the imperfections in the sensor data (a lot of robotics
is like this - dealing with imperfect data)