Script ROS to start at boot
I'm following the http://wiki.ros.org/roslibjs/Tutorial... example and running it in docker container.
It works if I manually type in the three commands by hand
roscore &
rosrun actionlib_tutorials fibonacci_server &
roslaunch rosbridge_server rosbridge_websocket.launch
but now I'd like to start the server automatically when the container runs.
I tried to make a script with those 3 commands and call it once the container is booted, but it doesn't work. It seems maybe some of the later commands are being run before the earlier ones finish whatever it is they're doing.
I can make it work by adding sleep 10
commands between the ros commands, but that doesn't seem like a good solution. What happens if something takes longer than 10 seconds to start?
Is there a proper way to script ROS so that you don't have to manually type in commands? Would it involve systemd? I saw some answers talk about upstart, but that's not used much anymore.
Thanks
output after script is run
[ERROR] [1473788676.856009756]: [registerPublisher] Failed to contact master at [localhost:11311]. Retrying...
... logging to /root/.ros/log/bd282b86-79d9-11e6-a6d8-0242ac110002/roslaunch-7cc22b76aecc-41.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
... logging to /root/.ros/log/bd2b0c3e-79d9-11e6-898e-0242ac110002/roslaunch-7cc22b76aecc-43.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://7cc22b76aecc:43707/
ros_comm version 1.12.2
SUMMARY
========
PARAMETERS
* /rosdistro: kinetic
* /rosversion: 1.12.2
NODES
auto-starting new master
started roslaunch server http://7cc22b76aecc:43708/
SUMMARY
========
PARAMETERS
* /rosbridge_websocket/address:
* /rosbridge_websocket/authenticate: False
* /rosbridge_websocket/delay_between_messages: 0
* /rosbridge_websocket/fragment_timeout: 600
* /rosbridge_websocket/max_message_size: None
* /rosbridge_websocket/port: 9090
* /rosbridge_websocket/retry_startup_delay: 5
* /rosdistro: kinetic
* /rosversion: 1.12.2
NODES
/
rosapi (rosapi/rosapi_node)
rosbridge_websocket (rosbridge_server/rosbridge_websocket)
auto-starting new master
process[master]: started with pid [71]
process[master]: started with pid [75]
ROS_MASTER_URI=http://7cc22b76aecc:11311/
setting /run_id to bd282b86-79d9-11e6-a6d8-0242ac110002
[ INFO] [1473788677.469727221]: Connected to master at [localhost:11311]
ROS_MASTER_URI=http://localhost:11311
ERROR: Unable to start XML-RPC server, port 11311 is already in use
Unhandled exception in thread started by <bound method XmlRpcNode.run of <rosgraph.xmlrpc.XmlRpcNode object at 0x7f2dd3104990>>
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/xmlrpc.py", line 212, in run
self._run()
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/xmlrpc.py", line 281, in _run
self._run_init()
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/xmlrpc.py", line 231, in _run_init
self.server = ThreadingXMLRPCServer((bind_address, port), log_requests)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/xmlrpc.py", line 112, in __init__
SimpleXMLRPCServer.__init__(self, addr, SilenceableXMLRPCRequestHandler, log_requests)
File "/usr/lib/python2.7/SimpleXMLRPCServer.py", line 593, in __init__
SocketServer.TCPServer.__init__(self, addr, requestHandler, bind_and_activate)
File "/usr/lib/python2.7/SocketServer.py", line 417, in __init__
self.server_bind()
File "/usr/lib/python2.7/SocketServer.py", line 431, in server_bind
self ...