You can use all of them (encoders, accelerometers, compasses, gyros - in order of drift), but you'll need to write a closed control loop. Take a look at Admin's PID control tutorial. If you decide to use accelerometers, be aware they have integral drift - correction with a gyro is the best way to avoid it, using a Kalman filter. Then you'll have an IMU (inertial measurement unit)