Search code examples
drake

Drake Mathematical Program Tutorial


I am running Drake on Ubuntu 20.04 using WSL2.
I use python3.8.10 and Drake1.2.0.
I tried running the "Mathematical Program Tutorial" obtained from deepnote on my PC, but the behavior of the ipopt solver is unnatural and does not give the expected results.

The 1st error is occurred in the section using ipopt solver.
All components of the solution is printed as "nan"

The 2nd error is below about "get_solver_details().status"

RuntimeError: The solver_details has not been set yet.

I can see both errors in "Demo on manually choosing a solver" in the tutorial. The result is following

SolutionResult.kUnknownError
x* =  [nan nan]
Solver is  IPOPT
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-12-2d1b3835c54a> in <module>
     25 print("x* = ", result.GetSolution(x))
     26 print("Solver is ", result.get_solver_id().name())
---> 27 print("Ipopt solver status: ", result.get_solver_details().status,
 28       ", meaning ", result.get_solver_details().ConvertStatusToString())

RuntimeError: The solver_details has not been set yet.

Thank you in advance.


P.S. I installed pydrake for venv by pip commands

python3 -m venv env
env/bin/pip install --upgrade pip
env/bin/pip install drake
sudo apt-get install --no-install-recommends \
  libpython3.8 libx11-6 libsm6 libxt6 libglib2.0-0
source env/bin/activate

I just download the folder "Tutorial" from deepnote and put it under env.

Then, I run it by Jupyter Notebook as

jupyter notebook

and open env/Tutorials/mathematical_program.ipynb


Solution

  • It turns out that the pip drake == 1.2.0 version has a bug in the IpoptSolver compilation.

    As a work-around, you can use SnoptSolver instead, or else use the https://drake.mit.edu/from_binary.html release (unpacking a zipped binary, instead of using pip).