1.概述
写了这么多ROS
的launch
脚本,怎么才能开机就启动呢,本文介绍1种方法,使用ROS
的 robot_upstart包,下面以pibot_bringup
package的·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 设置
rosrun robot_upstart install pibot_bringup/launch/bringup.launch
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
- 照着提示操作
sudo systemctl daemon-reload && sudo systemctl start pibot
2.3 测试
-
ps -aux | grep pibot_bringup
查看进程
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
已经可以查到该进程了
-
rosnode list
查看node
pibot@pibot-desktop:~$ rosnode list
/pibot_driver
/rosout
也可以看到2个node
-
roslaunch pibot keyboard_teleop.launch
启动键盘控制程序,也可以支持控制小车了
为了验证程序是否开启启动了,重启后再次重复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
启动服务
网友评论