使用Visual Studio Code 开发ROS方法
前提条件:安装好了ROS(melotic) 和 VSCODE
1、vscode安装必要的插件
2、提前准备好一个ROS的catkin workspace
在workspace下面使用vscode打开
$ code .
打开之后,第一步安装的ROS插件就会自动识别到这个workspace,同时会出现一个文件夹.vscode
里面有两个json文件:
c_cpp_properties.json
settings.json
c_cpp_properties.json 主要是和头文件 ros/ros.h这种头文件包含有关系。
settings.json 暂时好像是和Python的自动补全有关系。
3、将catkin_make放到vscode里面编译
原来的方式是,在catkin_ws下使用catkin_make命令:如下
hou@hou-ThinkPad-P52s:~/catkin_ws$ catkin_make
Base path: /home/hou/catkin_ws
Source space: /home/hou/catkin_ws/src
Build space: /home/hou/catkin_ws/build
Devel space: /home/hou/catkin_ws/devel
Install space: /home/hou/catkin_ws/install
####
#### Running command: "cmake /home/hou/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/hou/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/hou/catkin_ws/install -G Unix Makefiles" in "/home/hou/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/hou/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/hou/catkin_ws/devel;/opt/ros/melodic
-- This workspace overlays: /home/hou/catkin_ws/devel;/opt/ros/melodic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.17", minimum required is "2")
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/hou/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/googletest': gtests will be built