# Small IR distance sensor that works on black surfaces

Can anyone recommend an IR distance sensor that works on black surfaces? I'm looking for something to use as a "cliff" sensor, to help a small mobile robot avoid falling down stairs or off a table, and I thought the Sharp GP2Y0D805Z0F would work. However, after testing it, I found any matte black surface does not register with the sensor, meaning the sensor would falsely report a dark carpet as a dropoff.

Sharp has some other models that might better handle this, but they're all much larger and more expensive. What type of sensor is good at detecting ledges and other dropoffs, but is small and inexpensive and works with a wide range of surfaces?

• Have you actually tested the Sharp sensor with the "dark carpet" you intend to use? The Sharp IR rangefinders work by illuminating the scene and evaluating the return intensity, BUT they are infrared - that means that you cannot evaluate IR reflectivity by looking at surface color in the visible spectrum. Carpet mostly nylon, so comparing its response to whatever matte black surface you used is probably not a fair representation. – Chuck Nov 13 '15 at 19:45
• @Chuck, I haven't tested it with true black carpet, no, but my primary goal is also to make this work with black table tops. You may be right about carpet, but when it's on the ground, I'm more concerned with black tile and black plastic carpet trim as registering a false positive. – Cerin Nov 13 '15 at 23:06
• I understand your concern, but again, plastics especially typically have considerably different properties in IR vs visible bands. Also, for sanitary/cleaning purposes, I think that you might find a lot of surfaces like tables and floors are non-porous. This would mean that it's harder to stain the surface, but should also give stronger return intensities. Again, I would try testing it on the surfaces you're concerned about. Try going to a carpet show room, I'm sure they'd let you test on swatches. – Chuck Nov 14 '15 at 4:53

A surface that appears black doesn't reflect much visible light (it's the absence of visible light reaching your eye that makes it look black), if the surface also doesn't reflect IR light very well, then IR sensors will not work very well (they work by shinning IR light and measuring the intensity of the IR light reflected back). Note you can not tell with certainty whether a surface will reflect infrared by looking at it since you cannot see IR, but if it is the case that your surface isn't reflecting IR, then no IR sensor will work.

Have you considered using an ultrasonic distance sensor (aka ultrasonic rangefinders)? They work using the same principal but with sound (outside of auditory spectrum) instead of light. Or a mechanical sensor?

Ultrasonic sensors have a deadband of about 2-5 cm, so wouldn't be useful for close-range sensing. Also ultrasonics work best with hard, solid surfaces. Carpet, clothing, drapes, cushions, etc. will absorb much of the ultrasonic pulse and are likely to result in a faulty reading with the target appearing much further away than it really is.

The key for any sort of "cliff sensor" is that you are looking for a change in measurement by a significant value from previous measurements. I've built robots before that are programmed to avoid table edges and were using IR sensors. The heuristic for avoiding a table edge or stairway isn't to look for a specific value but a large change.

So, something like:

//assuming distance is measured in raw sensor values vs. cm or inches.
if ( abs(cur_distance - last_distance) > 100)
{

//do some avoidance logic here

}


This will work even if the sensors return weak or off-scale measurements when passing over a dark surface.

The problems with the Sharp sensor you've listed are: it's infra red only, and it's a digital on/off signal.

As you're hoping to detect a ledge or cliff, perhaps you could use an analogue sensor instead. Looking over the side of the ledge, we might reasonably expect the light level to change in some way, unless the room is in complete darkness - so if you suddenly detect a change in light level, you might be near the edge.

Note this may be affected by patterned carpets/tabletops though, or even by people switching the room lights... the only way is to try it and see.

Another possibility is to abandon visual sensors and use something that gently touches the floor - a flexible feeler like a cat's whisker, or a lever going down to a smooth roller or slider. But this could get tangled if there's clutter in the environment, such as loose wires or the edge of a rug.