## Re: [SeattleRobotics] How to make a robot go straight?

Expand Messages
• ... No mechanical device is exact. Therefore, your two motors won t ever turn at the same speed or give the same torque when given the same amount of power.
Message 1 of 12 , May 31, 2008
On Sun, 1 Jun 2008, Chris wrote:

> Hi,
>
> As a newbie, I am start learn and play using Mindstorms NXT, and
> construct the first robot, simple mobile robot with two wheels
> attached to two motors. But, I found, the robot can't go straight.
>
> Any hints or tips, how to make it go straight and can turn 90 degrees
> precisely?

No mechanical device is exact. Therefore, your two motors won't ever turn
at the same speed or give the same torque when given the same amount of
power.

You need a mathematical algorithm called PID
(proportional-integral-deriviative) and a rotary encoder on each motor.
This algorithm will adjust the power to each motor until your robot is
moving how you want it. You can only go at 1/2 to 3/4 of their fastest

Note that it also has limited precision and you won't get a perfectly
straight line this way either.

In fact, the *only* way to have your robot move in a straight line is for
it to use its sensors to follow a feature that is straight.

As for turning 90 degrees perfectly, PID will help but you will never get
a perfect 90 degree turn. You will have to use your robot's sensors to
line up with environmental features like walls as you go.

See http://www.seattlerobotics.org/encoder/200108/using_a_pid.html
• The NXT motors include rotary encoders, so the NXT does a pretty good job of going straight using the built-in firmware. Also, the encoders can be read to
Message 2 of 12 , Jun 1, 2008
The NXT motors include rotary encoders, so the NXT does a pretty good job of
going straight using the built-in firmware. Also, the encoders can be read
to determine when you have made the desired turn angle (obviously the values
depend on the robot configuration). So, NXT built robots, with proper
programming, can dead-reckon over short distances. As noted below, getting
high accuracy requires using a sensor to follow some feature (e.g., light
sensor following black strip of tape on a white surface).

_____

From: SeattleRobotics@yahoogroups.com
[mailto:SeattleRobotics@yahoogroups.com] On Behalf Of Triffid Hunter
Sent: Saturday, May 31, 2008 8:44 PM
To: SeattleRobotics@yahoogroups.com
Subject: Re: [SeattleRobotics] How to make a robot go straight?

On Sun, 1 Jun 2008, Chris wrote:

> Hi,
>
> As a newbie, I am start learn and play using Mindstorms NXT, and
> construct the first robot, simple mobile robot with two wheels
> attached to two motors. But, I found, the robot can't go straight.
>
> Any hints or tips, how to make it go straight and can turn 90 degrees
> precisely?

No mechanical device is exact. Therefore, your two motors won't ever turn
at the same speed or give the same torque when given the same amount of
power.

You need a mathematical algorithm called PID
(proportional-integral-deriviative) and a rotary encoder on each motor.
This algorithm will adjust the power to each motor until your robot is
moving how you want it. You can only go at 1/2 to 3/4 of their fastest

Note that it also has limited precision and you won't get a perfectly
straight line this way either.

In fact, the *only* way to have your robot move in a straight line is for
it to use its sensors to follow a feature that is straight.

As for turning 90 degrees perfectly, PID will help but you will never get
a perfect 90 degree turn. You will have to use your robot's sensors to
line up with environmental features like walls as you go.

See http://www.seattler
<http://www.seattlerobotics.org/encoder/200108/using_a_pid.html>
obotics.org/encoder/200108/using_a_pid.html

[Non-text portions of this message have been removed]
• I have tried some and found the differences between two motors (with the same power), 1 to 4 degrees, after run 1 meter. Any clues how to correct this? Fyi,
Message 3 of 12 , Jun 1, 2008
I have tried some and found the differences between two motors (with the
same power), 1 to 4 degrees, after run 1 meter. Any clues how to correct
this? Fyi, the robot has to run 2.5 meters straight on white floor (no
line).

Best Regards,

--chris

