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

Problem with roslaunch on rc.local startup

asked 2019-04-22 06:58:44 -0500

Jason C. gravatar image

updated 2019-05-02 05:09:21 -0500

Hello,

I tried launching some nodes on startup via rc.local, but I have the following errors on some of the startups:

[   45.809342] rc.local[661]: RLException: ERROR: could not contact master [http://localhost:11311]                                
[   45.821666] rc.local[661]: The traceback for the exception was written to the log file                                                     
[   45.844191] rc.local[661]: ... logging to /root/.ros/log/3b1cabe6-64e9-11e9-8f36-74e1828a3ed5/roslaunch-arm-945.log                        
[   45.845040] rc.local[661]: Checking log directory for disk usage. This may take awhile.                                                    
[   45.845630] rc.local[661]: Press Ctrl-C to interrupt                                                                                       
[   45.846329] rc.local[661]: Done checking log file disk usage. Usage is <1GB.                                                               
[   45.846840] rc.local[661]: 2;/home/tucer/catkin_ws/src/electronicload/launch/launcher.launch                                               
[   45.847310] rc.local[661]: started roslaunch server http://arm:45779/                                                                      
[   45.847892] rc.local[661]: SUMMARY                                                                                                         
[   45.860883] rc.local[661]: ========                                                                                                        
[   45.864314] rc.local[661]: PARAMETERS                                                                                                      
[   45.865892] rc.local[661]:  * /rosdistro: melodic                                                                                          
[   45.868293] rc.local[661]:  * /rosversion: 1.14.3                                                                                          
[   45.876385] rc.local[661]: NODES                                                                                                           
[   45.877925] rc.local[661]:   /                                                                                                             
[   45.880247] rc.local[661]:     LCD (electronicload/LCD.py)                                                                                 
[   45.882944] rc.local[661]:     controller (electronicload/controller.py)                                                                   
[   45.888258] rc.local[661]:     logger_to_file (electronicload/logger_to_file.py)                                                           
[   45.892181] rc.local[661]:     sensors (electronicload/sensors.py)                                                                         
[   45.893536] rc.local[661]:     shutdown (electronicload/shutdown.py)                                                                       
[   45.894667] rc.local[661]: auto-starting new master                                                                                        
[   45.900240] rc.local[661]: process[master]: started with pid [1175]                                                                        
[   46.031643] rc.local[661]: Traceback (most recent call last):                                                                              
[   46.036751] rc.local[661]:   File "/opt/ros/melodic/bin/rosmaster", line 35, in <module>                                                   
[   46.039083] rc.local[661]:     rosmaster.rosmaster_main()                                                                                  
[   46.040722] rc.local[661]:   File "/opt/ros/melodic/lib/python2.7/dist-packages/rosmaster/main.py", line 84, in rosmaster_main             
[   46.045008] rc.local[661]:     configure_logging()                                                                                         
[   46.048811] rc.local[661]:   File "/opt/ros/melodic/lib/python2.7/dist-packages/rosmaster/main.py", line 58, in configure_logging          
[   46.051817] rc.local[661]:     _log_filename = rosgraph.roslogging.configure_logging('rosmaster', logging.DEBUG, filename=filename)        
[   46.057809] rc.local[661]:   File "/opt/ros/melodic/lib/python2.7/dist-packages/rosgraph/roslogging.py", line 185, in configure_logging    
[   46.063184] rc.local[661]:     logging.config.fileConfig(config_file, disable_existing_loggers=False)                                      
[   46.070380] rc.local[661]:   File "/usr/lib/python2.7/logging/config.py", line 85, in fileConfig                                           
[   46.074387] rc.local[661]:     handlers = _install_handlers(cp, formatters)                                                                
[   46.075661] rc.local[661]:   File "/usr/lib/python2.7/logging/config.py", line 163, in _install_handlers                                   
[   46.081225] rc.local[661]:     h = klass(*args)                                                                                            
[   46.082611] rc.local[661]:   File "/opt/ros/melodic/lib/python2.7/dist-packages/rosgraph/roslogging.py", line 230, in __init__             
[   46.083944] rc.local[661]:     from rospy.rostime import get_time, is_wallclock                                                            
[   46.085346] rc.local[661]:   File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/__init__.py", line 49, in <module>                   
[   46.088288] rc.local[661]:     from .client import spin, myargv, init_node, \                                                              
[   46.089780] rc.local[661]:   File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/client.py", line 60, in <module>                     
[   46.092281] rc.local[661]:     import rospy.impl ...
(more)
edit retag flag offensive close merge delete

Comments

Do you have other options than using rclocal ? If so #q290599 might help you launch nodes on startup (but not using rclocal).

Delb gravatar image Delb  ( 2019-05-02 09:34:20 -0500 )edit

@Delb I tried systemd service but had the same results. I found a way around, if you are interested you can check the answers!

Jason C. gravatar image Jason C.  ( 2019-05-03 05:27:02 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2019-05-03 05:24:17 -0500

Jason C. gravatar image

updated 2019-05-03 05:27:53 -0500

Since I could not find a clear solution to the issue, with Delb's help I tweaked around the setup.bash script and found out that the roscore that is being automatically called from roslaunch may be the source of the problem. Using the --wait parameter on roslaunch, I can raise my own roscore and then run all the nodes needed. This is my new startup.bash file:

#! /bin/bash
##########################
##   scipt starts here  ##
##########################

export ROS_MASTER_URI="http://localhost:11311/"
export ROS_HOSTNAME="localhost"


echo "The penguin took off..."

source /opt/ros/melodic/setup.bash
source /home/tucer/catkin_ws/devel/setup.bash
echo "...the penguin sourced both bash files for ros with his penguin nades..."
roscore&
roslaunch --wait electronicload launcher.launch

echo "...the penguin landed safely."

EDIT: typo.

edit flag offensive delete link more

Comments

1

Glad you solved your issue !

Delb gravatar image Delb  ( 2019-05-03 06:53:49 -0500 )edit
2

answered 2019-05-02 04:00:41 -0500

Delb gravatar image

Not sure if this is your exact problem but there is something odd :

ERROR: could not contact master [http://localhost:11311]

This suggests that the environment variable ROS_MASTER_URI is set to http://localhost:11311.

started roslaunch server http://arm:45779/

This suggests that the environment variable ROS_HOSTNAME is set to arm.

Not having those variables to the same value is a common source of issue especially if the master is runned on your laptop.

Maybe you should try adding at the beginning of your startup.bash file those two lines :

export ROS_MASTER_URI="http://YOUR_IP_ADDRESS:11311/"
export ROS_HOSTNAME="YOUR_IP_ADDRESS"
edit flag offensive delete link more

Comments

thanks for the advice, however errors still exist. edited OP with information (EDIT2).

Jason C. gravatar image Jason C.  ( 2019-05-02 05:10:26 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2019-04-22 06:58:44 -0500

Seen: 1,076 times

Last updated: May 03 '19