jrl-umi3218 / RBDyn

RBDyn provides a set of classes and functions to model the dynamics of rigid body systems.
BSD 2-Clause "Simplified" License
163 stars 47 forks source link

Cannot import rbdyn in python #52

Closed OsamaMazhar closed 6 years ago

OsamaMazhar commented 6 years ago

I am trying to install RBDYN library so I can run the tutorials in python. Following is my system configuration:

Dell Alienware Area 51 Desktop Ubuntu 16.04 LTS cmake version 3.5.1 doxygen version 1.8.11 gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609 Cython version 0.28.5 libboost1.58-dev:amd64

define EIGEN_WORLD_VERSION 3

define EIGEN_MAJOR_VERSION 2

define EIGEN_MINOR_VERSION 92

SpaceVecAlg Installed Python 3.5.2

I have installed cython using pip3 install command. After completing the installation, when I import rbdyn I get the following error:

Traceback (most recent call last): File "", line 1, in File "/home/username/Programs/RBDyn/binding/python/rbdyn/init.py", line 1, in from .rbdyn import * ImportError: /home/username/Programs/RBDyn/binding/python/rbdyn/rbdyn.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _ZN3rbd15InverseDynamics25sInverseDynamicsNoInertiaERKNS_9MultiBodyERNS_15MultiBodyConfigE

Please help.

gergondet commented 6 years ago

Hi Osama,

I've tried on my system (with a similar configuration) and I don't have this issue.

How did you build the bindings?

For Python 3, the correct procedure would be:

  1. pip3 install . in Eigen3ToPython
  2. Use the PYTHON_BINDING_FORCE_PYTHON3 option in SpaceVecAlg and RBDyn (the later I just pushed a few minutes ago) or run python3 setup.py build_ext --inplace and pip3 install . in SpaceVecAlg/bindings/python and RBDyn/bindings/python folder. You might want to use python3 setup.py build_ext --inplace --force to make sure the module is properly rebuild
OsamaMazhar commented 6 years ago

Hi gerdondet,

Thanks for your quick reply. I manually deleted rbdyn files as follows:

sudo rm -Rf /usr/local/lib/python3.5/dist-packages/rbdyn-1.0.0_79cacd9-py3.5-linux-x86_64.egg/

Then I ran the setup.py as you advised and the output is as follows:

osama@osama-Alienware-Area-51-R2:/Programs/SpaceVecAlg/binding/python$ python3 setup.py build_ext --inplace --force

/home/osama/.local/lib/python3.5/site-packages/setuptools/dist.py:407: UserWarning: The version specified ('1.0.0-b18e913') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details. "details." % self.metadata.version running build_ext building 'sva.sva' extension x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/osama/Programs/SpaceVecAlg/_build -I/home/osama/Programs/SpaceVecAlg/_build/include -I/home/osama/Programs/SpaceVecAlg/include -I/usr/local/include/eigen3 -I/home/osama/Programs/SpaceVecAlg/src -I/home/osama/Programs/SpaceVecAlg/binding/python/include -I/home/osama/.local/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -c sva/sva.cpp -o build/temp.linux-x86_64-3.5/sva/sva.o -std=c++11 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ In file included from /home/osama/.local/lib/python3.5/site-packages/numpy/core/include/numpy/ndarraytypes.h:1816:0, from /home/osama/.local/lib/python3.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:18, from /home/osama/.local/lib/python3.5/site-packages/numpy/core/include/numpy/arrayobject.h:4, from sva/sva.cpp:611: /home/osama/.local/lib/python3.5/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

warning "Using deprecated NumPy API, disable it by " \

^ x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.5/sva/sva.o -o build/lib.linux-x86_64-3.5/sva/sva.cpython-35m-x86_64-linux-gnu.so copying build/lib.linux-x86_64-3.5/sva/sva.cpython-35m-x86_64-linux-gnu.so -> sva

osama@osama-Alienware-Area-51-R2:/Programs/SpaceVecAlg/binding/python$ pip3 install .

Processing /home/osama/Programs/SpaceVecAlg/binding/python Installing collected packages: sva Running setup.py install for sva ... done Successfully installed sva-1.0.0-b18e913 You are using pip version 8.1.1, however version 18.0 is available. You should consider upgrading via the 'pip install --upgrade pip' command.

Same for rbdyn:

