OUR EXPERT Les Pounder is associate editor at Tom's Hardware and a freelance maker. He blogs about hacks and makes at http://bigl.es.
At the end of part two, we had successfully built our robot from a kit, soldered the motors and tested them using a series of directional commands. To facilitate this, we created our own Python module to make things easier to control and abstract away some of the complexities. In this part, we move on to writing code that takes data from sensors and uses it to give our robot 'brains'.
Sensors, much like our own, provide a means to see and interact with the world around us. We use our eyes to see the world. Robots can see the world around them with OpenCV (Open Computer Vision), which uses machine learning to identify objects and people, and react accordingly. At a more basic level, robots can 'see' using ultrasonic and obstacle sensors. There are so many sensors to choose from it can bewilder even the most seasoned of makers. We've chosen to stick with the most basic forms: infrared, buttons and ultrasonic sensors. The more advanced methods of input and control will come in a future part.
This part can become quite complex - remember, we are working with multiple types of sensors. We will write the code and test each one as we go. We may use them all, or just a few. That is a decision for you. Make your robot as complex or simple as you wish - we will give you the tools and the knowledge to realise it. Start with a single sensor, learn how it works and then apply that knowledge to your build. The online resources have all of the code snippets for you to add to your code, and our robot.py file contains every function for every sensor we create in this tutorial.
Additional features
Denne historien er fra March 2023-utgaven av Linux Format.
Start din 7-dagers gratis prøveperiode på Magzter GOLD for å få tilgang til tusenvis av utvalgte premiumhistorier og 9000+ magasiner og aviser.
Allerede abonnent ? Logg på
Denne historien er fra March 2023-utgaven av Linux Format.
Start din 7-dagers gratis prøveperiode på Magzter GOLD for å få tilgang til tusenvis av utvalgte premiumhistorier og 9000+ magasiner og aviser.
Allerede abonnent? Logg på
Create your first WebSocket service
Mihalis Tsoukalos explains how to use the Go programming language to work with the WebSocket protocol.
Fantastic Mr Firefox
Nick Peers takes a trip down memory lane to reveal the story behind the rise - and slight fall - of Mozilla's popular web browser.
Set up your terminal and email like it's 1983
Jump in the hot terminal time machine with Mats Tage Axelsson who emails from the command line using the latest technology.
Universal layer text effects with GIMP
Posters use them, films and presentations are hard to imagine without them: text effects. Attract attention with Karsten Günther and GIMP.
Jump to a federated social network
Nick Peers reveals how you can get up and running with this free, decentralised and non-profit alternative to Twitter.
Free our SOFTWARE!
Taking anything for granted is dangerous, so Jonni Bidwell and Mike Saunders revisit how the free software movement got started to help free us from proprietary tyranny!
Master RPI.GPIO
Les Pounder goes back to the early days of the Raspberry Pi - and his career with this classic library! -
Waveshare Zero to Pi3
Transform your Pi Zero into a Pi 3, they promised Les Pounder, but it's more like adding on go-faster stripes.
The Best OPEN SOURCE Software Ever!
In an attempt to trigger controversy, Michael Reed and Neil Mohr unequivocally state these are the greatest free software apps ever. Probably. We’re just trying to be helpful.
Linux-Mandrake 7
Simplicity and a wide range of applications make this a great distribution for all Linux users.