ROS 機器人技術(shù) - 編寫一個 launch 啟動多個節(jié)點

登龍
這是我的第 141?篇原創(chuàng)
1. 增加 source 到 bashrc 中
為了不用在小車的 Ubuntu 上每次都 source 自己的工作空間,我把自己的 workspace 加到 ~/.bashrc 文件末尾:

然后重啟 shell,之后就會自動 source 我得工作空間,可以使用 roscd 直接進入指定包中:
roscd?pkg_name
2. 編寫啟動 launch
每次調(diào)試小車,都要分別啟動很多節(jié)點,比如融合、建圖、Loam、Rviz 等,所以我把這些節(jié)點全部配置在一個 launch 中啟動,直接一行命令啟動,這樣調(diào)試就方便多了,大大節(jié)省時間:
lidar_camera_fusion\launch:lidar_camera_fusion.launchoctomap_server\rviz:octomap_debug.rvizoctomap_server\launch:dlonng_octomap_test.launch
<launch>
??
??<include?file?=?"$(find?zed_cpu_ros)/launch/zed_cpu_ros.launch"?/>
??
??<include?file?=?"$(find?rslidar_pointcloud)/launch/rs_lidar_16.launch"?/>
??
??<include?file?=?"$(find?lidar_camera_fusion)/launch/lidar_camera_fusion.launch"?/>
??
??<include?file?=?"$(find?octomap_server)/launch/octomap_server_start.launch"?/>
??
??<node?pkg?=?"rviz"?type?=?"rviz"?name?=?"$(anon?rviz)"?respawn?=?"false"?output?=?"screen"?args?=?"-d?$(find?octomap_server)/rviz/octomap_debug.rviz"/>
??
??<include?file?=?"$(find?lego_loam)/launch/demo.launch"?/>
??
??<node?pkg?=?"tf2_ros"?type?=?"static_transform_publisher"?name?=?"dlonng_static_test_broadcaster"?args?=?"0?0?0?0?0?0?base_link?rslidar"?/>
launch>
3. 補充一些小 Tips
如果不知道要啟動的包的 launch 文件叫啥,可以查找指定包的路徑,然后進入看看 launch 文件夾下面的啟動文件叫啥:
rospack?list?|?grep?"zed_cpu_ros"
rospack?list?|?grep?"rslidar_pointcloud"
之后我就可以從 octomap_server 中一鍵啟動所有我建圖要用的節(jié)點了:
roslaunch?octomap_server?dlonng_octomap_test.launch
但是啟動過程中遇到 rviz 節(jié)點名字重復(fù)的問題,我把雷達啟動的 RVIZ 關(guān)掉或者把啟動 RVIZ 的節(jié)點名稱改變下,防止重復(fù)。
推薦閱讀:
廈大同學(xué),與你分享編程,AI 算法等技術(shù)干貨!精品文章創(chuàng)作不易,謝謝關(guān)注,歡迎在看。
點擊閱讀原文,查看更多精彩文章!
評論
圖片
表情
