#ROS调包侠#robot
The install script-robot_upstart 0.2.2 documentation
sudo apt install ros-$ROS_DISTRO-robot-upstart
使用前准备
创建启动用的功能包和launch文件
创建base_upstart用于存放开机启动的launch文件
cd ~/catkin_ws/src/
cd base_upstart/
mkdir launch && cd launch
编写launch文件,将需要启动的节点活launch文件写入
vim base_upstart.launch
<launch>
<include file="$(find base_control)/launch/base_control.launch" />
<include file="$(find robot_vision)/launch/robot_camera.launch" />
<node name="web_video_server" pkg="web_video_server" type="web_video_server" output="screen"/>
</launch>
编译工作空间
cd ~/catkin_ws/ && catkin_make
验证launch文件编写无误
roslaunch base_upstart base_upstart.launch
roscore
rosrun robot_upstart install base_upstart/launch/base_upstart.launch --job base_upstart --interface wlan0 --logdir ~/base_upstart.log
命令中
base_upstart/launch/base_upstart.launch 为开机自启动的launch文件
--job base_upstart 指定启动的任务名为base_upstart ,名称可以自定义
--interface wlan0 指定网络接口为wlan0,也可以使用lo,即127.0.0.1的内网地址
--logdir ~/ad_upstart.log 指定启动日志存放目录
加入必要的环境变量
sudo vim /lib/systemd/system/base_upstart.service
# THIS IS A GENERATED FILE, NOT RECOMMENDED TO EDIT.
[Unit]
Description="bringup base_upstart"
After=network.target
[Service]
Type=simple
Environment="BASE_TYPE=NanoCar"
Environment="LIDAR_TYPE=rplidar_super"
Environment="CAMERA_TYPE=usb100"
Environment="SONAR_NUM=1"
ExecStart=/usr/sbin/base_upstart-start
[Install]
WantedBy=multi-user.target
~
启动服务
sudo systemctl daemon-reload && sudo systemctl start base_upstart
sudo systemctl stop base_upstart
roscore
rosrun robot_upstart uninstall base_upstart
1、设置后修改源launch文件不会影响开机启动,因为开机启动所使用的launch文件位于/etc/ros/noetic/base_upstart.d/
目录下