IR/ultrasound sensing angle

how do these sensors work? Is it a distance directly in front of it, or does it “fan out” and return whatever the closest is?

The sonar fans out and returns the distance to the closest object in the fan within detection range. The detection fan of the LZ-MaxSonar-EZ1 that came in the KOP is about 4 or 5 feet across when it gets out 4 or 5 feet. Other models have different detection fans, but they all spread out to varying extents.

The IR sensor is more directed. It spreads out a little, but not much. It’s affected more by how reflective the target is and the angle the IR beam hits it at (bounce).

a little as in how much?

It depends on the model/make, but as an example I’d say the beam from a Banner QS18VN6LV widens 6mm or so per foot of distance. The beam is about 8mm at 6", 11mm wide at 12", 14mm at 18", etc.

A Sharp GP2Y0A02YK0F beam is about 6mm wide at 12", 12mm wide at 18", etc.

so there is no such thing as a “straight” sensor?


but does that return distance?

Just some of the applications they are used for include measuring the range to a golf hole, or the distance between interior walls. They are usually based on a class 1 laser that might be FRC legal depending on the rules (not guaranteed though). Class II lasers are probably right out for FRC use. They tend to be expensive devices and are difficult and complicated to integrate with a control system. Real expensive ones can be had with Bluetooth (not FRC legal).

You can also develop a DIY cheaper alternative by coupling a cheap laser pointer with a detector as a retro-reflective sensor.