ros-industrial / universal_robot

ROS-Industrial Universal Robots support (https://wiki.ros.org/universal_robot)
1.08k stars 1.03k forks source link

Unable to use ur_kin_py in Python 3.6 #461

Open hemanthsarabu opened 4 years ago

hemanthsarabu commented 4 years ago

I am trying to build and run ur_kin_py for a python 3 catkin workspace but have not been successful so far. I followed instructions from here, and replaced the line in the CMake file from find_package(PythonLibs 2.7 REQUIRED) to find_package(PythonLibs 3.6 REQUIRED) and ran catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so.

When I then try to runtest_analytical_ik.py , I get : Segmentation fault (core dumped) And when I try to run import ur_kinematics.ur_kin_py.inverse in a python session, I see ImportError: /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.65.1: undefined symbol: PyClass_Type . I suspect I am building the library against boost for python 2 and not 3 and I'm not sure how to fix that. Has anyone dealt with this before?

Any help would be greatly appreciated!

Thanks!

chinakwy commented 4 years ago

I'm stuck at this problem :( , did you fix it? hopefully can get some help Thanks!

tungkw commented 3 years ago

when I met the first problem Segmentation fault (core dumped), what I do is changing the path related to 'pyconfig.h'. In my case is from "/usr/include/python2.7/" to "/usr/include/python3.6/". And I edit the 'ur_kin_py.cpp' from

#include <boost/numpy.hpp>
#include <boost/scoped_array.hpp>
#include <boost/scoped_array.hpp>

namespace p = boost::python;
namespace np = boost::numpy;

to

#include <boost/python.hpp>
#include <boost/python/numpy.hpp>

namespace p = boost::python;
namespace np = boost::python::numpy;

For the second problem, I think it would be good to try somethings like -lboost_python3 -lboost_numpy3 when linking in cmake file.

dhled commented 2 years ago

Please assign this to me :)

gavanderhoorn commented 2 years ago

While you're at it, you may want to take a look at https://github.com/ros-industrial/universal_robot/projects/1 as well.

There may be PRs there which affect this issue.

dhled commented 2 years ago

So building using pybind as suggested in #453 seems to solve all python3 problems. I have tested on Python3.6 and 3.8, it seems to work fine.

The only problem is to fix the test_analytical_ik.py for python3 compatibility.

So how we should proceed ? I can try to fix/rebase the PR #453 and python3 compitibility but this might break other IK related PR.

gavanderhoorn commented 2 years ago

Would you have an idea of how many of those PRs would get into trouble? All of them?

dhled commented 2 years ago

This one #459 and maybe #358 (which combine 3 PR)

gavanderhoorn commented 2 years ago

What about getting those merged first?

Would that be an option?

dhled commented 2 years ago

Yes for #358.

For #459 it's pretty much useless if we merge #453 (or the rebased / updated version)

gavanderhoorn commented 2 years ago

I'd be ok with merging #358 into melodic-devel-staging.

The rest of the IK related PRs should then also go into that branch.

Could you 'review' #358 and post a thumbs up there?

(you did test it, didn't you ? ;) )