关于机器人:ROS-机器人技术-编写一个-launch-启动多个节点

42次阅读

共计 1428 个字符,预计需要花费 4 分钟才能阅读完成。

1. 减少 source 到 bashrc 中

为了不必在小车的 Ubuntu 上每次都 source 本人的工作空间,我把本人的 workspace 加到 ~/.bashrc 文件开端:

而后重启 shell,之后就会主动 source 我得工作空间,能够应用 roscd 间接进入指定包中:

roscd pkg_name

2. 编写启动 launch

每次调试小车,都要别离启动很多节点,比方交融、建图、Loam、Rviz 等,所以我把这些节点全副配置在一个 launch 中启动,间接一行命令启动,这样调试就不便多了,大大节省时间:

  • lidar_camera_fusion\launchlidar_camera_fusion.launch
  • octomap_server\rvizoctomap_debug.rviz
  • octomap_server\launchdlonng_octomap_test.launch
<launch>
  <!-- Start ZED! -->
  <include file = "$(find zed_cpu_ros)/launch/zed_cpu_ros.launch" />

  <!-- Start Robosense LIDAR! -->
  <include file = "$(find rslidar_pointcloud)/launch/rs_lidar_16.launch" />

  <!-- Start fusion node! -->
  <include file = "$(find lidar_camera_fusion)/launch/lidar_camera_fusion.launch" />

  <!-- Start Octomap node! -->
  <include file = "$(find octomap_server)/launch/octomap_server_start.launch" />

  <!-- Start octomap_debug.rviz -->
  <node pkg = "rviz" type = "rviz" name = "$(anon rviz)" respawn = "false" output = "screen" args = "-d $(find octomap_server)/rviz/octomap_debug.rviz"/>

  <!-- Start Lego Loam! -->
  <include file = "$(find lego_loam)/launch/demo.launch" />

  <!-- Only using in map build test! -->
  <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 中一键启动所有我建图要用的节点了:

roslaunch octomap_server dlonng_octomap_test.launch

然而启动过程中遇到 rviz 节点名字反复的问题,我把雷达启动的 RVIZ 关掉或者把启动 RVIZ 的节点名称扭转下,避免反复。

正文完
 0