Animating Linkages with Scratch
Here's a video of TrotBot simulated in Scratch, and an embedded simulator is below.
If you look at the Scratch code you'll see that the linkage's bars aren't sprites nor are they a series of images like the frames of a movie since this wouldn't allow the bar lengths to be changed while running the code. Instead, they are drawn with Scratch's pen, using the dimensions you set with the slider bars, and the pen's lines are erased and re-drawn each time an arrow key is pressed. The same goes for the red dots of the joints and the foot-paths that we added to some linkages, like the images of Strider below.
If you want to graph a linkage's foot-path or horizontal foot-speed, then open the project on MIT's site, click "see inside" and follow the steps in the images below. Note: you can access joint and bar maps by pressing "1" or "2" on your keyboard.
If you want to graph a linkage's foot-path or horizontal foot-speed, then open the project on MIT's site, click "see inside" and follow the steps in the images below. Note: you can access joint and bar maps by pressing "1" or "2" on your keyboard.
The horizontal speed of the feet when in contact with the ground can be calculated every 5 degrees of crank rotation as follows:
Foot-Speed (crank at x degrees) = Foot's X position(crank at x degrees) - Foot's X position(crank at x-5 degrees)
For an easier linkage simulation in Scratch check out the 4-Bar Linkage.
Below is the embedded simulator which is started by clicking the green flag. You can also run them on MIT's site where you can modify the Scratch code.
After changing a bar's length, click somewhere other than a slider bar and then press the space bar to see the new linkage and foot-path, and use your keyboard's left/right arrows to rotate the crank.
Foot-Speed (crank at x degrees) = Foot's X position(crank at x degrees) - Foot's X position(crank at x-5 degrees)
For an easier linkage simulation in Scratch check out the 4-Bar Linkage.
Below is the embedded simulator which is started by clicking the green flag. You can also run them on MIT's site where you can modify the Scratch code.
After changing a bar's length, click somewhere other than a slider bar and then press the space bar to see the new linkage and foot-path, and use your keyboard's left/right arrows to rotate the crank.
The algorithms, and how we used them to simulate linkages, are described here. Scratch is also made for creating games, so here's TrotBot Goalie. To play, click the green flag below to load TrotBot and launch the balls you need to block. Press left arrow to walk left, right arrow to walk right, "z" to jump left, "x" to jump right. |
|
For other Scratch coding examples check out the games below (not linkage related).
Halo Elite Sword fight
Gold Elite: D - walk right, A - walk left, W - Jump, S - swing sword, X - duck
Red Elite: 6 - walk right, 4 - walk left, 8 - Jump, 5 - swing sword, 2 - duck
Asteroid Belter
Avoid asteroids with the keyboard's arrows (up,down, left and right). The spaceship steers via Newton's 3rd law (like planes and rockets), where a force perpendicular to the rocket's direction causes it to slowly accelerate in the direction of the force, and the turn will continue accelerating if the arrow key is held down.
Asteroid Belter
Avoid asteroids with the keyboard's arrows (up,down, left and right). The spaceship steers via Newton's 3rd law (like planes and rockets), where a force perpendicular to the rocket's direction causes it to slowly accelerate in the direction of the force, and the turn will continue accelerating if the arrow key is held down.
Gravity Pong
Left Player: A moves paddle down, Q moves paddle up
Right Player: control paddle with up/down arrows
Modify the game by adjusting the force of Gravity, and the Level of difficulty.
Halo 3D Tanks
Left Tank:
Left hand for moving tank: w=in, s=out, a=left, d=right
Right hand for shooting: y=gun up, g=gun down, j,k,l fires 1 shell each
Right Tank:
Left hand for moving tank with 4 arrow keys
Right hand for shooting: 8=gun up, 4=gun down, 9,6,3 fires 1 shell each
Left Tank:
Left hand for moving tank: w=in, s=out, a=left, d=right
Right hand for shooting: y=gun up, g=gun down, j,k,l fires 1 shell each
Right Tank:
Left hand for moving tank with 4 arrow keys
Right hand for shooting: 8=gun up, 4=gun down, 9,6,3 fires 1 shell each