There's more...

There are also ways to detect objects that are near the robot without actually making physical contact with them. One such way is to use ultrasonic sensors, commonly used for vehicle reversing/parking sensors.

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.