# Making Robot Move straight

#1

What methods do you guys use for making the robot move as straight as possible? Currently we’re using a comparative p controller that adjusts the left and right side speed based off their difference in encoder value.

#2

Make sure the friction on each side is as similar as possible. And, it probably won’t make much of a difference, but I’ve used the same size wires to ensure constant loss of current on both sides. But it can’t be a big deal across such short wires.

#3

@Joshua_L my team uses the gyro sensor to measure any change in angle and correct it with a p controller.

#4

@Joshua_L We use SlEwrAtE and it doesn’t veer

#5

we honestly don’t do anything. never have any issues with it, it really doesn’t ever veer enough to be a problem.

#6

In skills we would use encoder straightening + PID while in auton we use gyro straightening + PID

#7

Lucky, for some reason we have a massive veer (6 inches left over 5 feet). Our drive has pretty equal friction so idk whats causing it to veer. And the frustrating part is that it still veers, whether we use gyro or encoders to correct it.

#8

@Joshua_L Prob not the case but are all of your motors at the same gear setting?

#9

I’m going to assume that you’re talking about veering during autonomous and not driver control since most teams don’t do encoder speed adjustments in driver control.

There are a lot of things that could be causing this. If you’re able to drive straight in driver control, it is definitely a code thing. If it doesn’t drive straight in driver control either, it could be a friction thing as well. If you believe it’s a programming thing, I would make sure that you are starting all of your motors. You may be starting only some of the motors (3 out of 4, or some other combo).
Another option could be that your math is incorrect. If you’re doing any calculation to determine the speed, you might be calculating the speed of the side that is slower incorrectly.

#10

Ya you are probably just not doing a good enough job of correcting it. I usually run 2 PID loops, 1 for straight distance and 1 for course correction. Then it is as easy as increasing kp on the course correction controller until it is stable.