orocos / orocos_kinematics_dynamics

Orocos Kinematics and Dynamics C++ library
671 stars 407 forks source link

Failed to build python_orocos_kdl #464

Open alemiu opened 2 months ago

alemiu commented 2 months ago

I want to use tf_conversion in a venv but it returns me the error ModuleNotFoundError: No module named 'PyKDL':

from tf_conversions import transformations

File "/opt/ros/noetic/lib/python3/dist-packages/tf_conversions/__init__.py", line 30, in <module>
    from .posemath import *
  File "/opt/ros/noetic/lib/python3/dist-packages/tf_conversions/posemath.py", line 34, in <module>
    from PyKDL import *
ModuleNotFoundError: No module named 'PyKDL'

Then I have followed your instructions to install orocos_kdl and python_orocos_kdl but when doing the catkin make (or catkin build) I get this error:

=> make -j4 -l4 in '/home/alemiu/DLO_ws/build_isolated/python_orocos_kdl'
Scanning dependencies of target PyKDL
[ 16%] Building CXX object CMakeFiles/PyKDL.dir/PyKDL/PyKDL.cpp.o
[ 33%] Building CXX object CMakeFiles/PyKDL.dir/PyKDL/frames.cpp.o
[ 66%] Building CXX object CMakeFiles/PyKDL.dir/PyKDL/framevel.cpp.o
[ 66%] Building CXX object CMakeFiles/PyKDL.dir/PyKDL/kinfam.cpp.o
/home/alemiu/DLO_ws/src/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/frames.cpp: In function ‘void init_frames(pybind11::module&)’:
/home/alemiu/DLO_ws/src/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/frames.cpp:80:29: error: could not convert ‘pybind11::detail::self’ from ‘const pybind11::detail::self_t’ to ‘pybind11::handle’
   80 |     vector.def(py::hash(py::self));
      |                         ~~~~^~~~
      |                             |
      |                             const pybind11::detail::self_t
/home/alemiu/DLO_ws/src/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/frames.cpp:167:29: error: could not convert ‘pybind11::detail::self’ from ‘const pybind11::detail::self_t’ to ‘pybind11::handle’
  167 |     wrench.def(py::hash(py::self));
      |                         ~~~~^~~~
      |                             |
      |                             const pybind11::detail::self_t
/home/alemiu/DLO_ws/src/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/frames.cpp:242:28: error: could not convert ‘pybind11::detail::self’ from ‘const pybind11::detail::self_t’ to ‘pybind11::handle’
  242 |     twist.def(py::hash(py::self));
      |                        ~~~~^~~~
      |                            |
      |                            const pybind11::detail::self_t
/home/alemiu/DLO_ws/src/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/framevel.cpp: In function ‘void init_framevel(pybind11::module&)’:
/home/alemiu/DLO_ws/src/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/framevel.cpp:65:33: error: could not convert ‘pybind11::detail::self’ from ‘const pybind11::detail::self_t’ to ‘pybind11::handle’
   65 |     double_vel.def(py::hash(py::self));
      |                             ~~~~^~~~
      |                                 |
      |                                 const pybind11::detail::self_t
/home/alemiu/DLO_ws/src/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/frames.cpp:375:31: error: could not convert ‘pybind11::detail::self’ from ‘const pybind11::detail::self_t’ to ‘pybind11::handle’
  375 |     rotation.def(py::hash(py::self));
      |                           ~~~~^~~~
      |                               |
      |                               const pybind11::detail::self_t
/home/alemiu/DLO_ws/src/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/framevel.cpp:135:33: error: could not convert ‘pybind11::detail::self’ from ‘const pybind11::detail::self_t’ to ‘pybind11::handle’
  135 |     vector_vel.def(py::hash(py::self));
      |                             ~~~~^~~~
      |                                 |
      |                                 const pybind11::detail::self_t
