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.
trotbot_stationary.zip |
Here's a slightly more complicated version with TrotBot moving across the screen:
trotbot_moving.zip |
Here's the python code for simulating TrotBot, Klann, Strandbeest,and Strider that generated the video above (updated on 1-22-2024). 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
|
|
Finally, here's the python code for simulating Klann's Mechanical Spider (updated on 12-20-2018), which makes it easier to switch from Klann's patented linkage configuration to our LEGO approximation of Klann Ver 2.
|
|
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.