VScode ROS文件相关配置

发布于:2025-08-20 ⋅ 阅读:(19) ⋅ 点赞:(0)
  • 相关插件推荐

在这里插入图片描述

  • 设置编译快捷键:ctral + shit + B 选择 catkin_make.build

  • 进行配置使不需要每次选择,而是进行 ctrol+shit+B 则自动编译。
{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "catkin_make",
			"args": [
				"--directory",
				"/home/lihongli/catkin_ws",
				"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
			],
			"problemMatcher": [
				"$catkin-gcc"
			],
			"group": "build",
			"label": "catkin_make: build"
		}
	]
}

在这里插入图片描述

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "catkin_make",
			"args": [
				"--directory",
				"/home/lihongli/catkin_ws",
				"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
			],
			"problemMatcher": [
				"$catkin-gcc"
			],
			"group": {"kind":"build","isDefault": true},
			"label": "catkin_make: build"
		}
	]
}

在这里插入图片描述
在这里插入图片描述

  • 如果源码文件包含的头文件报错,下划线波浪好,则将该文件删除,然后重启VScode,等待ros重新加载,随后该文件又出现就好了。
    在这里插入图片描述
  • 下载git开源代码:https://github.com/6-robot/wpr_simulation.git,网络连接不通,直接下载好压缩包,在对应文件目录中解压。随后通过脚本安装编译需要的依赖库。
  • 随后在catkin_ws 工作空间目录中运行catkin_make进行编译
lihongli@lhl:~/catkin_ws/src$ git clone https://github.com/6-robot/wpr_simulation.git
正克隆到 'wpr_simulation'...
fatal: 无法访问 'https://github.com/6-robot/wpr_simulation.git/':Failed to connect to github.com port 443: 连接超时
lihongli@lhl:~/catkin_ws/src$ ping github
ping: github: 域名解析暂时失败
lihongli@lhl:~/catkin_ws/src$ pwd
/home/lihongli/catkin_ws/src
lihongli@lhl:~/catkin_ws/src$ ls
CMakeLists.txt  test_pkg      workspace.zip
learning_topic  truck_ws.zip  wpr_simulation-master.zip
lihongli@lhl:~/catkin_ws/src$ unzip wpr_simulation-master.zip

在这里插入图片描述

  • 启动示例程序仿真端
ihongli@lhl:~/catkin_ws$ source ~/catkin_ws/devel/setup.bash     
lihongli@lhl:~/catkin_ws$ roslaunch wpr_simulation wpb_simple.launch
... logging to /home/lihongli/.ros/log/76f65c40-7cd7-11f0-ad7c-1be29ce82f48/roslaunch-lhl-23006.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt

  • 启动控制端
lihongli@lhl:~$ rosrun rqt_robot_steering rqt_robot_steering

在这里插入图片描述

  • 下载小海龟项目:下载、切换ros1版本、回工作空间编译。
  • 随后 roscore启动ros1,然后rosrun turtlesim turtlesim_node
    启动小乌龟。
lihongli@lhl:~/catkin_ws/src$ git clone https://github.com/ros/ros_tutorials.git
正克隆到 'ros_tutorials'...
remote: Enumerating objects: 3179, done.
remote: Counting objects: 100% (149/149), done.
remote: Compressing objects: 100% (66/66), done.
remote: Total 3179 (delta 106), reused 91 (delta 83), pack-reused 3030 (from 2)
接收对象中: 100% (3179/3179), 735.95 KiB | 502.00 KiB/s, 完成.
处理 delta 中: 100% (1921/1921), 完成.
lihongli@lhl:~/catkin_ws/src$ cd ros_tutorials/
lihongli@lhl:~/catkin_ws/src/ros_tutorials$ git che
checkout      cherry        cherry-pick   
lihongli@lhl:~/catkin_ws/src/ros_tutorials$ git checkout noetic-devel 
分支 'noetic-devel' 设置为跟踪来自 'origin' 的远程分支 'noetic-devel'。
切换到一个新分支 'noetic-devel'
lihongli@lhl:~/catkin_ws/src/ros_tutorials$ 
lihongli@lhl:~/catkin_ws$ catkin_make

在这里插入图片描述


网站公告

今日签到

点亮在社区的每一天
去签到