do you want to make a "segway"?
in this post I posted a tutorial about your problem viewtopic.php?f=1&t=647
you can start with using a pseudointegrator instead of a simple integrator. But if you you use a motor you will have some more complications.
If you like send me a PM and I will give more details.