How to Build a Claude Shannon Juggling Machine - video and instructions here:…

Search posts
Forum index

 

Scott Seltzer -

How to Build a Claude Shannon Juggling Machine - video and instructions here: https://www.instructables.com/id/How-to-Build-a-Claude-Shannon-Juggling-Machine/

Building is not my thing, but it was still interesting to watch and hear about his learning process and how he experimented and adjusted to make the corrections needed to get it reliable.

Stephen Meschke - - Parent

I built a Claude Shannon Juggling Machine. Instead of using physical objects, I built this machine virtually. This physics simulation is written in Python 3. The UI and some of the functions use the computer vision software library OpenCV. Like Scott said in the original post, the fun of this device is not in building it. The interesting part is tuning the device so that it juggles.

This program is object-oriented. The balls are the objects. Each ball object has two attributes, (1) a tuple to describe the ball's (x,y) coordinates, and (2) a tuple to describe the ball's velocity vector (speed and direction).

Several functions allow the ball to interact with the environment. These functions move the ball, apply gravity, bounce the ball off an object, etc... In the main loop of the program, all of these functions are called on the balls to produce juggling.

The machine is tuned by adjusting the parameters. The parameters are defined before running the program, or changed during runtime using the keyboard. The most important parameters are speed and rotation. Each number of balls requires a specific combination of speed and rotation to juggle. This graph shows the combinations of speed and rotation that work for 3, 5, 7, 9, and 11 balls.

To find these values, I tuned the machine during runtime. It was tedious to tune the machine, and I am searching for a way to mathematically derive the parameters that will produce juggling for n number of balls. Is there a formula that relates the number of balls and the combination of speed and rotation?

Please try this out for yourself: Link to Code on Github

Video: Link to video on juggling.tv

Link to Gifs: Gifs on Imgur

Kelhoon - - Parent

sounds like a job for linear regression

Stephen Meschke - - Parent

I can use linear regression to predict values that will work for 13 balls, using the known solutions for 3,5,7,9, and 11 balls. I'd like a way to compute a solution for n-number of balls that does not involve using experimental data.

david - - Parent

Very nice simulation, thanks for sharing it.

I did some simple spreadsheeting on your results. While the speed and rotation are roughly linearly related (R2 = 0.98) the speed is better correlated with the log of the number of balls (R2 = 0.99 for a log fit and 0.93 for a linear fit).

It might be that you could get better correlations by slightly adjusting your speed and rotation estimates. How do you decide what are the best parameters for each number of balls? Can you get it to juggle for all the different balls with a forced perfect linear relationship between speed and rotation?

I didn’t see any reference to masses in your code. I think that implies the paddle and the floor effectively have infinite mass and don’t move due to the balls hitting them. It might be simpler to see the underlying physics if the collisions were perfectly elastic. It could help me to know the units of time, distance and gravity to try to relate it to Newtonian physics.

Stephen Meschke - - Parent

Thank you.

I found these parameters by trial and error. The program allows me to adjust the parameters during runtime. I ran the program and manually adjusted the parameters until the machine achieved juggling. The parameters that I found are not optimal, but the best that I could do. Tuning this machine is difficult because changing one variable effects the whole system.

The machine will juggle if the parameters are in the correct range. For example, the optimum speed for 5 balls is 0.0148, but all values between 0.014 and 0.016 are valid for juggling. The ball will hit the middle of the paddle when the parameters are optimized.

There are no masses in my code, which by the way is not quite an accurate physics simulation. Here is some more info about the units:

  • Time: The time is based of the total rotation and the motor speed. For five ball juggling, the total rotation is 1.004 (0.502 radians * 2 - up and down). The motor speed is 0.0148 radians/tick. That means the period of the paddle is 1.004 / 0.0148 = 67.8 ticks.
  • Distance: Everything is in pixels. The paddles are 660 pixels apart.
  • Gravity: The gravity is a constant 0.069. To make the gravity affect the balls, I add the ball's velocity vector with the gravity vector: angle, speed = addVectors((angle, speed), gravity_vector)

When the balls bounce off the floor, they return with 75% of the energy. This makes juggling easier. Because the balls loose energy in the bounce, they can be thrown at the top of the stroke and caught at the bottom of the stroke. This helps avoid collisions.

When the balls are released from the paddle, they are released with the same velocity vector as the nearest part of the paddle.

 

Subscribe to this forum via RSS
1 article per branch
1 article per post

Forum stats