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

roslaunch erros out when trying to launch master when master is already running via roscore

asked 2017-07-31 23:17:46 -0500

roy gravatar image

updated 2017-08-01 01:09:27 -0500

gvdhoorn gravatar image

Guys,

I am having this issue where I can't use roslaunch command because every time I run something like:

roslaunch ros_robotics ddrobot_rviz.launch model:=dd_robot.urdf

it will error out with following message:

started roslaunch server http://localhost:34665/

SUMMARY

PARAMETERS
 * /joint_state_publisher/use_gui: True
 * /robot_description: <?xml version="1....
 * /rosdistro: kinetic
 * /rosversion: 1.12.7

NODES
  /
    joint_state_publisher (joint_state_publisher/joint_state_publisher)
    robot_state_publisher (robot_state_publisher/state_publisher)
    rviz (rviz/rviz)

auto-starting new master
process[master]: started with pid [2401]
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 0x7f38a45133d0>>
Traceback (most recent call last):
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/xmlrpc.py", line 215, in run
    self._run()
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/xmlrpc.py", line 284, in _run
    self._run_init()
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/xmlrpc.py", line 234, in _run_init
    self.server = ThreadingXMLRPCServer((bind_address, port), log_requests)
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/xmlrpc.py", line 115, 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.socket.bind(self.server_address)
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use
ERROR: could not contact master [http://localhost:11311//]
The traceback for the exception was written to the log file
[master] killing on exit

It seems that roslaunch tries to launch a master server while there is already one running in another terminal window.

Any idea how to resolve this?

Thanks!

As requested, this launch file might be helpful. That said, this issue is not specific to this particular launch file. Every launch file on my system errors out like this.

<launch>
  <!-- set parameter on Parameter Server -->
  <arg name="model" />
  <param name="robot_description"
    command="$(find xacro)/xacro.py '$(find ros_robotics)/urdf/$(arg model)'" />

  <!-- send joint values from gui -->
  <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
    <param name="use_gui" value="TRUE"/>
  </node>

  <!-- use joint positions to update tf -->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>

  <!-- visualize robot model in 3D -->
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find ros_robotics)/urdf.rviz" required="true" />

</launch>

Roy


Edit: @gvdhoorn

 roy@RoysMacUbuntu:~/catkin_ws/src/ros_robotics/urdf$ printenv | grep ROS
ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_PACKAGE_PATH=/opt/ros/kinetic/share
ROS_MASTER_URI=http://localhost:11311//
ROS_HOSTNAME=localhostsource
ROSLISP_PACKAGE_DIRECTORIES=
ROS_DISTRO=kinetic
edit retag flag offensive close merge delete

Comments

I might not be able to help much, but if you can post the roslaunch files in question (or links to them) that will definitely help others debug the issue.

M@t gravatar image M@t  ( 2017-07-31 23:47:12 -0500 )edit

@roy: could you also add the values of ROS_MASTER_URI, ROS_IP and ROS_HOSTNAME?

gvdhoorn gravatar image gvdhoorn  ( 2017-08-01 00:48:59 -0500 )edit

It probably shouldn't matter, but can you remove the two forward-slashes (/) at the end of ROS_MASTER_URI and try again?

gvdhoorn gravatar image gvdhoorn  ( 2017-08-01 01:07:41 -0500 )edit

ROS_IP is empty for some reason. Do I need to set this somewhere?

roy gravatar image roy  ( 2017-08-01 01:08:50 -0500 )edit

ROS_IP is only needed if you don't have a working DNS for all involved hosts. If you're not running a multi-host ROS setup -- and localhost resolves to the proper IP -- then it's not needed.

gvdhoorn gravatar image gvdhoorn  ( 2017-08-01 01:10:35 -0500 )edit

Where does the source suffix on ROS_HOSTNAME come from?

Are you setting any of these variables yourself -- in your .bashrc fi?

gvdhoorn gravatar image gvdhoorn  ( 2017-08-01 01:11:09 -0500 )edit

Here are ROS related lines in my.bashrc: source /opt/ros/kinetic/setup.bash source ~/catkin_ws/devel/setup.bash

export ROS_MASTER_URI=http://localhost:11311// export ROS_HOSTNAME=localhostsource /opt/ros/kinetic/setup.bash

roy gravatar image roy  ( 2017-08-01 01:13:37 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-08-01 01:17:40 -0500

gvdhoorn gravatar image

Here are ROS related lines in my .bashrc:

source /opt/ros/kinetic/setup.bash
source ~/catkin_ws/devel/setup.bash

export ROS_MASTER_URI=http://localhost:11311//
export ROS_HOSTNAME=localhostsource /opt/ros/kinetic/setup.bash

If that is really a copy-paste of your .bashrc then it would seem something went wrong while adding those lines (there was most likely a new-line missing after the export ROS_HOSTNAME line).

If you don't have a particular reason to set ROS_MASTER_URI and ROS_HOSTNAME to those values (localhost is already the default), then I would recommend to remove the export .. lines from your .bashrc, save it, open a new terminal and try starting your launch file again.

So your .bashrc should look like this (at the end, after all the normal stuff that is already there):

source /opt/ros/kinetic/setup.bash
source ~/catkin_ws/devel/setup.bash
edit flag offensive delete link more

Comments

Awesome, it worked. Although the error messages printed out doesn't seem to be very relevant to the issue.

Thank you very much!

roy gravatar image roy  ( 2017-08-01 01:21:40 -0500 )edit

Well, in a way the error message tells you that it can't connect to any -- already running -- master instance. That is true, as the env vars that influence the network config of ROS were incorrectly set. If it can't find a running master, roslaunch will start one itself. But as there already was one running, it ran into a socket.error: [Errno 98] Address already in use error (which makes sense).

I think the fact that ROS_MASTER_URI was set to localhost:11311// (notice the two forward-slashes) also didn't help.

gvdhoorn gravatar image gvdhoorn  ( 2017-08-01 01:23:48 -0500 )edit

I was facing the same problem. I removed the export.. things from my .bashrc after seeing your answer and it worked. Thank you for your suggestion.

Milin gravatar image Milin  ( 2020-04-17 13:52:18 -0500 )edit

Question Tools

Stats

Asked: 2017-07-31 23:17:46 -0500

Seen: 6,516 times

Last updated: Aug 01 '17