To do leveling you will want to use the accelerometer not the Gyro.
The accelerometer has an x,y and z axis that detect acceleration.
If you robot is not moving the largest acceleration detected will be gravity.
If you orientate the accelerometer so the z axis is exactly perpendicular to the floor it will read a value and the x and y values will be close to zero.
When the accelerometer is tilted the x and y axis will increase and the z will decrease.
Using trigonometry and physics you can figure out the angle of tilt and send motor commands to level the platform.
There is an example of using accelerometers to get you started.