Page 1 of 2

Can't drive straight forward

Posted: 11 Dec 2010, 11:38
by airblader
Hi everyone,

for a competition at our university I'm working with the NXT at the moment (all new sets from LEGO). However, I do have a problem - I can't get the robot to drive straight forward. In order to accomplish that I am using

Code: Select all

#define WHEEL_BOTH OUT_BC 

[..] 

RotateMotorEx (WHEEL_BOTH, speed, dist * __mm_ratio, corr_factor, true, true);
But the robot always makes a small curve to the right. I also noticed, that if I hold the robot up, in some angles the right motor starts to vibrate (and in some cases it vibrates kinda a lot). By adding corr_factor to the turnspot I already tried to nullify the effect, but it doesn't really work. In another forum I was being told to come here and ask, so I did that. ;)

I appreciate any kind of help and thanks in advance!
Ingo

Re: Can't drive straight forward

Posted: 11 Dec 2010, 18:55
by mattallen37
What do you mean by this?
...if I hold the robot up, in some angles the right motor starts to vibrate (and in some cases it vibrates kinda a lot)...
It sounds like a mechanical issue with the robot, not a software issue.

Re: Can't drive straight forward

Posted: 12 Dec 2010, 06:56
by airblader
Hi,

I kinda think it might be a mechanical issue, too. To be more precise about what I meant:
If I just hold the robot into the air the motor usually seems to work fine. But if I like just turn it around a little, in certain positions you can hear and feel the motor vibrate and sometimes this vibrations gets pretty strong. Since this also happens when I only run this one engine with no synch whatsoever, I guess it might just be a crappy motor.

I already sent an email to the technical leader of the competition, let's see what he says.

air

Re: Can't drive straight forward

Posted: 12 Dec 2010, 09:22
by gloomyandy
Have you tried switching the wheels around from one side to the other? If you do this does the robot still steer off to the same side. If it now goes in the other direction you may have one wheel/tyre bigger than the other (or the tyre may not be on the wheel correctly). If switching the wheels makes no difference try doing the same thing with the motors....

Andy

Re: Can't drive straight forward

Posted: 12 Dec 2010, 15:37
by airblader
Hi,

yes I did try switching the wheels, but it didn't change anything. I'm gonna try replacing the motor on the right side with the third motor in the set tonight.

air

Re: Can't drive straight forward

Posted: 12 Dec 2010, 18:56
by airblader
Okay, so i switched motors in almost every possible combination - no changes.
But here comes the big surprise: Since it wouldn't be the motors, I just switched the cables for the ports to B and C (meaning I just switched on which port which wheel is connected) ... and all of the sudden the robot drives a curve to the left instead of to the right.

So should that tell me that the nxt computer doesn't work right?

Edit: And just to make sure you understand that it can't be the problem ... I used a simple test program which counted the motor ticks and the line to make the robot move is this:

Code: Select all

OnFwdSync (OUT_BC, 100, OUT_REGMODE_SPEED);
(I also tried it with OUT_REGMODE_SYNC, no changes)

air

Re: Can't drive straight forward

Posted: 12 Dec 2010, 20:57
by mrblp
Hello,
airblader wrote:However, I do have a problem - I can't get the robot to drive straight forward.
Did you use some RotateMotorEx-Commands in a queue? If yes, use Wait(1) before every RotateMotorEx-Command to let the parameters be updated by the system. Especially if corr_factor is set to zero funny things will happen: The robot will try to "correct" the curves he drove before...

If that is not your problem I think you have a mechanic problem as stated before.

Bye marvin

Re: Can't drive straight forward

Posted: 12 Dec 2010, 21:01
by airblader
Hi,

while I appreciate your answer I think you might have not read the whole thread. I used different commands and I didn't use several of them in a row or anything. Also, by now, I know that it can't be an issue of the motor, but probably with the nxt computer .. or "just" the compiler. I don't know yet.

air

Re: Can't drive straight forward

Posted: 12 Dec 2010, 21:40
by airblader
Okay, so this is just getting ridiculous.
Here is the code I now used:

Code: Select all

task main ()
{
ResetTachoCount(OUT_BC);
OnFwdSync (OUT_BC, 95, OUT_REGMODE_SPEED);
Wait(7000);
Off(OUT_BC);
Wait (10000);
OnFwdSync (OUT_BC, 100, OUT_REGMODE_SPEED);
Wait (7000);
Off (OUT_BC);
Wait (1500);
}
And here is the video (sorry, it isn't the best quality): http://www.youtube.com/watch?v=OODbFfzs52g
As you can see, with speed 95 it pretty much drives straight forward, but with speed 100 it suddenly drives a huge curve. Why the hell would that happen?

Also something I noticed: When the motors start, I can always see that the robot changes the direction *a little bit*, meaning one wheel starts turning before the other one does. However, this only changes the initial direction a bit (still, bad enough!), afterwards any more problems depend on the speed (as seen above).

air

Re: Can't drive straight forward

Posted: 13 Dec 2010, 03:08
by nxtreme
I'm just guessing here, take it all with a grain of salt. I think that that the algorithm that syncs the NXT motors might only work if you leave the speed beneath 100% because it will speed up the motor that is slow, meaning that if you try to sync two motors at 100% speed, it can't speed up the slow motor which makes it curve. When you leave the target speed lower, it leaves a bit of "headroom" for the NXT to use to sync the motors. Now, if the NXT would see when the speed was set at 100% and instead of trying to speed up the slow motor, slow down the fast one, you might get a straight line. Remember, this is just an uneducated guess.

If you do want slightly better results, use the method Techbricks.com suggested, picking the two motors that perform the closest. I hope you get something working!

-EDIT- Oh and if the problem of having the motors start slightly out of sync becomes an issue, have the motors first start at a lower speed like 5-10% and then ramp up to what you want them at. This might help as then the amount that one motor turns before the other starts up will be less. However, if they don't quite get the speed setting updated at the same time, you'll have the same problem all over again. Just something to think about.