This is an early video of Pi playing "catch" with a rolling ball. I
unwittingly stacked the cards against Pi on two accounts: (a) The ball
is too heavy, and (b) the ball is too hard and slippery. Subsequent
trials with a lighter and softer ball have resulted in many more
successful catches. When I get the time, I'll make an updated
video...

The basic principle here is simple: the sonar module on Pi's base
between the wheels measures the closing distance to the ball as it
rolls towards him. I then compute the speed of the ball from these
measurements and from the distance and speed, estimate a time of
collision. These measurements and calculations are all updated about
20 times per second. The arms begin to close at a time that
anticipates this time to collision so that the hands close onto the
ball and not before it arrives or after it passes through.