Part 4: the hard part
4. Making it reliable, not just working
Getting a reliable grab was much harder
than getting a working one. Raw ultrasonic readings are
noisy, and a single spurious short reading would snap the
claw shut on nothing at all.
- Added sample filtering so a trigger requires agreement across several consecutive readings.
- Introduced a small dead zone to stop the claw oscillating when an object sat right at the threshold distance.
- Reshaped the jaw profile after the first build — the original made contact at a single point and objects simply rolled out of the grip.
Nearly all the control code that ended up mattering was
there to handle bad readings, not good ones. Sensor
data is never as clean as the datasheet implies.