0

This piece of example code: ''' import numpy as np import pydrake.solvers.mathematicalprogram as mp from pydrake.solvers.ipopt import IpoptSolver def foo(x): return np.sign(x)

prog = mp.MathematicalProgram()
x = prog.NewContinuousVariables(1)
prog.AddConstraint(foo, [1.], [1.], vars=x)
prog.AddLinearCost(1 * x[0])
result = mp.Solve(prog, np.array([10.]), None)
print(result.is_success())
print(result.GetSolution(x))

''' returns the error: Segmentation fault (core dumped), when I run it under termial opened by the jupyter notebook, provided by the course: http://underactuated.csail.mit.edu/Spring2019/install_drake_docker.html. (while the code itself already proved right here,https://github.com/RobotLocomotion/drake/issues/12410)

N.Li
  • 47
  • 7

1 Answers1

0

With docker image drake-20190129, this code cannot run. Specifically the line mp.Solve(prog, np.array([10.]), None) is problematic. Back then Drake doesn't support this function. You will need to replace this line with result = prog.Solve().

And after replacing the line, my kernel dies.

I wouldn't recommend using the docker drake-20190129 for your code. Specifically the line prog.AddConstraint(foo, [1.], [1.], vars=x) was not supported back then (2019, Jan, 29). I normally use the most up-to-date version of drake, as explained in https://drake.mit.edu/python_bindings.html

Hongkai Dai
  • 2,546
  • 11
  • 12
  • Yes, not supported even in version 20190423. btw, you finally reproduce my fault :) – N.Li Dec 04 '19 at 04:17
  • FWIW We have nightly docker images published that have Drake code: https://hub.docker.com/r/robotlocomotion/drake/tags However, this will not have the underactuated class materials. – Eric Cousineau Dec 05 '19 at 18:15