Search code examples
roboticsdrake

How to set SolverId when setting verbosity in IK solver options in Drake toolbox?


 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?


Solution

  • 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.