/home/alemiu/DLO_ws/src/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/frames.cpp:457:28: error: could not convert ‘pybind11::detail::self’ from ‘const pybind11::detail::self_t’ to ‘pybind11::handle’
  457 |     frame.def(py::hash(py::self));
      |                        ~~~~^~~~
      |                            |
      |                            const pybind11::detail::self_t
/home/alemiu/DLO_ws/src/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/framevel.cpp:221:32: error: could not convert ‘pybind11::detail::self’ from ‘const pybind11::detail::self_t’ to ‘pybind11::handle’
  221 |     twist_vel.def(py::hash(py::self));
      |                            ~~~~^~~~
      |                                |
      |                                const pybind11::detail::self_t
/home/alemiu/DLO_ws/src/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/framevel.cpp:310:35: error: could not convert ‘pybind11::detail::self’ from ‘const pybind11::detail::self_t’ to ‘pybind11::handle’
  310 |     rotation_vel.def(py::hash(py::self));
      |                               ~~~~^~~~
      |                                   |
      |                                   const pybind11::detail::self_t
/home/alemiu/DLO_ws/src/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/framevel.cpp:384:32: error: could not convert ‘pybind11::detail::self’ from ‘const pybind11::detail::self_t’ to ‘pybind11::handle’
  384 |     frame_vel.def(py::hash(py::self));
      |                            ~~~~^~~~
      |                                |
      |                                const pybind11::detail::self_t
[ 83%] Building CXX object CMakeFiles/PyKDL.dir/PyKDL/dynamics.cpp.o
make[2]: *** [CMakeFiles/PyKDL.dir/build.make:76: CMakeFiles/PyKDL.dir/PyKDL/frames.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/PyKDL.dir/build.make:102: CMakeFiles/PyKDL.dir/PyKDL/framevel.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:276: CMakeFiles/PyKDL.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
<== Failed to process package 'python_orocos_kdl': 
  Command '['/home/alemiu/DLO_ws/devel_isolated/orocos_kdl/env.sh', 'make', '-j4', '-l4']' returned non-zero exit status 2.

Reproduce this error by running:
==> cd /home/alemiu/DLO_ws/build_isolated/python_orocos_kdl && /home/alemiu/DLO_ws/devel_isolated/orocos_kdl/env.sh make -j4 -l4

Command failed, exiting.

And I do not managed to find any other solution on the net. Can someone help me?

MatthijsBurgh commented 2 months ago

You probably have a system installed version of pybind11 on your machine. See https://github.com/orocos/orocos_kinematics_dynamics/issues/416 and https://github.com/orocos/orocos_kinematics_dynamics/issues/401

You need pybind11>2.6, CMake should find the correct one since https://github.com/orocos/orocos_kinematics_dynamics/pull/430. But I don't know on which commit you are.

alemiu commented 2 months ago

Thank you for your quick answer. On my system I had installed Pybind11 2.12, after reading your answer I have uninstalled it and then done catkin build --force-make but the same error on python_orocos_kdl appears. Now if I check the installed version I get:

pip show Pybind11
/usr/bin/pip:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pkg_resources import load_entry_point
Name: pybind11
Version: 2.4.3
Summary: Seamless operability between C++11 and Python
Home-page: https://github.com/pybind/pybind11
Author: Wenzel Jakob
Author-email: wenzel.jakob@epfl.ch
License: BSD
Location: /usr/lib/python3/dist-packages
Requires: 
Required-by: 

I'm building on master branch and last commit 1197 of 10th June 2024 ( if this is what you meant)

MatthijsBurgh commented 2 months ago

So there is still another version of pybind11 installed on your system. Which is too old. CMake should not use it, as it doesn't match the version requirements. So hopefully that is the case.

When you cloned the repo, did you also initialize the submodule? As we include pybind11 as submodule.

MatthijsBurgh commented 2 months ago

It doesn't detect pip installed versions of pybind11, see https://github.com/orocos/orocos_kinematics_dynamics/actions/runs/9512645544

It does detect apt installed versions of pybind11, see https://github.com/orocos/orocos_kinematics_dynamics/actions/runs/9512728029

The last one also shows the CMake version requirement does work.