Robot not going a straight line in telops arcade mode

#1

Hi,

In telops (manual drive) mode, the biggest problem our team has is, very often the robot doesn’t drive a straight line, even in very short distances, such as going from starting point to the bar in the NextLevel game. The robot is using arcade control, I wonder if that has anything to do with this behavior. Here is the code for arcade control:

  //arcade control variables
  yjoy = getJoystickValue(ChA);
  xjoy = getJoystickValue(ChC);

	if(yjoy > -10 && yjoy < 10)
	{
		yjoy = 0;
	}
	if(xjoy > -10 && xjoy < 10)
	{
		xjoy = 0;
	}
	leftm = xjoy + yjoy;
	rightm = -xjoy + yjoy;

setMotorSpeed(driveMotorRight,rightm);
setMotorSpeed(driveMotorLeft,leftm);

Thanks,

Jason

0 Likes

#2

Programming is not my strong suit so I’ll let others comment there. From a basic troubleshooting approach, there seems to be 1 of 2 things… either the robot doesn’t go straight, or the remote needs work. Will is drive in a straight line in autonomous?

0 Likes

#3

it certainly doesn’t drive a straight line in autonomous, that’s a different issue that I will ask on a separate thread, as it’s more related to sensors not working.

while the overall design of the robot is symmetrical, I could understand it would deviate over a longer distance. but I don’t understand why sometimes it goes sideways even over just 1-10 inches.

0 Likes

#4

Do remember that even though the robot may be built symmetrically, the friction on each side might not be identical.

First, rule out code: swap the left and right motors’ ports. If the code is fine, it will curve in the same way going “backwards” that it curved when going forwards before the swap.

Next, rule out the motors, if possible: if you have spare motors and your motors are easily accessible, swap them out for new ones and see if the problem changes in any way. Try not to change anything else if possible.

Next, rule out ports: swap your motors to a different block of ports (so if they’re on 1-3, try 4-6, etc.). You will have to change the code for this bit.

If none of those reveal any change, your final likely reason is build quality. Work to make sure that the wheels can spin freely (detaching the motors helps for this test). Axles being torqued can cause friction, as well as axle holes not being aligned quite right.

1 Like

#5

did some simple tests that by swapping left and right motor’s ports, just one command to go forward or backward, actually it could go pretty straight across 3/4 of the length of the field before going off course, thought that should be good enough? but in manual control, very often it can’t even go straight for 6-10 inches.

0 Likes

#6

I’m thinking that it’s the motors being imbalanced somehow (one has a higher rpm than the other, causing the robot to curve).

My fix for this is for EDR V5 equipment, I haven’t had much experience with IQ. Question: do IQ motors have integrated encoders?

0 Likes

#7

Yeah and the usually run pretty well. If your problem is only in driver and less in auton, then try a threshold on your left/right joystick assuming you are using arcade mode. If in tank, make sure the joystick is calibrated and both axis reach 100%

0 Likes

#8

we are using arcade control, and here is the code:

//arcade control variables
yjoy = getJoystickValue(ChA);
xjoy = getJoystickValue(ChC);

	if(yjoy > -10 && yjoy < 10)
	{
		yjoy = 0;
	}
	if(xjoy > -10 && xjoy < 10)
	{
		xjoy = 0;
	}
	leftm = xjoy + yjoy;
	rightm = -xjoy + yjoy;

 setMotorSpeed(driveMotorRight,rightm);
setMotorSpeed(driveMotorLeft,leftm);

is that threshold too high? The other problem the kids have, is when they turn, they can’t do fine adjustment, like when they try to aim for the yellow hub, they often have to turn left and right several times, all too much one side or other.

0 Likes

#10

That’s not quite doing what you think. You are overwriting the threshold values straight away.

Try:

//arcade control variables

xjoy = getJoystickValue(ChC); 
yjoy = getJoystickValue(ChA);


	if(yjoy > -10 && yjoy < 10)
	{
		yjoy = 0;
	}
        else{
            yjoy = getJoystickValue(ChA);
        }

	if(xjoy > -10 && xjoy < 10)
	{
		xjoy = 0;
	}
       else{
          xjoy = getJoystickValue(ChC); 
       }

	leftm = xjoy + yjoy;
	rightm = -xjoy + yjoy;

 setMotorSpeed(driveMotorRight,rightm);
setMotorSpeed(driveMotorLeft,leftm);
0 Likes

#11

I see you added the else block:

else{
yjoy = getJoystickValue(ChA);
}

but isn’t that implied by the initial

yjoy = getJoystickValue(ChA);

before the if block?

0 Likes

#12

Yes, you are right, my apologies. Perhaps increase the left/right threshold slightly or calibrate the joystick just incase?
You could write the xjoy and yjoy values to the screen to see if the thresholds are working ok or if the left/right is causing problems. Use the displayTextLine command.

0 Likes

#13

how to calibrate the joystick?

0 Likes

#14

Connect the controller to the brain with tether cable then go to settings on brain and find calibrate controller.

0 Likes