ROS配置中cv_bridge

ROS配置中cv_bridge

安装步骤

1.安装依赖

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

2.环境准备及安装

# Create catkin workspace
mkdir catkin_workspace
cd catkin_workspace
catkin init
# Instruct catkin to set cmake variables
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
# Instruct catkin to install built packages into install place. It is $CATKIN_WORKSPACE/install folder
catkin config --install
# Clone cv_bridge src
git clone https://github.com/ros-perception/vision_opencv.git src/vision_opencv
# Find version of cv_bridge in your repository
apt-cache show ros-melodic-cv-bridge | grep Version
    Version: 1.12.8-0xenial-20180416-143935-0800
# Checkout right version in git repo. In our case it is 1.12.8
cd src/vision_opencv/
git checkout 1.12.8
cd ../../
# Build
catkin build cv_bridge
# Extend environment with new package
source install/setup.bash --extend

其他详细

1.set cmake variables 以下是jetson nano下的配置,其他系统架构此处需要改动

  • -DPYTHON_INCLUDE_DIR = /usr/include/python3.6m

  • -DPYTHON_LIBRARY = /usr/lib/aarch64-linux-gnu/libpython3.6m.so

2.opencv4.x版本的解决方案

  • 使用以下我克隆的项目,分支是opencv4
  • git clone https://gitee.com/chendda/vision_opencv.git -b opencv4 src/vision_opencv
  • 切记:git checkout 1.12.8 这里不再切换分支

3.pip3 与 pip catkin-tools冲突

错误内容
Exception ignored in: <bound method BaseEventLoop.del of <_UnixSelectorEventLoop running=False closed=True debug=False>>

解决方案

  • pip3 freeze | grep catkin-tools

如果有输出则pip3 卸载掉catkin-tools

4.import_array 错误

 warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
     import_array( );
     ^

解决方案

添加 build 中添加 -DPYTHON3=On 参数

  • catkin build -DPYTHON3=On cv_bridge

你可能感兴趣的:(ROS机器人,python,opencv,linux)