我是这个平台的新手。我有关于rc.local 的问题。我创建了一个脚本来自动运行roscore和roslaunch rosbridge_server rosbridge_websocket.launch。此脚本名称为auto,脚本内容为:
#!/bin/sh
cd $home
xterm -hold -e "roscore" &
xterm -hold -e "roslaunch rosbridge_server rosbridge_websocket.launch"
exit 0
Run Code Online (Sandbox Code Playgroud)
我必须在 rc.local 中运行这个脚本。创建的 rc.local 文件是:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sudo auto.sh
sh '/home/moguztas/auto.sh'
exit 0
Run Code Online (Sandbox Code Playgroud)
我哪里做错了?我按照如何在启动时运行“rc.local”中的9 个步骤来执行解决方案?但它没有运行。
问题彻底解决了。下面给出解决方案。
首先创建一个您想要在其中运行的脚本。我想rosbridge_websocket在计算机启动时自动运行。我的脚本名称是auto并且位于home/username/auto.sh. 脚本的内容是:
#!/bin/bash
cd $home
source /opt/ros/indigo/setup.bash
roslaunch rosbridge_server rosbridge_websocket.launch
exit 0
Run Code Online (Sandbox Code Playgroud)
您必须检查您的脚本文件是否可执行。要执行脚本文件,请使用以下命令:$ sudo chmod u+x /home/username/auto.sh
要执行此操作,请运行rc.local位于 的脚本/etc/rc.local。它是使用创建的gksudo gedit /etc/rc.local。里面rc.local是:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/home/username/auto.sh
exit 0
Run Code Online (Sandbox Code Playgroud)
最后,您必须使用 重新启动系统$ sudo reboot。当您启动计算机时,您的脚本就完全可以工作了。