Animation Scheduling Algorithms
The Animator part of ToonFace uses a multi-threaded scheduling algorithm to simulate parallel execution of motors.
The main loop has a constant, loop-time, which determines the number of animation frames per second. The value
for this constant should be equal to the maximum time the main loop could ever take to execute one loop. In the
current implementation this constant is set to 100 ms, giving a fixed rate of 10 animation frames per second. When
a command to move multiple motors is received, the total time this action is supposed to take is divided into looptime
slices. Since all motors are independent from each other, separate slices are made for each motor. So for a
close-left-eye command (i.e. control point Elu) of a 500 ms duration, 5 slices would be made for the left eye, each
slice to be executed on each main-loop. If the eye is fully open when the command is initially recieved, the eye will
be 20% closer to being fully closed on each loop, and fully closed when the last slice has been executed. If a
command for closing both eyes in 500 ms were to be given, a total of 10 slices would initially be produced and each
time through main loop one slice for the left eyelid and one slice for the right eyelid would be executed, bringing
both eyes to a close in 500 ms. If all pending slices have been executed before the 100 ms loop-time constant has
been reached, the program waits the remaining time, thus guaranteeing a constant loop time.