目的:
打开多个launch文件比较复杂,因此考虑采用shell进行多个launch文件的一键启动
实例
#!/bin/bash
gnome-terminal -t "loam_interface" -x bash -c "cd autonomous_exploration_development_environment; source devel/ setup.bash;roslaunch loam_interface loam_interface.launch;exec bash"
sleep 3s
gnome-terminal -t "local_planner" -x bash -c "cd autonomous_exploration_development_environment; source devel/setup.bash;roslaunch local_planner local_planner.launch;exec bash"
sleep 3s
解析
1.gnome-terminal -t表示开终端窗口的标签页面(后面为终端标题);gnome-terminal --window 是表示开一个窗口.
2.x bash -c : 后面的“”中是我们原本要在终端输入的命令,指令之间通过;分割开.
3.exec bash 可以确保执行脚本后保持窗口不消失.
4.sleep执行下一个命令前,最好能等待上一个命令执行完成,否则容易造成启动失败,当节点启动比较慢时,最好将等待的时间变长.
步骤
1.编写sh文件
2.执行权限:chmod 777 filename.sh
3.启动:./filename.sh