Braitenberg Vehicles – v1.0

For our Braitenberg Vehicles project, we were to create Braitenberg's first four cars. The basic idea behind these vehicles is that each vehicle has a set of sensors and motors. The sensors cause the motors to move: either speed up or slow down. By connecting different sensors to different motors, you can cause the cars to have different movements.





Math: Math!!

Although I usually start with the visual side of these projects, this time I wanted to first figure out how the vehicles would move on-screen.

Getting Around
The first car, Getting Around, was pretty simple. The light intensity, taken from the sensor, directly correlates to the y-position of the car. At this point, I threw together some basic graphics using the handy-dandy StdDraw library and a few JPEGs. You can see the final Getting Around car to the right.

Implementing two motors and sensors, however, was much more challenging. At first, I was trying to calculate the distance each motor would travel with a bunch of geometry. Needless to say, that didn't get me very far. I decided to opt for the much simpler option of having the car travel forward, and the angle that it travels at varies. Now, I could easily take the difference of the intensities from the two sensors and multiply that by a constant to get the angle that the car should change.

Problems with Power

So, all seemed good until I got up and unplugged my computer. Suddenly, all of the vehicles slowed down! At first, I couldn't figure out what was causing the slowdown. However, with the help of my teacher, we figured out that my computer went into power-saving mode when I unplugged it. Disproving my belief that all modern computers are insanely powerful, I had to figure out how to make the game run at the same speed no matter how fast the computer was.

To do so, I changed the "speed" of the car to pixels/millisecond. Then, when updating the vehicles' distance, I did so by multiplying it by the time since the last update. This was simple enough, and it only required saving the time at each update for future reference.

Comments

Popular updates

Half Moon Project Part 2 - More Accuracy

NumberVision – Machine Learning Application

Machine Learning & Half Moon Project