ROS自主导航机器人

ROS机器人底盘(33)-ROS程序开机自启动

2019-04-11  本文已影响27人  PIBOT导航机器人

1.概述

写了这么多ROSlaunch脚本,怎么才能开机就启动呢,本文介绍1种方法,使用ROSrobot_upstart包,下面以pibot_bringuppackage的·bringup.launch`演示

2.robot_upstart包

2.1 安装

使用pibot_install_ros.sh一键安装工具即可安装所有pibot所需要的ROS包,如需单独安装sudo apt-get install ros-{ROS_DIST}-robot-upstart

ROS_DIST即为indigo或者kinetic

2.2 设置

pibot@pibot-desktop:~$ rosrun robot_upstart install pibot_bringup/launch/bringup.launch
/lib/systemd/systemd
Preparing to install files to the following paths:
 /etc/ros/kinetic/pibot.d/.installed_files
 /etc/ros/kinetic/pibot.d/bringup.launch
 /etc/systemd/system/multi-user.target.wants/pibot.service
 /lib/systemd/system/pibot.service
 /usr/sbin/pibot-start
 /usr/sbin/pibot-stop
Now calling: /usr/bin/sudo /opt/ros/kinetic/lib/robot_upstart/mutate_files
Filesystem operation succeeded.
** To complete installation please run the following command:
 sudo systemctl daemon-reload && sudo systemctl start pibot

2.3 测试

pibot@pibot-desktop:~/pibot_ros$ ps -aux | grep pibot_bringup
pibot    15971 96.3  0.7  85620  7488 ?        Rsl  23:26   1:13 /home/pibot/pibot_ros/ros_ws/devel/lib/pibot_bringup/pibot_driver __name:=pibot_driver __log:=/tmp/0656ed38-5ba5-11e9-be9a-b827ebff3168/pibot_driver-2.log

已经可以查到该进程了

pibot@pibot-desktop:~$ rosnode list
/pibot_driver
/rosout

也可以看到2个node

为了验证程序是否开启启动了,重启后再次重复2.3的测试步骤即可

2.4 停止以及取消开机启动

sudo service pibot start
sudo service pibot  stop
rosrun robot_upstart uninstall pibot

3 robot_upstart服务名称

可以看到上面的service名称为pibot,通过查看源码可以看到


job_name取了包名的下划线前面的对pibot_bringup取了pibot

我们稍作修改


新增一个参数指定服务名称
对于上面我追加一个参数pibot_bringup
rosrun robot_upstart install pibot_bringup/launch/bringup.launch pibot_bringup
pibot@pibot-desktop:~$ rosrun robot_upstart install pibot_bringup/launch/bringup.launch pibot_bringup
/lib/systemd/systemd
Preparing to install files to the following paths:
/etc/ros/kinetic/pibot_bringup.d/.installed_files
/etc/ros/kinetic/pibot_bringup.d/bringup.launch
/etc/systemd/system/multi-user.target.wants/pibot_bringup.service
/lib/systemd/system/pibot_bringup.service
/usr/sbin/pibot_bringup-start
/usr/sbin/pibot_bringup-stop
Now calling: /usr/bin/sudo /opt/ros/kinetic/lib/robot_upstart/mutate_files
Filesystem operation succeeded.
** To complete installation please run the following command:
 sudo systemctl daemon-reload && sudo systemctl start pibot_bringup

我们就可以使用sudo service pibot_bringup start启动服务

上一篇下一篇

猜你喜欢

热点阅读