The main objective of this article is to optimize the walking pattern of a 2D humanoid robot with heel-off and toe-off motions in order to minimize the energy consumption and maximize the stability margin. To this end, at first, a gait planning method is introduced based on the ankle and hip joint position trajectories. Then, using these trajectories and the inverse kinematics, the position tra...