Acados issues in Pycharm

Hi :wave:

I‘m using Python interface of acados.

The environment I use is Ubuntu 22.04, Python 3.9, Pycharm Community Edition.
I successfully ran the minimal_example_ocp.py program of acados in the Ubuntu terminal, but I get an error when I configure the same environment and run the same code in pycharm.

Code  (Ubuntu terminal)
(base) k@k-Lenovo:~$ source home/k/tum-control-venv/bin/activate
(tum-control-venv) (base) k@k-Lenovo:~$ python /home/k/acados/examples/acados_python/getting_started/minimal_example_ocp.py

WARNING: Gauss-Newton Hessian approximation with EXTERNAL cost type not well defined!
got cost_type EXTERNAL for cost_type_e, hessian_approx: 'GAUSS_NEWTON'.
With this setting, acados will proceed computing the exact Hessian for the cost term and no Hessian contribution from constraints and dynamics.
If the external cost is a linear least squares cost, this coincides with the Gauss-Newton Hessian.
Note: There is also the option to use the external cost module with a numerical Hessian approximation (see `ext_cost_num_hess`).
OR the option to provide a symbolic custom Hessian approximation (see `cost_expr_ext_cost_custom_hess`).

rm -f libacados_ocp_solver_pendulum_ode.so
rm -f pendulum_ode_cost/pendulum_ode_cost_y_0_fun.o pendulum_ode_cost/pendulum_ode_cost_y_0_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_0_hess.o pendulum_ode_cost/pendulum_ode_cost_y_fun.o pendulum_ode_cost/pendulum_ode_cost_y_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_hess.o pendulum_ode_cost/pendulum_ode_cost_y_e_fun.o pendulum_ode_cost/pendulum_ode_cost_y_e_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_e_hess.o acados_solver_pendulum_ode.o
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_0_fun.o pendulum_ode_cost/pendulum_ode_cost_y_0_fun.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_0_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_0_fun_jac_ut_xt.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_0_hess.o pendulum_ode_cost/pendulum_ode_cost_y_0_hess.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_fun.o pendulum_ode_cost/pendulum_ode_cost_y_fun.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_fun_jac_ut_xt.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_hess.o pendulum_ode_cost/pendulum_ode_cost_y_hess.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_e_fun.o pendulum_ode_cost/pendulum_ode_cost_y_e_fun.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_e_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_e_fun_jac_ut_xt.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_e_hess.o pendulum_ode_cost/pendulum_ode_cost_y_e_hess.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o acados_solver_pendulum_ode.o acados_solver_pendulum_ode.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_model/pendulum_ode_impl_dae_fun.o pendulum_ode_model/pendulum_ode_impl_dae_fun.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_z.o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_z.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_u_z.o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_u_z.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_u.o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_u.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_model/pendulum_ode_impl_dae_jac_x_xdot_u_z.o pendulum_ode_model/pendulum_ode_impl_dae_jac_x_xdot_u_z.c
cc -shared pendulum_ode_cost/pendulum_ode_cost_y_0_fun.o pendulum_ode_cost/pendulum_ode_cost_y_0_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_0_hess.o pendulum_ode_cost/pendulum_ode_cost_y_fun.o pendulum_ode_cost/pendulum_ode_cost_y_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_hess.o pendulum_ode_cost/pendulum_ode_cost_y_e_fun.o pendulum_ode_cost/pendulum_ode_cost_y_e_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_e_hess.o acados_solver_pendulum_ode.o pendulum_ode_model/pendulum_ode_impl_dae_fun.o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_z.o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_u_z.o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_u.o pendulum_ode_model/pendulum_ode_impl_dae_jac_x_xdot_u_z.o -o libacados_ocp_solver_pendulum_ode.so -L/home/k/acados/lib -lacados -lhpipm -lblasfeo -lm  \
-L -l
acados was compiled without OpenMP.

iter	res_stat	res_eq		res_ineq	res_comp	qp_statqp_iter	alpha
0	6.283185e+03	8.259477e-17	0.000000e+00	0.000000e+00	0	00.000000e+00	
1	4.157952e+03	3.287960e+00	0.000000e+00	4.872276e-14	0	71.000000e+00	
2	1.075826e+03	3.853160e+00	0.000000e+00	7.587925e+01	0	27	4.900000e-01	
3	7.297345e+02	4.596882e+00	1.421085e-14	6.792801e-12	0	12	1.000000e+00	
4	7.830690e+02	1.008541e+01	0.000000e+00	5.807888e-10	0	22	1.000000e+00	
5	2.742341e+02	8.222071e-01	0.000000e+00	8.033253e-11	0	21	1.000000e+00	
6	2.061598e+01	1.014569e-02	0.000000e+00	8.528716e-08	0	31.000000e+00	
7	1.068400e-01	4.453771e-05	0.000000e+00	6.941675e-08	0	31.000000e+00	
8	1.435036e-03	2.790096e-08	0.000000e+00	9.821706e-10	0	31.000000e+00	
9	2.216659e-05	7.440659e-12	0.000000e+00	1.094352e-09	0	31.000000e+00	
10	3.862291e-07	3.552714e-15	0.000000e+00	1.092658e-09	0	31.000000e+00

But in Pycharm, there are some bugs.

Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.

