Society of Robots - Robot Forum

Mechanics and Construction => Mechanics and Construction => Topic started by: javafiend on March 31, 2008, 11:30:20 AM

Title: driving straight
Post by: javafiend on March 31, 2008, 11:30:20 AM
Has anyone else had problems with their $50 robot, or any differential drive robot for that matter, drifting to one side or the other when it should be going straight?  Mine has been doing it from the beginning, with sensor code commented out, and seems fine structurally.

How did you fix it?

Thanks!
Title: Re: driving straight
Post by: bukowski on March 31, 2008, 11:44:29 AM
Mine ran fine... perfectly straight from what I could tell.
Is it consistantly turning in the same direction? (eg always making a slow left turn) if so, you could adjust the speed in the code to match up the wheel speed, or adjust one of your wheel's OD if you want to jerry rig it.
Title: Re: driving straight
Post by: AndrewM on March 31, 2008, 11:54:44 AM
Assuming your left and right wheels are the same size, you just need to adjust the pwm sent to one servo or the other.  Two servos are often slightly different in their application of a pwm signal as you are now experiencing.  If the robot is turning consistently to the right, you need to reduce the pwm signal sent to the left servo slightly; vice versa for if it is turning to the left.  It is basically a trial and error kind of thing.
Title: Re: driving straight
Post by: superchiku on March 31, 2008, 01:34:12 PM
andrew is right sometimes u have to adjust the pwm values to make the bot go straight, so try doing that it will work out
Title: Re: driving straight
Post by: michaelsane on March 31, 2008, 03:58:33 PM
In theory the robot is not going to go perfectly strait even if you do tweak your pwm values, because there is no feedback.  If you want to use an optical encoder on the wheels then you could send out the pwm signals, and stop after each axel makes x amount of revolutions.  If you are interested in optical encoders US Digital makes some really nice ones (and affordable).