The C3 optimization solves for a vector stored as the internal class variable z_sol_, which contains the stacked vectors corresponding to x, u, lambda, (and for C3+ eta). While z_sol_ contains the most up-to-date values, the other class variables x_sol_, u_sol_, and lambda_sol_ do not always reflect these same values -- they are the same at the end of a call to C3::Solve(...) (as ensured by this call) only if the option end_on_qp_step is true (which otherwise updates the z_sol_ vector here without also updating the x_sol_, etc. vectors).
Given the intuitive outputs of C3 are the state and input (and possibly contact force) vectors accessible via the helpers GetStateSolution and GetInputSolution (and GetForceSolution), respectively, these x_sol_, u_sol_, and lambda_sol_ vectors should reflect the most updated values in z_sol_.
Proposed solution:
- Remove the class variables
x_sol_, u_sol_, and lambda_sol_.
- Edit the helper functions
GetStateSolution, GetInputSolution, and GetForceSolution to grab and return the relevant portions of the z_sol_ vector when called.
The C3 optimization solves for a vector stored as the internal class variable
z_sol_, which contains the stacked vectors corresponding tox,u,lambda, (and for C3+eta). Whilez_sol_contains the most up-to-date values, the other class variablesx_sol_,u_sol_, andlambda_sol_do not always reflect these same values -- they are the same at the end of a call toC3::Solve(...)(as ensured by this call) only if the optionend_on_qp_stepis true (which otherwise updates thez_sol_vector here without also updating thex_sol_, etc. vectors).Given the intuitive outputs of C3 are the state and input (and possibly contact force) vectors accessible via the helpers
GetStateSolutionandGetInputSolution(andGetForceSolution), respectively, thesex_sol_,u_sol_, andlambda_sol_vectors should reflect the most updated values inz_sol_.Proposed solution:
x_sol_,u_sol_, andlambda_sol_.GetStateSolution,GetInputSolution, andGetForceSolutionto grab and return the relevant portions of thez_sol_vector when called.