WARNING: Gauss-Newton Hessian approximation with EXTERNAL cost type not well defined!
got cost_type EXTERNAL for cost_type_e, hessian_approx: 'GAUSS_NEWTON'.
With this setting, acados will proceed computing the exact Hessian for the cost term and no Hessian contribution from constraints and dynamics.
If the external cost is a linear least squares cost, this coincides with the Gauss-Newton Hessian.
Note: There is also the option to use the external cost module with a numerical Hessian approximation (see `ext_cost_num_hess`).
OR the option to provide a symbolic custom Hessian approximation (see `cost_expr_ext_cost_custom_hess`).

Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
Warning: Did not find environment variable ACADOS_SOURCE_DIR, guessed ACADOS_PATH to be /home/k/acados.
Please export ACADOS_SOURCE_DIR to avoid this warning.
rm -f libacados_ocp_solver_pendulum_ode.so
rm -f pendulum_ode_cost/pendulum_ode_cost_y_0_fun.o pendulum_ode_cost/pendulum_ode_cost_y_0_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_0_hess.o pendulum_ode_cost/pendulum_ode_cost_y_fun.o pendulum_ode_cost/pendulum_ode_cost_y_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_hess.o pendulum_ode_cost/pendulum_ode_cost_y_e_fun.o pendulum_ode_cost/pendulum_ode_cost_y_e_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_e_hess.o acados_solver_pendulum_ode.o
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_0_fun.o pendulum_ode_cost/pendulum_ode_cost_y_0_fun.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_0_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_0_fun_jac_ut_xt.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_0_hess.o pendulum_ode_cost/pendulum_ode_cost_y_0_hess.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_fun.o pendulum_ode_cost/pendulum_ode_cost_y_fun.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_fun_jac_ut_xt.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_hess.o pendulum_ode_cost/pendulum_ode_cost_y_hess.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_e_fun.o pendulum_ode_cost/pendulum_ode_cost_y_e_fun.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_e_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_e_fun_jac_ut_xt.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_cost/pendulum_ode_cost_y_e_hess.o pendulum_ode_cost/pendulum_ode_cost_y_e_hess.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o acados_solver_pendulum_ode.o acados_solver_pendulum_ode.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_model/pendulum_ode_impl_dae_fun.o pendulum_ode_model/pendulum_ode_impl_dae_fun.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_z.o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_z.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_u_z.o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_u_z.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_u.o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_u.c
cc -fPIC -std=c99   -O2 -I/home/k/acados/include -I/home/k/acados/include/acados -I/home/k/acados/include/blasfeo/include -I/home/k/acados/include/hpipm/include  -c -o pendulum_ode_model/pendulum_ode_impl_dae_jac_x_xdot_u_z.o pendulum_ode_model/pendulum_ode_impl_dae_jac_x_xdot_u_z.c
cc -shared pendulum_ode_cost/pendulum_ode_cost_y_0_fun.o pendulum_ode_cost/pendulum_ode_cost_y_0_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_0_hess.o pendulum_ode_cost/pendulum_ode_cost_y_fun.o pendulum_ode_cost/pendulum_ode_cost_y_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_hess.o pendulum_ode_cost/pendulum_ode_cost_y_e_fun.o pendulum_ode_cost/pendulum_ode_cost_y_e_fun_jac_ut_xt.o pendulum_ode_cost/pendulum_ode_cost_y_e_hess.o acados_solver_pendulum_ode.o pendulum_ode_model/pendulum_ode_impl_dae_fun.o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_z.o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_u_z.o pendulum_ode_model/pendulum_ode_impl_dae_fun_jac_x_xdot_u.o pendulum_ode_model/pendulum_ode_impl_dae_jac_x_xdot_u_z.o -o libacados_ocp_solver_pendulum_ode.so -L/home/k/acados/lib -lacados -lhpipm -lblasfeo -lm  \
-L -l
Traceback (most recent call last):
  File "/home/k/snap/pycharm-community-2022.1.4/plugins/python-ce/helpers/pydev/pydevd.py", line 1491, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/k/snap/pycharm-community-2022.1.4/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/k/acados/examples/acados_python/getting_started/minimal_example_ocp.py", line 109, in <module>
    main()
  File "/home/k/acados/examples/acados_python/getting_started/minimal_example_ocp.py", line 88, in main
    ocp_solver = AcadosOcpSolver(ocp)
  File "/home/k/acados/interfaces/acados_template/acados_template/acados_ocp_solver.py", line 239, in __init__
    self.__acados_lib = get_shared_lib(libacados_filepath, self.winmode)
  File "/home/k/acados/interfaces/acados_template/acados_template/utils.py", line 130, in get_shared_lib
    shared_lib = DllLoader(shared_lib_name)
  File "/home/k/anaconda3/lib/python3.9/ctypes/__init__.py", line 382, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libqpOASES_e.so: cannot open shared object file: No such file or directory
python-BaseException
Backend tkagg is interactive backend. Turning interactive mode on.
Process finished with exit code 130 (interrupted by signal 2: SIGINT)

settings in pycharm:

I wish someone could help me, thank you very much. :pray:

Not an expert at all on pycharm, but the problem seems to be this one:
libqpOASES_e.so: cannot open shared object file

Which QP solver are you using? In the minimal example, the QP solver should be set to HPIPM. If you change it to qpOASES you need to ensure that acados is compiled with the flag -DACADOS_WITH_QPOASES=ON.

Best, Katrin