A c++ novice here! The verbose in the terminal output says the problem is solved successfully, but I am not able to access the solution. What is the problem with the last line?
drake::solvers::MathematicalProgram prog;
auto x = prog.NewContinuousVariables(n_x);
// Cost and Constraints
drake::solvers::MathematicalProgramResult result;
drake::solvers::OsqpSolver osqp_solver;
if (osqp_solver.available()) {
// Setting solver options.
for (int print_to_console : {0, 0}) { //{0,1} for verbose, {0,0} for no terminal output
drake::solvers::SolverOptions options;
options.SetOption(drake::solvers::OsqpSolver::id(), "verbose", print_to_console);
osqp_solver.Solve(prog, {}, options);
}
}
const auto u = result.GetSolution(x);
Another question is that what if I don't wanna choose OSQP and let Drake decide which solver to use for the QP, how can I do this?