What is the Animation API?

This chapter's title leads to a lot of questions—what is the Animation API and how does it relate to servos? There's also a lot of terminology used here. To start, let's discuss the point and development of the Animation API to give us a little context.

Why do we need an Animation API?

The Animation API was created around the work started by Donovan Buck and Rick Waldron on walking robots—Rick built a quadruped bot, and Donovan, a Hexapod. Turns out, walking robots require a lot of timing on the servos involved, and the Johnny-Five library at the time was only capable of running servos from one degree to another at a maximum speed. This made walking very difficult, because even with servos of the same brand and make, the maximum speed is slightly different. Also, there are situations in which you want different servos to move at different speeds—this was impossible before the Animation API as well.

This led to the development of a function that allows you to set the speed of a given movement by giving a time to complete—we explored these functions in the previous section. You can also set a number of discreet movements. While these definitely helped with walking robotics code, there's another huge benefit to this API, and this is why the name might seem strange.

Why animation?

An animation is a description of movements over time. Keyframes are used in animations to set key positions at given times—there are several animation libraries that will calculate the frames in-between these keyframes, called tweening. The Animation API in Johnny-Five allows you to set keyframes for a servo movement and then does the tweening for you—allowing you to programmatically define a set of movements over time, just as the definition of animation states.

This is great for moving robotics—calculating the speed for each servo in a leg that is moving to a specific point would be daunting for even the most skilled programmer. The Animation API's ability to do tweening for us means that we can set the keyframes and let the code do the rest. This means that even beginners in moving robotics can create complex movements.

Now that we have some context, let's take a bird's-eye view of the Animation API and the various ways to describe and interact with it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.61.119