November 2018
Beginner
472 pages
13h 5m
English
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 ...