Book Image

Mastering Beaglebone Robotics

By : Richard Grimmett
Book Image

Mastering Beaglebone Robotics

By: Richard Grimmett

Overview of this book

Table of Contents (18 chapters)
Mastering BeagleBone Robotics
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Following movement with your robot


To follow the movement, you will do something very similar to the previous section on following color. Your program will hold the center of the movement in the center_point variable, which will hold and the x and y value. You can then use it to move your robot if it is on either edge of the vision field. The first additions you'll need to add to your program are the import time and import os lines at the top of the file, to include these libraries. Here are the changes:

Here are the main additions at the bottom of the program on motion detection:

These lines should look almost exactly like the lines you added to move your robot when tracking color. The timing statements prevent our robot from overreacting to the movement. Now your robot should be able to follow movement within its field of vision.