Fishes flocking fun with JavaScript

This spring I was working on a “ocean themed” site taking the user on a journey to the great depths of the North Sea. And of course, in every ocean there needs to be
fish happily swimming in flocks. So I started doing some research into flocking, and with some experience from creating particle systems, the first prototype was done in in a day.

See the Pen Fish flocking simulation by Pål Smitt-Amundsen (@gadgetgnome) on CodePen.

The basics of flocking is that one fish tries to find a buddy to follow, one that it can see in a sector relative to it’s swimming direction. Once a buddy is found, it tries to follow as best it can, limited by its max speed among other properties.

To see who a fish is following, hold the shift-button on your keyboard. Red lines will point out the leader, also green lines will display the “negative force field” that the mouse cursor is to the fishes. The are just really scared of the cursor, trying to avoid it the best they can.

Feel free to peek into the code using the link below, there are some comments that should explain the basics. I wrote the code from scratch with a JS “class” for a Fish, making it easy to instantiate a thousand of them with the “new” operator. The particle system is drawn on a canvas, drawing the fish from a bitmap with correct rotation and position from its “particle” properties.

Go ahead, visit CodePen:

Automatic brakes on bumper cars!

Late summer I was lucky enough to participate in a build project we did for our client Volkswagen. The idea was illustrating their automatic braking system by creating a similar system for bumper cars, filming people driving them unbeknownst of our modification. Take a look at the result here:

And if you are interested in how created this, check out the “behind the scenes” video with Knut explaining the basics of the setup.

The brake system was powered by pneumatics, so several large dive tanks was needed to keep the smaller bottles refilled the whole recording day. This picture was taken after, with the brake system parts all back in boxes after restoring the bumper cars to their normal brake-less setup.
Dive tanks and parts

The parts for each cars setup, hidden under the seat for a surprising effect (from L to R):

  • Small “pony bottle” diving tank
  • Pressure regulators
  • Blue Festo air tubes (awesomeness with quick-release!)
  • Computer box with battery, Raspberry PI and Arduino interfacing the ultrasonic sensor-array and sending the the data to the server via the tailor made SW.
  • Massive relay to withstand the big current drawn by the car
  • Festo solenoid electromagnetic air valve to feed air into the brake valves.

Car brake parts

The feeling of just holding one of these beautiful Festo cylinders cannot be described with words, the build quality is unbelievable. We used two in each car, each capable of lifting 178KG (1750 Newtons) at 10 bars!
By the power of Festo!

All in all I’m in awe of the design and production that Knut and Morten did, mostly just contributing to the electro mechanic part myself.