玩命加载中 . . .

VS Code运行ROS


ROS初始化

sudo vim /etc/hosts
185.199.108.133 raw.githubusercontent.com
sudo vim /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
url="https://ghproxy.com/"+url

sudo vim /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
DEFAULT_INDEX_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'

VS Code for ROS

新建工作空间和功能包

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
cd ..
catkin_make
cd src
catkin_create_pkg <功能包名称> std_msgs rospy roscpp

添加json文件

添加c_cpp_properties.json,找到ROS头文件目录

{
  "configurations": [
    {
      "browse": {
        "databaseFilename": "",
        "limitSymbolsToIncludedHeaders": true
      },
      "includePath": [
        "${catkin_ws}/devel/include/**",
        "/opt/ros/melodic/include/**",
        "/usr/include/**"
      ],
      "name": "ROS"
    }
  ],
  "version": 4
}

添加settings.json文件,找到python

{
    "python.autoComplete.extraPaths": [
        "${catkin_ws}/devel/lib/python2.7/dist-packages",
        "/opt/ros/melodic/lib/python2.7/dist-packages"
    ],
    "python.analysis.extraPaths": [
        "${catkin_ws}/devel/lib/python2.7/dist-packages",
        "/opt/ros/melodic/lib/python2.7/dist-packages"
    ],
    "files.associations": {
        "iostream": "cpp"
    }
}

编译cv_bridge

sudo apt-get install python-catkin-tools python3-dev python3-catkin-pkg-modules python3-numpy python3-yaml ros-melodic-cv-bridge
mkdir -p catkin_ws/src
cd catkin_ws
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
git clone https://github.com/ros-perception/vision_opencv.git src/vision_opencv
apt-cache show ros-melodic-cv-bridge | grep Version
cd src/vision_opencv/
git checkout 1.13.0
cd ../../
catkin build 或者 catkin build cv_bridge
source ~/catkin_ws/devel/setup.zsh --extend 
# --extend 参数的作用是让这次的路径配置不影响之前配置好的路径,否则这一次source会覆盖掉之前配置的路径。

文章作者: kunpeng
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 kunpeng !
  目录