Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Robotics at Home with Raspberry Pi Pico

You're reading from   Robotics at Home with Raspberry Pi Pico Build autonomous robots with the versatile low-cost Raspberry Pi Pico controller and Python

Arrow left icon
Product type Paperback
Published in Mar 2023
Publisher Packt
ISBN-13 9781803246079
Length 400 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Danny Staple Danny Staple
Author Profile Icon Danny Staple
Danny Staple
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Part 1: The Basics – Preparing for Robotics with Raspberry Pi Pico
2. Chapter 1: Planning a Robot with Raspberry Pi Pico FREE CHAPTER 3. Chapter 2: Preparing Raspberry Pi Pico 4. Chapter 3: Designing a Robot Chassis in FreeCAD 5. Chapter 4: Building a Robot around Pico 6. Chapter 5: Driving Motors with Raspberry Pi Pico 7. Part 2: Interfacing Raspberry Pi Pico with Simple Sensors and Outputs
8. Chapter 6: Measuring Movement with Encoders on Raspberry Pi Pico 9. Chapter 7: Planning and Shopping for More Devices 10. Chapter 8: Sensing Distances to Detect Objects with Pico 11. Chapter 9: Teleoperating a Raspberry Pi Pico Robot with Bluetooth LE 12. Part 3: Adding More Robotic Behaviors to Raspberry Pi Pico
13. Chapter 10: Using the PID Algorithm to Follow Walls 14. Chapter 11: Controlling Motion with Encoders on Raspberry Pi Pico 15. Chapter 12: Detecting Orientation with an IMU on Raspberry Pi Pico 16. Chapter 13: Determining Position Using Monte Carlo Localization 17. Chapter 14: Continuing Your Journey – Your Next Robot 18. Index 19. Other Books You May Enjoy

Always face North behavior

We’ll build a behavior with a heading as a set point for a PID and the IMU Euler heading as feedback. The error value between these will be how far, in degrees, the robot is facing away from the North heading. For example, a heading of 0 should be North – note that you could pick another heading as needed. We will use the PID output to control the motor movements, with the output adding to the speed of one motor and subtracting from the other, producing a turn.

Let’s see how this looks as a block diagram:

Figure 12.10 – Face North behavior block diagram

The preceding diagram shows the flow of data. The expected heading (or target) with the actual heading from the IMU are used to calculate the error. This error and dt (delta time) are the inputs to the PID. The output from the PID, the control signal, is added for one motor and subtracted for the other. The motors then result in robot movement, which...

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 €18.99/month. Cancel anytime