osama@osama-Alienware-Area-51-R2:/Programs/RBDyn/binding/python$ python3 setup.py build_ext --inplace --force /home/osama/.local/lib/python3.5/site-packages/setuptools/dist.py:407: UserWarning: The version specified ('1.0.0-79cacd9') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details. "details." % self.metadata.version running build_ext building 'rbdyn.rbdyn' extension x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/osama/Programs/RBDyn/_build -I/home/osama/Programs/RBDyn/_build/include -I/home/osama/Programs/RBDyn/include -I/usr/local/include/eigen3 -I/home/osama/Programs/RBDyn/src -I/usr/local/include/eigen3 -I/home/osama/Programs/RBDyn/binding/python/include -I/home/osama/.local/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -c rbdyn/rbdyn.cpp -o build/temp.linux-x86_64-3.5/rbdyn/rbdyn.o -std=c++11 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ In file included from /home/osama/.local/lib/python3.5/site-packages/numpy/core/include/numpy/ndarraytypes.h:1816:0, from /home/osama/.local/lib/python3.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:18, from /home/osama/.local/lib/python3.5/site-packages/numpy/core/include/numpy/arrayobject.h:4, from rbdyn/rbdyn.cpp:618: /home/osama/.local/lib/python3.5/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

warning "Using deprecated NumPy API, disable it by " \

^ rbdyn/rbdyn.cpp: In function ‘PyObject __pyx_pf_5rbdyn_5rbdyn_15MultiBodyVector_6getitem(__pyx_obj_5rbdyn_5rbdyn_MultiBodyVector, int)’: rbdyn/rbdyn.cpp:17093:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] pyx_t_1 = ((pyx_v_idx < pyx_v_self->v->size()) != 0); ^ rbdyn/rbdyn.cpp: In function ‘PyObject* pyx_pf_5rbdyn_5rbdyn_21MultiBodyConfigVector_6getitem(pyx_obj_5rbdyn_5rbdyn_MultiBodyConfigVector*, int)’: rbdyn/rbdyn.cpp:24761:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] pyx_t_1 = ((pyx_v_idx < pyx_v_self->v->size()) != 0); ^ rbdyn/rbdyn.cpp: In function ‘int __pyx_pf_5rbdyn_5rbdyn_21MultiBodyConfigVector_8setitem(pyx_obj_5rbdyn_5rbdyn_MultiBodyConfigVector*, int, pyx_obj_5rbdyn_5rbdyn_MultiBodyConfig*)’: rbdyn/rbdyn.cpp:24875:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] pyx_t_1 = ((pyx_v_idx < __pyx_v_self->v->size()) != 0); ^ x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.5/rbdyn/rbdyn.o -L/home/osama/Programs/RBDyn/_build/src -lRBDyn -o build/lib.linux-x86_64-3.5/rbdyn/rbdyn.cpython-35m-x86_64-linux-gnu.so copying build/lib.linux-x86_64-3.5/rbdyn/rbdyn.cpython-35m-x86_64-linux-gnu.so -> rbdyn osama@osama-Alienware-Area-51-R2:/Programs/RBDyn/binding/python$ pip3 install . Processing /home/osama/Programs/RBDyn/binding/python Installing collected packages: rbdyn Running setup.py install for rbdyn ... done Successfully installed rbdyn-1.0.0-79cacd9 You are using pip version 8.1.1, however version 18.0 is available. You should consider upgrading via the 'pip install --upgrade pip' command.

But when I import rbdyn in python3, I get the same error as I shown in the first post.

Please excuse my beginner skills, I am not a software expert but I can follow guides.

gergondet commented 6 years ago

Did you install the latest version of RBDyn?

Do you have multiple versions of RBDyn installed on your system ?

Run: ˋˋˋ sudo updatedb locate libRBDyn.so ˋˋˋ

OsamaMazhar commented 6 years ago

Yes, I updated the repo and then installed before posting the previous comment.

I don't think I have multiple versions installed.

Here is output of locate command after updatedb:

osama@osama-Alienware-Area-51-R2:~$ locate libRBDyn.so /home/osama/Programs/RBDyn/_build/src/libRBDyn.so /home/osama/Programs/RBDyn/_build/src/libRBDyn.so.0 /home/osama/Programs/RBDyn/_build/src/libRBDyn.so.0.9.0 /usr/lib/libRBDyn.so /usr/lib/libRBDyn.so.0 /usr/lib/libRBDyn.so.0.9.0

gergondet commented 6 years ago

Did you set CMAKE_INSTALL_PREFIX to /usr? Otherwise I’m guessing you have the binary packages installed. They have not been updated recently so that would cause the problem you are having.

You can:

Then it should work.

OsamaMazhar commented 6 years ago

It works :+1: Thank you very much!