ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Issues launching ROS on startup

asked 2014-03-15 21:03:27 -0500

rb gravatar image

updated 2016-10-24 09:08:29 -0500

ngrennan gravatar image

ROS: groovy OS: ubuntu 12.04

What we are trying to do is have roscore start upon boot (have this working now) and then execute a launch file. I am not a linux person, so I feel I am really not approaching this the right way. Currently, this is what I have attempted:

1) roscore is launched via a script in /etc/init.d. This is fine. 2) I want to launch my launch file on boot. Manually, I do it like this: roslaunch rover.launch. It works great. 3) I would like this to start on boot, so I tried the following: inside new script (boot.sh) - note i disabled password prompt for sudo:

 sudo su - roboops
 /home/roboops/groovycat/scripts/bootRoverLaunch.sh

bootRoverLaunch.sh:

cd /home/roboops/groovycat/
source devel/setup.sh
sleep 5
roslaunch rover.launch > /home/roboops/groovycat/scripts/startup.log

4) I went to "startup applications" and added "bash /home/roboops/groovycat/scripts/boot.sh"

5) Tried rebooting. Roscore starts, and the launch files executes. However, the nodes malfunction and don't work correctly (They work fine when started using the launch file directly in a terminal window. Oddly, it also works fine if I log out and back in once)

More specifically, here is the problem when using the above script to launch:

I am trying to run two nodes:

-joystick node (publishes joy topic) -motor control node (listens to joy topic and outputs commands to motor controllers via serial)

Joystick node starts successfully and If I do rostopic echo joy, I can see the values. Motor control node is listed as running but if I run roswtf it says:

Found 3 error(s).

ERROR Could not contact the following nodes:
 * /Drivetrain

ERROR The following nodes should be connected but aren't:
 * /Drivetrain->/rosout (/rosout)

