The robot can balance given angle measurements from an on-board IMU sensor, which feeds into a control algorithm that actuates the wheel motors to keep the robot at a stabilizing reference angle.
The robot's wheels have encoders which feed into a control algorithm and allow one wheel to tack and follow the position of the reference wheel. Also, the tracking wheel resists changes to its position when disturbed.