i7 2.7-GHz processor. The BVP method run-time on Example 3 is missing since the algorithm failed to terminate.[]{data-label="fig:cpu_time"}](cpu_time_comparison_compressed.pdf){width="\columnwidth"}

      Alg.     $J$     $s_1$    $s_2$    Itr.   FC.
  -- ------ --------- -------- -------- ------ -----
      BVP    5.4498    0.2235   1.0198    9     13
      OCS2   5.4438    0.2324   1.0236    7     14
      BVP    10.3797   0.2754   1.6076    9     13
      OCS2   10.3888   0.2973   1.5978    8     20

  : Comparison between the performance of the BVP and OCS2 algorithms. In the table Itr. is the number of iterations in the gradient-descent method until it converges. FC. is the number of requests for cost function and its derivative evaluation in the gradient-descent algorithm.[]{data-label="tab:performance"}

#### Example 3: Quadruped’s CoM motion control {#example-3-quadrupeds-com-motion-control .unnumbered}

In this example, we apply OCS2 to the quadruped’s CoM control problem. In a quadruped robot, based on the stance legs configuration the system shows different dynamical behavior. Furthermore, at the switching instances the non-elastic nature of contacts introduces a jump in the state trajectory. Therefore, basically a legged robot have to be modeled as a nonlinear hybrid system with discontinuous state trajectory.

The computational burden of solving the optimal control problem on such a nonlinear and hybrid system has encouraged researchers to use CoM dynamics instead of the complete system dynamics. 