0
 drake::solvers::SolverOptions options;
    options.SetOption(drake::solvers::**?**, "verbose", {0, 1});   //{0,1} for verbose, {0,0} for no verbosity
    const auto result = Solve(ik.prog(), {}, options);
    const auto q_sol = result.GetSolution(ik.q());

What do I set the SolverId to for solving the Inverse Kinematics nlp problem?

skywalker
  • 9
  • 1

1 Answers1

0

You have two options here:

  1. Set the option for the specific solver you use. You can know which solver is invoked by checking the result
    std::cout << result.get_solver_id().name() << "\n";
    
    if it prints "IPOPT", then you can do options.SetOption(drake::solvers::IpoptSolver::id(), ...).
  2. Another (and better) solution is to set the common solver options
    options.SetOption(CommonSolverOption::kPrintToConsole, 1);
    
    which will print the output information to the console for any solver that supports console printing. You can also do options.SetOption(CommonSolverOption::kPrintFileName, "output.txt") which will print the output to output.txt file.
Hongkai Dai
  • 2,546
  • 11
  • 12
  • `drake::solvers::SolverOptions options; options.SetOption(drake::solvers::CommonSolverOption::kPrintToConsole, 1); const auto result = Solve(ik.prog(), {}, options);` Does not display anything in the console. Am I missing something? My [IK Formulation](https://stackoverflow.com/questions/69590113/how-to-set-up-ik-trajectory-optimization-in-drake-toolbox) – skywalker Oct 15 '21 at 21:01
  • ```std::cout << result.get_solver_id().name() << "\n";``` gives me: `SNOPT/fortran` in the terminal. – skywalker Oct 15 '21 at 21:27
  • Since you are using SNOPT, which doesn't support print to console. You should set `kPrintToFile` option. – Hongkai Dai Oct 15 '21 at 23:32