How to make the robot drive straight?

When I try to drive forward, giving both engines 1, the robot drives a bit left. How can I fix it?

A number of ways.

  1. You can continue using an open loop system with no sensors, but do a bit of calibration. Multiply the right side by .9 or .95 or whatever value corrects for the problem.

  2. You can dig deeper and determine if it is due to differences in motors, bindings in gearboxes, tightness of chains, or resistance of electrical components, and try to correct the underlying issue.

  3. You can close the loop and add sensors such as encoders to measure how fast the motors are running and correct it so that the fast side doesn’t outrun the slow side.

Option 1 is trivially easy but will likely not solve the problem except at that power setting, with that battery voltage, on that carpet, etc. Option 2 is important to at least look for in case it is a serious inefficiency that you are trying to work around in software. Option 3 takes more thought and more work, but if tuned well, it is the most robust.

Greg McKaskle

This could also be a hardware problem. If some of the motors are wired in reverse polarity, or if they’re just older, they might not be able to reach the same maximum speed as they could if they were new and wired straight through. If any of your motors are wired up reverse polarity and receiving a +1 signal, try re-wiring them in straight through polarity and sending that side a -1 signal instead.

You could try ballast if you have room for the weight.

Really? Does that make a difference? I’ve never thought of this but I just assumed motors were symmetrical in efficiency, except maybe niche motors for specific tasks (I can’t even think of one right now). Do you have links to give me?

Don’t make an ‘assume’ joke.

Many motors have a measurable bias in their “forward” direction. However, a CIM’s bias is negligible.

You can’t compensate for bias by swapping wires. There is no electrical difference between sending full positive voltage to a motor’s black wire and sending full negative voltage to its red wire. Assuming the same mechanical load, it will spin in the same direction at the same speed in either case.

The place to look is in the mechanical side of things, not electrical. The slower-moving side could have some extra friction or binding, perhaps due to a too-tight chain or belt. Or it might just be that the wheels aren’t mounted quite in line with the desired robot travel and the chassis would tend to travel in a curve even when being pushed by hand with no power applied.