Are there any performance differences between optical sensors and ultrasonic sensors? How do I make the right choice for my drone? I will be using them in a object detection system for collision prevention.
Keyence has a useful comparison table:
╔════════════════════╦══════════════════╦══════════════════╗ ║ Item ║ Optical ║ Ultrasonic ║ ╠════════════════════╬══════════════════╬══════════════════╣ ║ Detectable target ║ Affected by ║ Unaffected by ║ ║ ║ colour/material ║ colour/material ║ ║ Detecting distance ║ 1000mm max ║ 10m max ║ ║ Accuracy ║ High ║ Low ║ ║ Response speed ║ Fast ║ Slow ║ ║ Dust/water ║ Affected ║ Unaffected ║ ║ Measuring range ║ Small ║ Large ║ ╚════════════════════╩══════════════════╩══════════════════╝
So basically it depends how and where you want to use it... Since you say you are trying to avoid colliding with objects, my guess is you'll want the ultrasonic. It gives you a much higher detecting distance (10 m vs 1m). At most speeds, 1 m could be insufficient to avoid a collision.
Also, if you plan on using your drone anywhere where the sensor could get dirty/wet, you'll definitely want to go with the ultrasonic sensor.
TL;DR: it depends entirely on the situation in which you intend to use the sensors.
According to this article, it is entirely dependent on your application.
You’ve mentioned you want to use it for obstacle avoidance, but the environment in which you want to do this is important.
IR sensors are easily affected by external conditions such as ambient light levels. As such, using them outdoors might be problematic.
However, IR sensors are apparently better at detecting edges, so they are more appropriate if you want to use them in very close quarters.
Another option worth looking at would be optical flow sensors, however these may not work so well in the dark from what I’ve seen.