Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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
Mastering Beaglebone Robotics

You're reading from   Mastering Beaglebone Robotics Master the power of the BeagleBone Black to maximize your robot-building skills and create awesome projects

Arrow left icon
Product type Paperback
Published in Dec 2014
Publisher
ISBN-13 9781783988907
Length 234 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Richard Grimmett Richard Grimmett
Author Profile Icon Richard Grimmett
Richard Grimmett
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Preparing the BeagleBone Black FREE CHAPTER 2. Building a Basic Tracked Vehicle 3. Adding Sensors to Your Tracked Vehicle 4. Vision and Image Processing 5. Building a Robot that Can Walk 6. A Robot that Can Sail 7. Using GPS for Navigation 8. Measuring Wind Speed – Integrating Analog Sensors 9. An Underwater Remotely Operated Vehicle 10. A Quadcopter 11. An Autonomous Quadcopter Index

Following colored objects with your vision system


Now that your robot can sense colored objects, let's take this a step forward and use this capability to actually guide your robot. If you look at the code from the last section, you'll notice two variables, pt1 and pt2. These variables hold the x and y coordinates of the color that your robot found. We can use these with our dcmotor.py program to move the robot so that when the color reaches the edge of the viewing area, the robot will move to put the colored object back into the middle of the viewing area. Here is the code:

When your robot finds a color, it also finds the x boundaries of that color. These are held in the rect[0] and rect[2] variables. Each time through the loop, your program checks to see if the left side is smaller than 20 or the right side is larger than 310. In either case, your program will call the dcmotor.py program you wrote earlier and move the robot in a turn either to the right or left. As you move the target,...

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 $19.99/month. Cancel anytime
Banner background image