Adaptible inverted pendulum on 2-axis

Has anybody developed an inverted pendulum code for Arduino? I am thinking of having a go at Sageway type of thing?