ubuntu18.04 shell开机自启launch文件
1.新建xxx.sh文件
2.文件输入:
#! /bin/bash
#根据系统启动相应版本的roscore
gnome-terminal – bash -c “source /opt/ros/melodic/setup.bash;roscore” & #启动roscore
sleep 2 #等待roscore启动(可以不写)
gnome-terminal – bash -c “cd /home/ros_ws;source devel/setup.bash;roslaunch gazebo_pkg raceNew.launch” #启动节点
wait
exit 0
(此处有bug,如果电脑运行速度不行,则将roscore启动后的延时开高,否则会与后面的launch冲突,导致后面的launch启动失败!)
3.给于权限chmod +x xxx.sh
4.gnome-session-properties启动ubuntu自启动程序,点击add添加:name和comment可以随意填写,中间的command添加你需要启动的可执行文件xxx.sh及路径。
5.完成reboot即可测试自启。