Balancing on the Bridge

What is the code for balancing the robot on the bridge? (For C++)

There is no canned solution. We implement a servo that use a gyro and just moves slowly into position.