> The NXT motors include rotary encoders, so the NXT does a pretty good job
> of
> going straight using the built-in firmware. Also, the encoders can be
> to determine when you have made the desired turn angle (obviously the
> values
> depend on the robot configuration). So, NXT built robots, with proper
> programming, can dead-reckon over short distances. As noted below,
> getting
> high accuracy requires using a sensor to follow some feature (e.g., light
> sensor following black strip of tape on a white surface).
>
>
>
> _____
>
> From: SeattleRobotics@yahoogroups.com
> [mailto:SeattleRobotics@yahoogroups.com] On Behalf Of Triffid Hunter
> Sent: Saturday, May 31, 2008 8:44 PM
> To: SeattleRobotics@yahoogroups.com
> Subject: Re: [SeattleRobotics] How to make a robot go straight?
>
>
>
> On Sun, 1 Jun 2008, Chris wrote:
>
>> Hi,
>>
>> As a newbie, I am start learn and play using Mindstorms NXT, and
>> construct the first robot, simple mobile robot with two wheels
>> attached to two motors. But, I found, the robot can't go straight.
>>
>> Any hints or tips, how to make it go straight and can turn 90 degrees
>> precisely?
>
> No mechanical device is exact. Therefore, your two motors won't ever turn
> at the same speed or give the same torque when given the same amount of
> power.
>
> You need a mathematical algorithm called PID
> (proportional-integral-deriviative) and a rotary encoder on each motor.
> This algorithm will adjust the power to each motor until your robot is
> moving how you want it. You can only go at 1/2 to 3/4 of their fastest
>
> Note that it also has limited precision and you won't get a perfectly
> straight line this way either.
>
> In fact, the *only* way to have your robot move in a straight line is for
> it to use its sensors to follow a feature that is straight.
>
> As for turning 90 degrees perfectly, PID will help but you will never get
> a perfect 90 degree turn. You will have to use your robot's sensors to
> line up with environmental features like walls as you go.
>
> See http://www.seattler
> <http://www.seattlerobotics.org/encoder/200108/using_a_pid.html>
> obotics.org/encoder/200108/using_a_pid.html
• Chris said: Sunday, June 01, 2008 9:52 AM ... 1 to 4 degrees in a meter sounds like pretty good steering to me for a Lego. How tight do you need to have it
Message 4 of 12 , Jun 1, 2008
Chris said: Sunday, June 01, 2008 9:52 AM
> I have tried some and found the differences between two
> motors (with the same power), 1 to 4 degrees, after run 1
> meter. Any clues how to correct this? Fyi, the robot has to
> run 2.5 meters straight on white floor (no line).

1 to 4 degrees in a meter sounds like pretty good steering to me
for a Lego.

How tight do you need to have it corrected to?

What are you doing now to get it that straight? Have you done

Do you know what a gyro is?

Randy
• Hope 1 degree difference for 2.5 meter distance :) Someone tell me, Move Block in NXT-G has a PID control (CMIIW). I am using this block to make it straight .
Message 5 of 12 , Jun 1, 2008
Hope 1 degree difference for 2.5 meter distance :)

Someone tell me, Move Block in NXT-G has a PID control (CMIIW). I am using
this block to make it "straight".

The second option still being considered, using dual differential. So, only
one motor drive forward and reverse.

Sorry, I have to explore about odometry and gyro.

Best Regards,

--chris

----- Original Message -----
From: "Randy M. Dumse" <rmd@...>
To: <SeattleRobotics@yahoogroups.com>
Sent: Monday, June 02, 2008 8:33 AM
Subject: RE: [SeattleRobotics] How to make a robot go straight?

Chris said: Sunday, June 01, 2008 9:52 AM
> I have tried some and found the differences between two
> motors (with the same power), 1 to 4 degrees, after run 1
> meter. Any clues how to correct this? Fyi, the robot has to
> run 2.5 meters straight on white floor (no line).

1 to 4 degrees in a meter sounds like pretty good steering to me
for a Lego.

How tight do you need to have it corrected to?

What are you doing now to get it that straight? Have you done

Do you know what a gyro is?

Randy
• Chris said: Sunday, June 01, 2008 10:32 PM ... So you re looking for 4cm deviation in 2500cm travel. That s very tight. I don t think you could put a plastic
Message 6 of 12 , Jun 1, 2008
Chris said: Sunday, June 01, 2008 10:32 PM
> Hope 1 degree difference for 2.5 meter distance :)

So you're looking for 4cm deviation in 2500cm travel. That's
very tight.

I don't think you could put a plastic car with two fixed axles
and achieve that. I don't think you can aim the car by sight for
much more than a few degrees accuracy to begin with. It might be
fun to find out.

Try this. Put a laser pointer on top of the robot pointing
straight ahead at a wall 2.5m ahead. Now twist the robot left
and right just enough that the gear train tightens up the
backlash without turning the motors. Measure how far of center
the laser dot is.

Now, turn off the laser. Place the robot by hand pointing where
you want it to go. Without moving the car, turn on the laser.
Now measure how far off the laser dot is from the point you were
aiming at.

One of the tricks of getting a good aim is to push the wheels
all the way forward (or backwards) to take out the backlash, and
even drag it a little ways, just enough the motors don't turn,
but the backlash is taken out of the drive train.

