ubuntu开机自动运行脚本程序
终端中输入gnome-session-properties
打开Ubuntu开机首选项管理,如图所示
添加选项中选择需要开机自动运行的脚本,之后,在command
选项中添加:
sh /home/nvidia/autorun.sh
本次主要是为了在NX模块上开机自动运行脚本,以实现启动:
dji_osdk_ros
主节点、大疆camera节点、livox_lidar节点、rosbag record功能。
1、自启动脚本:autosave.sh
的内容如下:
#!/usr/bin/env bash
sleep 10 //********sleep的时间需要开机测试的时候根据实际进行修改********
gnome-terminal -t "launch_dji" -x bash -c "cd /home/foia/ws_djiCamera;source devel/setup.bash;cd /home/foia/bagfiles;sh ./launch_dji.sh;exec bash"
sleep 10
gnome-terminal -t "run_camera" -x bash -c "cd /home/foia/ws_djiCamera;source devel/setup.bash;cd /home/foia/bagfiles;sh ./run_camera.sh;exec bash"
sleep 10
gnome-terminal -t "launch_lidar" -x bash -c "cd /home/foia/ws_livox;source devel/setup.bash;cd /home/foia/bagfiles;sh ./launch_lidar.sh;exec bash"
sleep 10
gnome-terminal -t "rosbag_record" -x bash -c "source /opt/ros/melodic/setup.bash;cd /home/foia/bagfiles;sh ./rosbag_record.sh;exec bash"
【注解】:
-t:终端的标题;
-x:后面的为要在打开的终端中执行的脚本,根据需要自己修改就行了。
最后的exec bash;是让打开的终端在执行完脚本后不关闭。
1.1、dji主节点的启动脚本launch_dji.sh
内容如下:
#!/usr/bin/env bash
roslaunch dji_osdk_ros dji_vehicle_node.launch
1.2、大疆camera节点的启动脚本run_camera.sh
内容如下:
#!/usr/bin/env bash
rosrun dji_osdk_ros camera_stream_node
1.3、livox_lidar节点的启动脚本launch_lidar.sh
内容如下:
#!/usr/bin/env bash
roslaunch livox_ros_driver livox_lidar_rviz.launch
1.4、rosbag record功能的启动脚本rosbag_record.sh
内容如下:
#!/usr/bin/env bash
rosbag record /livox/lidar /image_compressed