autostart a launchfile after/while boot
Hi,
I looking for a solution to just turn on my system (ubuntu 11.04 server/headless) and launch a launchfile automatically.
I tried the solution posted here with a boot startup script but it didn't work. Would be great to get your thoughts.
here is my script in /etc/init.d/:
start_ros () {
#Get ROS bash commands
source /opt/ros/electric/setup.sh
#Get custom packages (this script will launch with 'sudo', so it'll be the root user
export ROS_PACKAGE_PATH=/home/panda:$ROS_PACKAGE_PATH
#Home directory of your user for logging
export HOME="/home/panda"
#Home directory for your user for logging
export ROS_HOME="/home/panda/.ros"
#I run ROS on a headless machine, so I want to be able to connect to it remotely
export ROS_IP="192.168.9.123"
#I like to log things, so this creates a new log for this script
LOG="/var/log/panda.log"
#Time/Date stamp the log
echo -e "\n$(date +%Y:%m:%d-%T) - Starting ROS daemon at system startup" >> $LOG
echo "This launch will export ROS's IP as $ip" >> $LOG
#For bootup time calculations
START=$(date +%s.%N)
#This is important. You must wait until the IP address of the machine is actually configured by all of the Ubuntu process. Otherwise, you will get an error and launch will fail. This loop just loops until the IP comes up.
while true; do
IP="`ifconfig | grep 'inet addr:'192.168.9.123''| cut -d: -f2 | awk '{ print $1}'`"
if [ "$IP" ] ; then
echo "Found"
break
fi
done
#For bootup time calculations
END=$(date +%s.%N)
echo "It took $(echo "$END - $START"|bc ) seconds for an IP to come up" >> $LOG
echo "Launching default_package default_launch into a screen with name 'ros'." >> $LOG
screen -dmS ros roslaunch panda_cam high.launch
}
case "$1" in
start)
start_ros
esac
exit 0
after that I called and rebooted
$sudo update-rc.d panda_cam_startup defaults 99
while bootup i get the following output
/etc/rc2.d/S99panda_cam_startup: 45: source: not found
Found
/etc/rc2.d/S99panda_cam_startup: 45: bc: not found
/etc/rc2.d/S99panda_cam_startup: 45: screen: not found
But the sourcepath is definitely righ. No idea whats wrong
Maybe you can get some inspiration from here: https://github.com/turtlebot/turtlebot/tree/master/turtlebot_bringup/upstart