Best Ultrasonic Sensor / Encoder?

Last year I was able to write consistent autonomous code for placing gears on all 3 of the pegs using timings, a gyro, and vision tracking.

This year, my team would like me to write auton code for placing 2-3 crates in the switch. That being said, I think in order to get it consistent I will want to use encoders/an ultrasonic sensor.

For the encoder(s):

  1. Is it best to use an encoder on each gearbox or is only 1 necessary?

For the ultrasonic sensor:

  1. I’m having trouble finding an ultrasonic sensor that can read accurately past 12". I’d most likely be using it for the purpose of forward motion during vision tracking, so ~24" would work.

I’d love to hear about the Ultrasonic sensors/encoders that your teams are using / the ones you think are the best.

Thanks :slight_smile: !

For the encoder(s):

  1. Is it best to use an encoder on each gearbox or is only 1 necessary?

If you only have one encoder on the chassis, then if you’re trying to determine distance traveled, going in a circle looks no different than traveling in a straight line. Having an encoder on each side of the drive train is desirable. That said, if you are confident in your ability to keep the robot driving straight (with a gyro or something), then a single encoder is a good approximation of the distance traveled.

We have used Grayhill 63R256 encoders with great success since 2012. There is a $50 PDV to digikey in your kit of parts.

For the ultrasonic sensor:

  1. I’m having trouble finding an ultrasonic sensor that can read accurately past 12". I’d most likely be using it for the purpose of forward motion during vision tracking, so ~24" would work.

There should have been an Ultrasonic sensor from maxbotix in your kit of parts. Specifically this one: https://www.maxbotix.com/Ultrasonic_Sensors/MB1013.htm. It is in a little baggie stapled to a flyer about the sensor. These sensors are usually pretty good for detecting large objects (like walls). It’s able to sense objects up to 195 inches away. You’ll want to verify you can mount it low enough that you can detect the surfaces you need to (like the switch wall), but not so low that you get reflections off the floor. The nice thing is that you already have one on hand to test out and see if you think it will work for your specific application.

Personally I would go with one of the sharp IR ranging sensors. At least one of these have been on our robot since 2012. As long as they aren’t mounted facing upwards, you should be fine (event lighting can give erroneous readings when they are facing straight up). They are rated for different sensing ranges depending on your application: 10-80cm, 4-30cm, 20-150cm.
There are many suppliers online selling these sensors, (Amazon, ebay, digikey, pololu, sparkfun, adafruit, etc). So shop around for best price.

These are wired up to analog input channels on the RoboRIO. You can then convert the reported voltage to a distance, or just look for a value >= to some known voltage. There are voltage/distance curves for each sensor on the pages linked above. One thing to keep in mind with these is that the plastic case is conductive. Yes that’s not a typo. The plastic is conductive and grounded. So when they are mounted they need to be kept isolated for any metal on the robot.

A couple of sensor warnings:

  1. Check the range for your version of the Maxbotix ultrasonic sensor. Some can’t measure closer than 20 or 30 cm.
  2. Be careful using IR sensors on a field with so much clear polycarbonate. I’m not convinced that Sharp IR will be able to see the switch fence, for example, unless you aim for the top rail.

Good point on #2. Have you tested the sharp sensors ability to detect the polycarbonate wall of the switch?

I have not myself. Its on my to-do list. I was hopeful that there was enough material within the switch (making up the plates of the balance, vision markers, vertical supports, etc) that they would be detectable. But that’s an assumption I haven’t tested.

we had zero success last year with sharp IR, and banner fixed field diffuse sensor to pick up the clear polycarb behind the peg. We ended up using an ultrasonic, but the raw data needed to processed to be useful… (I think we sampled 10, through out top 2 and bottom 2 and averaged the remaining 6, the ultrasonic gave a wide range of error data)

Another thing to be careful with when using the Sharp IR sensors is that the voltage/distance plot is non-monotonic, so you should make sure there is never a case where the object to detect (or anything interfering) can be closer than the minimum rated distance.

For example, if you are trying to drive to a wall using the 20-150cm sensor, and the wall ends up at 10cm from the sensor, the output voltage will be the same as if the wall is 25cm away and the robot may take the wrong action.