Hey guys. Team 3200 here. During the offseason we were doing some training. The bot that we built keeps drifting to the left by a severe amount. We have attached wheel encoders to try to even out this drift. We code using java and would really appreciate if you had any code examples to help get the bot to drive straight. Any help is much appreciated.
Don’t put lipstick on a pig. With severe drift, you should rule out alignment, excessive friction, and other mechanical, electrical, and software problems first.
Describe your drivetrain and driver interface so we can make suggestions.
While you can use encoders to drive straight, a better idea might be to use a gyro since encoders can have errors due to wheels slipping. Regardless of the sensor you choose, you will want to use a PID controller to help correct the drift. When using encoders, one method would be to use a master-slave setup as described in this article. The example code is in ROBOTC, but the same principles apply. Basically you measure the speed difference between the two sides of the drivetrain and use that error with your PID controller to correct the drift.
Searching the forums will also provide you with more information on this topic, such as this thread.
We use a 6 wheel drivetrain. With toughbox minis which are specially made with a unique gear ratio for speed. We use 2 CIMs on each toughbox. We use the standard drive code given by FIRST. We have been trying to check out mechanical and electrical problems but we haven’t narrowed it down to anything yet.
What kind of wheels?
How much are the center wheels dropped?
Chains or belts? How are you doing the tensioning?
What’s the total speed reduction from motor to wheel (include gears, sprockets, and pulleys?
Put some extra weight over the rear wheels and see if that changes the amount of drift. Then move that extra weight to the front wheels and try again.
Put the bot up on blocks and slowly advance the throttle and observe the left and right wheel speeds.
We use high grip traction wheels. The wheels are dropped about a quarter of an inch. We are using belts. We don’t have any tensioners on the bot. Sorry but I don’t know how to answer the last question because we are not sure how to measure that value.
What is the gear ratio of your gearbox, and what are the diameters of the driving and driven pulleys?
Also, what diameter are the wheels?
We don’t have any tensioners on the bot
Have you measured the belt tension?
With the robot on blocks and no power applied, spin the wheels on both sides by hand. Do they have the same friction?
Are you certain both toughboxes were updated identically? Since you intended to go faster, take the slower one (left) apart and make sure it has all the right gears. What gears (how many teeth) are you expecting to find? Two years ago, the person who rebuilt our TB put the middle 14T back when it needed to be changed to a 16T.
My manufacturing leader isn’t sure of the gear ratio on the gear box. The diameter of the driving pulley is 2.75 inches. The diameter of the driven pulleys are 3 inches. The diameter of the wheels are 6 inches. We aren’t sure how to measure belt tension
We have tried this and it appears that the right side spins much easier than the left side.
That is a possibility but because we will be using this bot on Saturday for an offseason event we are not able take of the gear boxes and see if they are geared identically.
That could be the cause of your left-drift problem.
Have you tried putting it up on blocks and advancing the throttle slowly and observing the speed on each side? This is easy to do.
OK, but can you tell if the belt on the left side is tighter than the belt on the right side? Push1 on the belt midway between the two pulleys and see how much it deflects. The tighter the belt is, the less it will deflect.
If you want to be a little more accurate, ask around to see if anyone on your team has a fish pull-scale. Hook the scale to the belt midway between the pulleys and pull1 it. Measure how far the belt deflects for a given force.
Yea the left side goes slower than the right side. The belt tension is tighter on the left side. We used to have the right motors hooked up to the victors on the right and the left motors hooked up to the victors on the left. We switched the hook up so the right motors were hooked up to the victors on the left and the left motors are hooked up to the victors on right. The bot still curves to the left by a bit but it isn’t as drastic as it was before.
Although I agree that your issues are more likely mechanical, I have seen some robots that have drift problems that are not extremely severe (and thus difficult to properly diagnose), so there is some application for using encoders to even out drive. The basic technique is to use a feedback controller (eg. PID) to control the difference between the encoders. eg., if you’re using (rightEnc-leftEnc), you’ll control the value to 0 to move straight, some positive value to curve left, and some negative value to curve right.