Giter VIP home page Giter VIP logo

ros-note's Introduction

ROS-note

使ros的python功能在python3下也可以运行

import cv2的问题

结合了这个博客这个问题,成功实现了rospy在Python3下的使用. 首先应该已经安装好基于Python2的ROS,按照官网的wiki教程安装想要的版本即可。 然后利用pip3安装ROS的Python包:

sudo apt-get install python3-pip python3-yaml
sudo pip3 install rospkg catkin_pkg

经过这个操作之后import rospy之类的应该都没有问题了,但是cv_bridge仍然无法正常使用,需要利用Python3重新编译。 先查看一下自己的Python3版本ls /usr/include/,找一下类似python3.5m的文件夹。 然后按照以下步骤重新编译一个cv_bridge,先用Python3创建一个工作空间:

mkdir cv_bridge_python3
cd cv_bridge_python3
catkin init
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
catkin config --install

其中-DPYTHON_INCLUDE_DIR-DPYTHON_LIBRARY要按照实际情况修改。接下来在工作空间中:

mkdir src
cd src
git clone https://github.com/ros-perception/vision_opencv.git
cd ..
catkin build cv_bridge

如果没出错的话基于Python3的cv_bridge就编译好了。 要使当前的ROS程序使用这个包的话,在cv_bridge_python3下,source install/setup.bash --extend即可。 这个编译好的文件夹可以直接保存好,移动到其他工作空间。

运行Python脚本时不要忘记使用python3 ...

import tf的问题

最详细的讨论在这里,但是用了里面的方法在ubuntu16.04与18.04下都无效,最后使用ros论坛上这个贴子提供的方法,在ubuntu18.04,ros melodic下成功使用python3.6 import tf。 其他可能还有些问题,但还没有遇到。

ros-note's People

Contributors

youkenhou avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.