how to drive robot straight...

i m amateur to the ARDUINO UNO board.
currently working on project named "path follower robot" in which i have to give path virtually ..
my robot is going on path but it is not going perfect straight and that is why it is distracting from main path.
i m using dc motor with encoder posting link below for this

for example
i have to drive robot 1st straight 10 feet then 90 degree right turn and again 3 feet
how to do programming for dis

help me to go through this prob.
thankss

i m using 2 dc motor of same kind ...

how to do programming for dis

Dis?
Differential (?) Steering?

To go straight, you need to ensure both wheels have the same circumference, and that both encoders record the same number of turns.
Have you done this?

nope

dimensions of both wheel are identical ....

You have two identical wheels and do the same things to both, but the path isn't straight? Welcome to the real world!

The frictional condition on the ground varies between the wheels so they will never go straight even with encoders saying they've spun the same amounts. When you started your motors, did you apply full power right on, or did you ramp up power from low to high? Same goes with stopping. Also you should slow down overall speed to make sure you always have traction. If you can do the above, you will get straighter. To get it really straight, you need external feedback on the straightness of the path or smart grid in space to tell you where you are at and which way you head.

Ever seen GPS-controlled combines working fields? Me not, but I know they go very straight :wink:
Ever driven a car along a straight stretch of highway? Me, a lot, and I know I always need to keep my hands on the steering wheel and eyes on the road (follow straight lines).

Those were examples of external feedback (road lines) and smart grid (GPS). Many robots can follow lines drawn on the floor, FYI.

divnext:
nope

If you want both wheels to travel the same distance then you need to use the encoders to determine how far each wheel has traveled and control the relative speeds to keep the distances equal.

Even with encoders, I bet the minute difference in friction when the OP starts motor at full speed may just turn the robot a tiny bit, which is enough to make it travel in a kind-of-straight line but off from forward.

It would depend how much torque the motors make relative to the available friction. The feedback needs to be implemented first - if there's still a problem then add in acceleration control to keep wheelslip acceptably low.

Making a differential robot drive straight is not easy.

I've been building my own navbot for the last few months. Only now is it able to navigate accurately using wheel encoders and dead reckoning.

I first started off making a wall following robot that uses encoder to make it drive straight: WallBot | solderspot

I then started on the NavBot proper: navbot | solderspot

It ends up being very involved.

How much time and effort do you plan to put into your project? How accurate does it need to be?

liuzengqiang:
Even with encoders, I bet the minute difference in friction when the OP starts motor at full speed may just turn the robot a tiny bit, which is enough to make it travel in a kind-of-straight line but off from forward.

I totally agree. So, that means pursuit of straight line movement in indoor environment with a two-wheeled rover is non trivial and is futile without:

  1. Either using floor strips as in warehouses
  2. or using a single wheel with a stepper at nose to control direction

What are the quick alternatives that can be used without requiring extensive setup and crisscrossing the house with lasers / ribbons?

Is compass an option. But it can get distracted by the metallic and magnetic objects...
What about a camera aimed at the roof that can memorize roof map?
Or using ultrasonic sensors?