— This paper proposes an optimal gait generation framework using virtual constraint and learning optimal control. In this method, firstly, we add a constraint by a virtual potential energy to prevent the robot from falling. Secondly, we execute iterative learning control (ILC) to generate an optimal feedforward input. Thirdly, we execute iterative feedback tuning (IFT) to mitigate the strength of the virtual constraint automatically according to the progress of learning control. Consequently, it is expected to generate an optimal gait without constraint eventually. Although existing ILC frameworks require a lot of experimental data under the same initial condition, the proposed method does not need to repeat experiments under the same initial condition because the virtual constraint restricts the motion of the robot to a symmetric trajectory. Furthermore, it does not require the precise knowledge of the plant system. Finally, some numerical simulations demonstrate the effectiveness ...