Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learn Robotics Programming - Second Edition

You're reading from  Learn Robotics Programming - Second Edition

Product type Book
Published in Feb 2021
Publisher Packt
ISBN-13 9781839218804
Pages 602 pages
Edition 2nd Edition
Languages
Concepts
Author (1):
Danny Staple Danny Staple
Profile icon Danny Staple

Table of Contents (25) Chapters

Preface Section 1: The Basics – Preparing for Robotics
Chapter 1: Introduction to Robotics Chapter 2: Exploring Robot Building Blocks – Code and Electronics Chapter 3: Exploring the Raspberry Pi Chapter 4: Preparing a Headless Raspberry Pi for a Robot Chapter 5: Backing Up the Code with Git and SD Card Copies Section 2: Building an Autonomous Robot – Connecting Sensors and Motors to a Raspberry Pi
Chapter 6: Building Robot Basics – Wheels, Power, and Wiring Chapter 7: Drive and Turn – Moving Motors with Python Chapter 8: Programming Distance Sensors with Python Chapter 9: Programming RGB Strips in Python Chapter 10: Using Python to Control Servo Motors Chapter 11: Programming Encoders with Python Chapter 12: IMU Programming with Python Section 3: Hearing and Seeing – Giving a Robot Intelligent Sensors
Chapter 13: Robot Vision – Using a Pi Camera and OpenCV Chapter 14: Line-Following with a Camera in Python Chapter 15: Voice Communication with a Robot Using Mycroft Chapter 16: Diving Deeper with the IMU Chapter 17: Controlling the Robot with a Phone and Python Section 4: Taking Robotics Further
Chapter 18: Taking Your Robot Programming Skills Further Chapter 19: Planning Your Next Robot Project – Putting It All Together Other Books You May Enjoy

Writing code to test your motors

Before we get stuck in and do fancy things with the motors, we need to get them set up and test them. This way, we can make sure they work and iron out any problems.

We need to download the library to work with the motor board we have chosen. Many robot parts, apart from the simplest ones, have an interface library to control the motors and other devices on the board. It's time to log in to your Pi using PuTTY again.

Preparing libraries

We download this code from a project on GitHub using Git on the Raspberry Pi. So, we need to install Git on the Pi; we also need I2C (i2c-tools and python3-smbus) and pip to install things into Python. Type the following command:

pi@myrobot:~ $ sudo apt-get install -y git python3-pip python3-smbus i2c-tools

To get the library for the motor board, Raspi_MotorHAT, we use Git and download it from GitHub, installing it for use in any of your scripts with the following command:

pi@myrobot:~ $ pip3 install...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}