Measuring Distance With Sensors

Ok so every year (for ~12 yrs now) my team has always done “dead-reckoning” Autonomous, but as programmer I am determined to use some sensors. (Last yr was 1st year to get the camera display).

Recently I managed to get the gyro to work and have the robot travel in a straight line down a long hallway. Now I would like to measure the distance of the robot moving, What would be best for this? (Accelerometer, my mentor suggested Hall Effect Sensors with a magnet mounted on the wheel, or different kind of encoder).

Many teams (we do) use optical encoders. If you use a standard gearbox (toughbox, supershifters, etc), there is an output shaft on those that fit these. They can measure speed and distance, as well as let you set up a PID loop.

To measure distance traveled, a topic known as odometry, one would normally use a sensor that measures how many turns one or more wheels have made.

An optical encoder was included in the KoP for this, you mount a small wheel to a 1/4" shaft and it delivers something like [strike]250[/strike] 360 pulses per revolution. Since it has two signals you can also tell whether the wheel is traveling forward or backward. There are other ways to sense rotation, but most teams use the optical encoders supplied.

Naturally the accuracy of such a system depends on many factors, most important a relative lack of slippage between the wheel and the surface on which it travels. If you anticipate significant slippage, an unpowered ‘fifth’ wheel can be used (google it)

Wiring up the sensor is not difficult - power, ground, signal A and signal B. We wire up power and Signal A to one digital I/O on the sidecar, and ground and signal B to another digital I/O. I’m not a programmer, but I believe there are routines in every language for handlingt his data stream. They’re a bit finicky (as judged by the number of CD posts asking for help) so use care to ensure it works first time.

Good luck, you are on the right track away from dead reckoning.

For reference, the included encoder is the USDigital E4P encoder, with a 360CPR wheel. In 2009, the included wheel was 250CPR.

Note that while optical encoders are great for distance, they are limited by the fact that they only measure how much the wheel has rotated. If your wheels lose traction with the ground, they will NOT accurately measure the position of the robot. This can happen, for example, on the bridge.

Thanks for the info. That should work on the competition drive train, but for a programming class I am helping with the bot has 2 Banebots as direct drive motors (it is a much smaller bot).

So any ideas for this?

There are quite a few options. I don’t think I’ve seen a team that’s done it (but I don’t know how you COULD see a team do this), but if you want to take into account slippage, you could attach a >= 2-axis accelerometer as well as an encoder. You will notice the behavior of slippage in an accelerometer (or the lack thereof behavior). You can use that information as a sanity check for your encoder. If you see your encoder moving and you know you should be accelerating but don’t see it in your accelerometer, then you know you’re slipping. As mentioned before, an unpowered 5th (and 6th) wheel would work just as well.

I think there are also options for the ultrasonic sensor.