Smooth Servo Motion For Lifelike Animatronics

Danie Conradie



Smooth Servo Motion For Lifelike Animatronics

Building an animatronic robot is one thing, but animating it in a lifelike fashion is a completely different challenge. Hobby servos are cheap and popular for animatronics, but just letting it move at max speed isn’t particularly lifelike. In the video after the break, [James Bruton] demonstrates how to achieve natural motion with a simple animatronic head and a few extra lines of code.

Very little natural body movement happens at a constant speed, it’s always accelerating or decelerating. When we move our heads to look at something around us, our neck muscles accelerate our head sharply in the chosen direction and then slows down gradually as it reaches its endpoint. To do this in Arduino/C code, a new intermediate position for the servo is specified for each main loop until it reaches the final position. The intermediate value is the sum of 95% of the current position, and 5% of the target position. This gives the effect of the natural motion described above. The ratios can be changed to suit the desired speed.

The delay function is usually one of the first timing mechanisms that new Arduino programmers learn about, but it’s not suited for this application, especially when you’re controlling multiple servos simultaneously. Instead, the millis function is used to keep track of the system clock in the main loop, which fires the position update commands at the specified intervals. Adafruit wrote an excellent tutorial on this method of multitasking, which [James] based his code on. Of course, this should be old news to anyone who has been doing embedded programming for a while, but it’s an excellent introduction for newcomers.

Like most of [James]’s projects, all the code and CAD files are open source and available on GitHub. His projects make regular appearances here on Hackaday, like his mono-wheel balancing robot and mechanically multiplexed flip-dot display.

Continue Reading

Loading data