本文介绍了使用ROS Kinetic和Python3忽略cmake参数构建cv_bridge软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将ROS软件包集成到我们的系统中以进行研究项目,并且需要cv_bridge软件包和python3才能使该软件包正常工作.尽管有多个步骤,目前我无法在python3中构建cv_bridge包,但仍在python2目录中不断构建.

I'm trying to integrate a ROS package into our system for a research project and the cv_bridge package and python3 is needed in order to get the package working. Currently I can't get the cv_bridge package to build in python3 despite multiple steps, constantly builds in python2 directory.

在具有ROS动力学的Ubuntu 16.04中工作.使用python3.5

Working in Ubuntu 16.04 with ROS kinetic. Using python3.5

错误消息:

[ERROR] [1563897986.999724]: bad callback: <function color_callback at 0x7f00ffa06598>
Traceback (most recent call last):
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
  File "/home/rival/Documents/Repos/ROS/src/rcnn_apple_detector/detection.py", line 84, in color_callback
image = bridge.imgmsg_to_cv2(image_msg, "bgr8")
  File "/home/rival/Documents/Repos/ROS/src/vision_opencv/cv_bridge/python/cv_bridge/core.py", line 163, in imgmsg_to_cv2
dtype, n_channels = self.encoding_to_dtype_with_channels(img_msg.encoding)
  File "/home/rival/Documents/Repos/ROS/src/vision_opencv/cv_bridge/python/cv_bridge/core.py", line 99, in encoding_to_dtype_with_channels
return self.cvtype2_to_dtype_with_channels(self.encoding_to_cvtype2(encoding))
  File "/home/rival/Documents/Repos/ROS/src/vision_opencv/cv_bridge/python/cv_bridge/core.py", line 91, in encoding_to_cvtype2
from cv_bridge.boost.cv_bridge_boost import getCvType
ImportError: dynamic module does not define module export function (PyInit_cv_bridge_boost)

我已经尝试了上一个问题的答案中的步骤:

I've tried the steps in this previous question's answer:

无法与ROS Kinetic和Python3一起使用cv_bridge

您可以通过传递-DPYTHON_EXECUTABLE =/usr/bin/python3来实现-DPYTHON_INCLUDE_DIR =/usr/include/python3.5m -DPYTHON_LIBRARY =/usr/lib/x86_64-linux-gnu/libpython3.5m.so args固定.或者,如果您使用柳絮来构建软件包,则可以执行下一步步骤:"

You can do it with passing -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.5m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so args to cmake. Or, if you are using catkin to build packages, you can do next steps:"

步骤的唯一变化是我必须使用catkin_make,因为我使用的一堆旧软件包的问题目前不适用于catkin build.我不知道那是不是导致它.但是我将cmake参数传递到我的工作区中,但它仍然以ROS python2目录为目标.

The only variations to the steps is I have to use catkin_make because issues with a bunch of older packages I'm using aren't currently working with catkin build. I don't know if that is causing it or not. But I pass the cmake arguments into my workspace and still it targets to the ROS python2 directory.

位置cv_bridge当前仍在构建中:

Location cv_bridge is currently still being built:

/opt/ros/kinetic/lib/python2.7/dist-packages

版本:

apt-cache show ros-kinetic-cv-bridge | grep Version
Version: 1.12.8-0xenial-20190320-142632-0800

catkin配置:

-------------------------------------------------------------------------------------------------------------------------------------------------
Profile:                     default
Extending:             [env] /home/rival/Documents/Repos/ROS/devel:/opt/ros/kinetic
Workspace:                   /home/rival/Documents/Repos/ROS
---------------------------------------------------------------------------------------------------------------------------------------------------
Build Space:        [exists] /home/rival/Documents/Repos/ROS/build
Devel Space:        [exists] /home/rival/Documents/Repos/ROS/devel
Install Space:     [missing] /home/rival/Documents/Repos/ROS/install
Log Space:         [missing] /home/rival/Documents/Repos/ROS/logs
Source Space:       [exists] /home/rival/Documents/Repos/ROS/src
DESTDIR:            [unused] None
---------------------------------------------------------------------------------------------------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        merged
---------------------------------------------------------------------------------------------------------------------------------------------------
Additional CMake Args:       -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.5m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
---------------------------------------------------------------------------------------------------------------------------------------------------
Whitelisted Packages:        None
Blacklisted Packages:        None
---------------------------------------------------------------------------------------------------------------------------------------------------
Workspace configuration appears valid.

已采取的确切步骤:

sudo apt-get install python-catkin-tools python3-dev python3-catkin-pkg-modules python3-numpy python3-yaml ros-kinetic-cv-bridge

catkin clean

catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.5m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so

cd src/vision_opencv/
git checkout 1.12.8

catkin_make cv_bridge

source devel/setup.bash --extend

我希望cv_bridge可以使用cmake参数构建,但是它仍然可以重新定位到python2目录中.似乎cmake args被忽略/定位不正确.

I expect cv_bridge to be built with the cmake arguments but it still gets targeted back into the python2 directory. It seems the cmake args are being ignored/not targeting correctly.

推荐答案

我遵循了博客文章.

基本上,您需要创建一个新的catkin工作区,以使其配置不会与您原来的(python2)工作区混淆.

Essentially you need to create new catkin workspace so that its configuration doesn't mess with your original (python2) workspace.

  1. 安装python3和依赖项.我喜欢使用不带sudo的-user 来使解决依赖关系冲突变得容易一些.

  1. Install python3 and dependencies. I like using --user without sudo to make resolving dependency conflicts a little easier.

sudo apt-get install python-catkin-tools python3-dev python3-numpy 
sudo apt-get install python3-pip python3-yaml
pip3 install rospkg catkin_pkg --user

  • 创建一个新的工作区

  • Make a new workspace

    mkdir py3_catkin_ws
    cd py3_catkin_ws
    mkdir src
    

  • 已配置python3的初始化catkin(使用您的python3x版本)

  • Init catkin with python3 configured (use your python3x version)

    catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so
    catkin config --install
    

  • 克隆和 catkin构建 vision_opencv 在新的工作区中.照常继续.Python3现在应该能够找到 cv_bridge .博客文章建议 source install/setup.bash --extend ,但这对我而言不是必需的.

  • Clone and catkin build vision_opencv in your new workspace. Continue as usual. Python3 should now be able to locate cv_bridge. The blog post suggests to source install/setup.bash --extend but it wasn't necessary in my case.

    这篇关于使用ROS Kinetic和Python3忽略cmake参数构建cv_bridge软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 10-19 05:51