Animating Linkages with Python
....and Matplotlib's Animation Function
Sam Korman from Team TrotBot put his Python skills to work to improve our simulators, and shares his code below. For those who are not that experienced with Python, Sam included many useful comments in his code.
First, here's Sam's simplest script that animates TrotBot in place.
Here's a slightly more complicated version with TrotBot moving across the screen:
Here's the python code for simulating TrotBot, Klann, Strandbeest,and Strider that generated the video above (updated on 1-17-2019). You can find the joint and bar maps for each mechanism on its Linkage Optimizer page. Note: this code was copy/pasted from 4 separate sims, so it's a bit sloppy and is not as streamlined as Sam's code, FYI
In the below video of our LEGO approximation, Klann's linkage was animated in place by setting the "moving" variable to "False" (or you can simply set its average speed to zero). Also, you can find the joint and bar maps used in this Klann simulator here, which the python script now matches.
The algorithms, and how we used them to simulate linkages, are described here.