autonomous car algorithm help

Hello everyone,

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!

Thanks
Gil

I will be happy to get some ideas for possible algorithms to solve the problem!

What is the problem? Reading the sensors? Changing the speed of the motors?

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

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?

hi,
the front arm can help me to know when the fence from the front is near and i got to start turnning..

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.

How do you steer?

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

I steer by driving faster with the wheels of the other side i wang to steer.

The greater the speed differential, the smaller the radius. Turn the inside wheels in reverse to make it even smaller.

Hi,
How big is this car?

Can you post a picture of it please.

Have you done any code for the car at all?

What is your electronics, programming, arduino, hardware experience?
Is this a school/college/university project?

Tom..... :slight_smile:

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)

the problem is how to write the code that will make the car drive and keep 30cm

The original post said 25cm.
Which is it?