Skip to Content
Learn Robotics Programming
book

Learn Robotics Programming

by Danny Staple
November 2018
Beginner
472 pages
13h 5m
English
Packt Publishing
Content preview from Learn Robotics Programming

Creating a behavior

We will make the pan and tilt head move in small circles of around 30 degrees. This behavior will demonstrate the mechanism and the parts of the code to talk to it. The code will create repeating animated kind of behavior. So, we will keep a time base—a current time. This allows us make our movement based on that. We will be using the time base to draw the circle.

Create a new file; I suggest the name circle_pan_tilt_behavior.py.

We will start with some imports; the Robot object, the math library, and some timing:

from time import sleepimport mathfrom robot import Robot

We prepare the math library as we are going to use sine and cosine to calculate that circle.

We'll make a frames_per_circle variable we can adjust to say ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn Robotics Programming - Second Edition

Learn Robotics Programming - Second Edition

Danny Staple

Publisher Resources

ISBN: 9781789340747Supplemental Content