An analytical approach for generating balanced gaits of a biped robot on stairs and sloping surfaces