Randy
• One thing you might try although I don t know if it would buy you anything would be to disconnect the motors from the internal drivers and then take each motor
Message 7 of 12 , Jun 2, 2008
One thing you might try although I don't know if it would buy you anything would be to
disconnect the motors from the internal drivers and then take each motor and apply
different voltages/pwm values to it.

Then measure the speed of each motor at those voltages. Plot the values for each of
the motors. From that you can develop an equation for each motor based on the slope
of the line for each motor. Then you can use the equations to develop an unique input to
each motor for each speed that you would like to go.

If it's non-linear, mathcad (& I assume matlab) has the capability to generate an
equation for you. This can also be done manually, but you might have to get out your
college math texts and refresh for a while.

If you use the encoders to measure, you could also write a diagnostic that would
calculate this for you.

> Hi,
>
> As a newbie, I am start learn and play using Mindstorms NXT, and
> construct the first robot, simple mobile robot with two wheels
> attached to two motors. But, I found, the robot can't go straight.
>
> Any hints or tips, how to make it go straight and can turn 90 degrees
> precisely?
>
>
> Best Regards,
>
> --chris
>
>
• I ve built a dual differential drive system in Legos. While it does provide a straight path, there is so much play in the gears that the initial pointing
Message 8 of 12 , Jun 2, 2008
I've built a dual differential drive system in Legos. While it does provide
a straight path, there is so much play in the gears that the initial
pointing position isn't very accurate.

_____

From: SeattleRobotics@yahoogroups.com
[mailto:SeattleRobotics@yahoogroups.com] On Behalf Of Chris
Sent: Sunday, June 01, 2008 8:32 PM
To: SeattleRobotics@yahoogroups.com
Subject: Re: [SeattleRobotics] How to make a robot go straight?

Hope 1 degree difference for 2.5 meter distance :)

Someone tell me, Move Block in NXT-G has a PID control (CMIIW). I am using
this block to make it "straight".

The second option still being considered, using dual differential. So, only
one motor drive forward and reverse.

Sorry, I have to explore about odometry and gyro.

Best Regards,

--chris

----- Original Message -----
From: "Randy M. Dumse" <rmd@newmicros. <mailto:rmd%40newmicros.com> com>
To: <SeattleRobotics@ <mailto:SeattleRobotics%40yahoogroups.com>
yahoogroups.com>
Sent: Monday, June 02, 2008 8:33 AM
Subject: RE: [SeattleRobotics] How to make a robot go straight?

Chris said: Sunday, June 01, 2008 9:52 AM
> I have tried some and found the differences between two
> motors (with the same power), 1 to 4 degrees, after run 1
> meter. Any clues how to correct this? Fyi, the robot has to
> run 2.5 meters straight on white floor (no line).

1 to 4 degrees in a meter sounds like pretty good steering to me
for a Lego.

How tight do you need to have it corrected to?

What are you doing now to get it that straight? Have you done

Do you know what a gyro is?

Randy

[Non-text portions of this message have been removed]
• Thanks for all replies. My conclusion, so far, there is no tips (using Lego) to get the accuracy level expected. I think, it is easier to build the simple
Message 9 of 12 , Jun 2, 2008
Thanks for all replies. My conclusion, so far, there is no tips (using
Lego) to get the accuracy level expected.

I think, it is easier to build the simple differential drive (each wheel
attached to one motor) than dual differential drive. So, I will try to
make two motors synchronize first, and then try to "go straight" :)

Best Regards,

--chris

