ROS开机自启动

来源:互联网 发布:su for mac 教学视频 编辑:程序博客网 时间:2024/05/16 14:50

Ubuntu14.04

网上很多资料说在/etc/rc.local中添加脚本,实验之后完全没用。可能是系统版本不对。 
解决: 
Ubuntu14.04 开机项命令: gnome-session-properties 
这里写图片描述 
点击”add” 
这里写图片描述

name : 名字 
command : 命令,eg:gnome-terminal -x your_command.sh 
注意:sh文件的权限,必须是可运行的, 路径为绝对路径。

 sudo chmod +x your_command.sh
  • 1
  • 1

comment :注释

这里写图片描述

这里写图片描述 
退出,重启!

脚本文件 start.sh

#! /bin/bash source /opt/ros/indigo/setup.shsource /home/server/catkin_ws/devel/setup.bashroslaunch /home/server/catkin_ws/src/nodelet_tutorial_math/launch/plus.launch
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

开机后结果,已经自动运行了。 
这里写图片描述

firefly

最终的产品我们不可能用一台电脑作为处理器,所以我们要有开发板,我们使用的是firefly rk3288.系统是Ubuntu14.04.因为系统是同事搞得,具体细节不清楚。在firefly中,没有gnome-session-properties这条命令,也就是说之前的方法不能用。这个时候robot_upstart 上场了。 
http://docs.ros.org/jade/api/robot_upstart/html/index.html# 
安装:sudo apt-get install ros-indigo-robot-upstart

install 命令:要启动的launch文件,默认的名称为”myrobot”,也可以使用–job 指定工作名称,默认是工程名(下划线之前的部分)。

这里写图片描述

start 命令:

$ sudo service nodelet start
  • 1
  • 1

这里写图片描述

关机重启之后,这时,我们的终端不会自动启动,但是ros 节点已经启动了,打开终端,验证一下执行

$rosnode list$rostopic list
  • 1
  • 2
  • 1
  • 2

这里写图片描述

可以看到,ros节点已经在运行了。

stop命令:

sudo service nodelet stop
  • 1
  • 1

uninstall命令:

rosrun robot_upstart uninstall nodelet
  • 1
  • 1

这里写图片描述 
这样自启动就会取消了。

遇到的大坑

我们的板子需要接很多设备,比如底座,摄像头,arduino等等。板子上的usb转串口 接口明显不够用。另外开机时串口的识别,设备的识别等很不稳定。所以让这些设备在板子开机时被稳定的识别到是最重要的。目前没有找到好的解决办法,以后解决了再更新。

2016 -12-30更新

之前的关于设备接口和串口识别不到的问题解决了,说一下解决思路。可以新建一个node,使用launch启动,将这个launch设为自启动。这样,上电开机时,这个node就会运行。在这个node中,延时一段时间,调用c++的system函数执行去Linux命令,启动包含摄像头等其他设备的launch。

system("roslaunch pkg xxx.launch")
  • 1
  • 1

总之,等系统识别完设备接口之后,再去启动我们的launch,就能保证不会出现找不到串口或设备的问题了。

转自http://blog.csdn.net/yiranhaiziqi/article/details/53640523

0 0
原创粉丝点击