A control method that executes a numerical non-linear optimization procedure with forward simulation of the full dynamics of the bipedal robot (including ground collisions) to compute a foothold, which produces the desired center of mass velocity during the next step of the walking cycle. The controller includes a gait generator that outputs desired joint trajectories designed to track a desired foothold provided by the foot placement algorithm. A torque calculator is included to output desired joint torques designed to track the desired joint trajectories provided by the gait generator. Additionally, the controller includes an actuator controller that produces the desired joint torques determined by the torque calculator at each joint on the physical robot, which may be a legged robot with torque-controlled joints. The foot placement algorithm may use nonlinear optimization that is solvable using a mathematical model of the dynamics of the controlled robot.