Mark Kenworthy wrote:
>
>
> I've built a dual differential drive system in Legos. While it does provide
> a straight path, there is so much play in the gears that the initial
> pointing position isn't very accurate.
>
> _____
>
> From: SeattleRobotics@yahoogroups.com
> <mailto:SeattleRobotics%40yahoogroups.com>
> [mailto:SeattleRobotics@yahoogroups.com
> <mailto:SeattleRobotics%40yahoogroups.com>] On Behalf Of Chris
> Sent: Sunday, June 01, 2008 8:32 PM
> To: SeattleRobotics@yahoogroups.com
> <mailto:SeattleRobotics%40yahoogroups.com>
> Subject: Re: [SeattleRobotics] How to make a robot go straight?
>
> Hope 1 degree difference for 2.5 meter distance :)
>
> Someone tell me, Move Block in NXT-G has a PID control (CMIIW). I am using
> this block to make it "straight".
>
> The second option still being considered, using dual differential. So, only
> one motor drive forward and reverse.
>
> Sorry, I have to explore about odometry and gyro.
>
> Best Regards,
>
> --chris
>
> ----- Original Message -----
> From: "Randy M. Dumse" <rmd@newmicros. <mailto:rmd%40newmicros.com> com>
> To: <SeattleRobotics@ <mailto:SeattleRobotics%40yahoogroups.com>
> yahoogroups.com>
> Sent: Monday, June 02, 2008 8:33 AM
> Subject: RE: [SeattleRobotics] How to make a robot go straight?
>
> Chris said: Sunday, June 01, 2008 9:52 AM
> > I have tried some and found the differences between two
> > motors (with the same power), 1 to 4 degrees, after run 1
> > meter. Any clues how to correct this? Fyi, the robot has to
> > run 2.5 meters straight on white floor (no line).
>
> 1 to 4 degrees in a meter sounds like pretty good steering to me
> for a Lego.
>
> How tight do you need to have it corrected to?
>
> What are you doing now to get it that straight? Have you done
> the PID and Odometry already?
>
> Do you know what a gyro is?
>
> Randy
>
• Chris, In addition to the practical suggestions you ve received here (I especially like Randy s suggestion about turning the wheels to engage the gear teeth
Message 10 of 12 , Jun 3, 2008
Chris,

especially like Randy's suggestion about turning the wheels to engage
the gear teeth and take up the backlash... I bet he's used a milling
machine more than once) I would like to add two things I've noticed
in playing with Legos... First off, if there is a way to make your
frame as rigid as possible so that the unit doesn't wobble, it
helps. Of course, you don't want to add so many reinforcements that
you introduce problems by making the thing too heavy. Second, angle
is computed as the difference in wheel rotation divided by distance
between wheels, so if you can increase the spacing between wheels you
can reduce the effect of error in rotational positioning somewhat.
Of course, you have to be careful not to introduce mechanical
problems by making your vehicle too wide.

Gary

--- In SeattleRobotics@yahoogroups.com, Chris <nextsys@...> wrote:
>
> Thanks for all replies. My conclusion, so far, there is no tips
(using
> Lego) to get the accuracy level expected.
>
> I think, it is easier to build the simple differential drive (each
wheel
> attached to one motor) than dual differential drive. So, I will try
to
> make two motors synchronize first, and then try to "go straight" :)
>
> Best Regards,
>
> --chris
>
>
> Mark Kenworthy wrote:
> >
> >
> > I've built a dual differential drive system in Legos. While it
does provide
> > a straight path, there is so much play in the gears that the
initial
> > pointing position isn't very accurate.
> >
> > _____
> >
> > From: SeattleRobotics@yahoogroups.com
> > <mailto:SeattleRobotics%40yahoogroups.com>
> > [mailto:SeattleRobotics@yahoogroups.com
> > <mailto:SeattleRobotics%40yahoogroups.com>] On Behalf Of Chris
> > Sent: Sunday, June 01, 2008 8:32 PM
> > To: SeattleRobotics@yahoogroups.com
> > <mailto:SeattleRobotics%40yahoogroups.com>
> > Subject: Re: [SeattleRobotics] How to make a robot go straight?
> >
> > Hope 1 degree difference for 2.5 meter distance :)
> >
> > Someone tell me, Move Block in NXT-G has a PID control (CMIIW). I
am using
> > this block to make it "straight".
> >
> > The second option still being considered, using dual
differential. So, only
> > one motor drive forward and reverse.
> >
> > Sorry, I have to explore about odometry and gyro.
> >
> > Best Regards,
> >
> > --chris
> >
> > ----- Original Message -----
> > From: "Randy M. Dumse" <rmd@newmicros. <mailto:rmd%
40newmicros.com> com>
> > To: <SeattleRobotics@ <mailto:SeattleRobotics%40yahoogroups.com>
> > yahoogroups.com>
> > Sent: Monday, June 02, 2008 8:33 AM
> > Subject: RE: [SeattleRobotics] How to make a robot go straight?
> >
> > Chris said: Sunday, June 01, 2008 9:52 AM
> > > I have tried some and found the differences between two
> > > motors (with the same power), 1 to 4 degrees, after run 1
> > > meter. Any clues how to correct this? Fyi, the robot has to
> > > run 2.5 meters straight on white floor (no line).
> >
> > 1 to 4 degrees in a meter sounds like pretty good steering to me
> > for a Lego.
> >
> > How tight do you need to have it corrected to?
> >
> > What are you doing now to get it that straight? Have you done
> > the PID and Odometry already?
> >
> > Do you know what a gyro is?
> >
> > Randy
> >
>
Your message has been successfully submitted and would be delivered to recipients shortly.