Experiments with the Apple Motion Sensor
Throw your PowerBook off a cliff. As it tumbles, sensors will detect changes in orientation and gravitational force. With this data, your PowerBook will wisely ascertain that all is not well. Faster than you can knock a laptop off a desk, it will swing the hard drive's head away from the platter and park it, preventing a deadly collision with your data.
The "Sudden Motion Sensor" in Apple's latest PowerBooks implements this technology. The sensors are not built into the hard drive - they're an integral part of the system, compatible with any drive you install. It's even possible to read the sensor output yourself. Amit Singh has written several programs that do just that.
This is where the fun starts. amstracker is a simple command-line utility that returns the values for the sensors' x, y, and z axes. X is left/right tilt, y is forward/back, and z is the change in G force. Amit's utility can output these values and then exit or can be configured to provide a continuous stream of data.
The trick with a cool utility like this is coming up with a practical application. One possibility is to keep a motion log. Here's a sample in which data was collected every tenth of a second. To produce these values, I let my PowerBook drop about eight inches and then gently caught it.
[pre] X Y Z
3 27 49
1 26 51
2 24 53
4 28 49
2 31 49
2 27 53
9 8 16
-6 8 16
9 47 82
11 28 46
5 18 67
-1 22 55
-2 24 51
1 23 49
-1 23 51[/pre]
The first indication that something has gone wrong is a major the change in G force from 53 to 16. At the same time, the Y axis shifts from 27 to 8, indicating a sudden backwards tilt, caused by the weight of the display. A tenth of a second later, the logs indicate a rightward tilt as the X axis changes from 9 to -6. Another tenth of a second - and impact. The G force leaps from 16 to 82 as the PowerBook collides with my hands.
If you often lend your computer out, this data could make for some very interesting conversations. "Larry, why did my PowerBook experience a sudden spike in gravitational force at 6:43 PM?"
The numbers are fun, but a visual makes for a more interesting demo. Amit has done just this with AMSVisualizer, which displays a PowerBook on-screen and tilts it in sync with the computer's actual movements. This is great for demoing the PowerBook to potential customers.
Amit has written one more entertaining demo: StableWindow. You can tilt your PowerBook any way you like, but this window refuses to tilt with it. Those interested in reading more about these programs and the technology behind them should visit Amit Singh's website.
Of course, we haven't even addressed one of the most obvious uses for motion sensors: games. It took Peter Berglund just four days after reading Amit's article to have a simple game working based on the motion sensors. Berglund's BubbleGym gives the player a marble on a board. Tilting the computer tilts the board and causes the marble to roll. The objective is to roll the ball into the cloud. With each success, a new cloud appears and the allotted time grows shorter. The player has four balls (i.e. lives) and each one exhibits different physical characteristics. Graphics and gameplay are rudimentary, but as a technology demonstration, the game is excellent. BubbleGym is mildly fun to play and a lot of fun to share with others.
Where will Apple's motion-sensing technology go from here? A more convenient tool for logging data might also be useful and hopefully an adaptation of the arcade game Neverball will soon be in the works. Post your ideas below.