ERROR Errors connecting to the following services:
 * service [/Drivetrain/get_loggers] appears to be malfunctioning: Unable to communicate with service [/Drivetrain/get_loggers], address [rosrpc://Rover:58631]
 * service [/Drivetrain/set_logger_level] appears to be malfunctioning: Unable to communicate with service [/Drivetrain/set_logger_level], address [rosrpc://Rover:58631]

The idea is, I need everything to automatically start on power-up. There will be no input devices/monitor connected to it when it is in use.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2014-03-17 14:47:14 -0500

Ryan gravatar image

We recommend using the robot_upstart package we developed. It's simple, seems to do everything you need, and has already been deployed on dozens of robots.

edit flag offensive delete link more

Comments

I notice the package only has a hydro/devel branch. Does this work for groovy?

Andrew.A gravatar image Andrew.A  ( 2014-05-29 21:10:11 -0500 )edit
1

Hi Andrew, yes, robot_upstart should work with groovy as well as hydro, as long as you don't mind doing a source install of it in your workspace.

mikepurvis gravatar image mikepurvis  ( 2014-07-07 14:13:10 -0500 )edit
1

Hi Mike,

I'm also trying to use robot_upstart since 3hours without results.... is it possible to use this package with indigo???

Tks

julien gravatar image julien  ( 2015-02-02 07:23:36 -0500 )edit

@julien: I'm not Mike, but I know we use it to run our Jackal, which is Indigo-only. Have you tried using

sudo apt-get install ros-indigo-robot-upstart

to install it? Instructions to use it are on both the ROS wiki and its github page.

Ryan gravatar image Ryan  ( 2015-02-05 17:31:51 -0500 )edit

Note, this package is no longer supported on Kinetic.

Cerin gravatar image Cerin  ( 2016-08-14 15:39:19 -0500 )edit
1

Support for Kinetic has been added

kmhallen gravatar image kmhallen  ( 2017-04-09 10:47:15 -0500 )edit
3

answered 2014-03-17 08:22:35 -0500

Wolf gravatar image

I start my roslaunch on start up using cron ( http://wiki.ubuntuusers.de/Cron ) and screen ( http://wiki.ubuntuusers.de/screen ).

I have a /home/user/autostart/autostart_screens.sh that get executed by cron @reboot (Meaning whenever the PC is booted). You can set these startup files via crontab command. See crontab --help. My current crontab -l gives:

# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
@reboot bash /home/user/autostart/autostart_screens.sh

My autostart_screens.sh starts and detaches two screen sessions and logs any thing happening inbetween to a log file. It looks like:

# !/bin/bash
LOG_FILE=/home/user/autostart/logs/log_autostart_screens.txt

echo "" >> ${LOG_FILE}
echo "" >> ${LOG_FILE}
echo "" >> ${LOG_FILE}
echo "" >> ${LOG_FILE}
echo "#############################################" >> ${LOG_FILE}
echo "Running autostart_screens.sh" >> ${LOG_FILE}
echo $(date) >> ${LOG_FILE}
echo "#############################################" >> ${LOG_FILE}
echo "" >> ${LOG_FILE}
echo "Logs:" >> ${LOG_FILE}

set -e
set -v

{

screen -d -m bash /home/user/autostart/start_roscore.sh
screen -d -m bash /home/user/autostart/start_roslaunch.sh

} &>> ${LOG_FILE}

Note that it is not blocking as it just starts the screens.

The start_roscore.sh looks like:

# !/bin/bash
LOG_FILE=/home/user/autostart/logs/log_start_roscore.txt
echo "" >> ${LOG_FILE}
echo "" >> ${LOG_FILE}
echo "" >> ${LOG_FILE}
echo "" >> ${LOG_FILE}
echo "#############################################" >> ${LOG_FILE}
echo "Running start_roscore.sh" >> ${LOG_FILE}
echo $(date) >> ${LOG_FILE}
echo "#############################################" >> ${LOG_FILE}
echo "" >> ${LOG_FILE}
echo "Logs:" >> ${LOG_FILE}

set -e

{

source /opt/ros/hydro/setup.bash
source /home/user/workspace/ros_hydro/catkin/devel/setup.bash

export ROS_WORKSPACE=/home/user/workspace/ros_hydro/catkin

export ROS_MASTER_URI=http://192.168.1.10:11311/ ##e. g. Master
export ROS_IP=192.168.1.15                   ##e. g. Own IP

sleep 5

} &>> ${LOG_FILE}

set -v

{

roscore

} &>> ${LOG_FILE}

The start_roslaunch.sh looks like:

# !/bin/bash
LOG_FILE=/home/user/autostart/logs/log_start_roslaunch.txt
echo "" >> ${LOG_FILE}
echo "" >> ${LOG_FILE}
echo "" >> ${LOG_FILE}
echo "" >> ${LOG_FILE}
echo "#############################################" >> ${LOG_FILE}
echo "Running start_roslaunch.sh" >> ${LOG_FILE}
echo $(date) >> ${LOG_FILE}
echo "#############################################" >> ${LOG_FILE}
echo "" >> ${LOG_FILE}
echo "Logs:" >> ${LOG_FILE}

set -e

{
source /opt/ros/hydro/setup.bash
source /home/user/workspace/ros_hydro/catkin/devel/setup.bash

export ROS_WORKSPACE=/home/user/workspace/ros_hydro/catkin

export ROS_MASTER_URI=http://192.168.1.10:11311/
export ROS_IP=192.168.1.15

sleep 8

} &>> ${LOG_FILE}

set -v

{

roslaunch my_pkg my_launch.launch

} &>> ${LOG_FILE}

All logs go to /home ... (more)

edit flag offensive delete link more

Comments

Why are you running both roscore and roslaunch in separate scripts? roslaunch will automatically run roscore if needed.

Cerin gravatar image Cerin  ( 2016-08-14 21:55:57 -0500 )edit
2

answered 2017-04-09 10:26:04 -0500

CimeROS gravatar image

updated 2017-04-09 10:28:46 -0500

I start my roscore on boot simply by adding this line in "/etc/rc.local" before "exit0":

su pi -c "source /home/pi/YOURWS/devel/setup.sh ; roscore  > /dev/null 2>&1 &"

the "> /dev/null" means its logs dont get stored anywhere and "&" at the end means it starts in the background. You cant start roscore in root mode, that's why "su pi -c" is at the start of the command. Replace "/home/pi/YOURWS" with your workspace name and destination.

edit flag offensive delete link more

Comments

1

Works, and it's simple ! I have spent hours trying to use robot_upstart, but it needs too many files and devices to have their permissions changed. I used a launch file: su ubuntu -c "source /home/ubuntu/catkin_ws/devel/setup.sh ; roslaunch biped biped_robot.launch > /dev/null 2>&1 &"

elpidiovaldez gravatar image elpidiovaldez  ( 2018-05-24 22:40:58 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-03-15 21:03:27 -0500

Seen: 10,839 times

Last updated: Apr 09 '17