0
$\begingroup$

Rosanswers logo

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

Originally posted by roy on ROS Answers with karma: 33 on 2017-07-31

Post score: 1


Original comments

Comment by M@t on 2017-07-31:
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.

Comment by gvdhoorn on 2017-08-01:
@roy: could you also add the values of ROS_MASTER_URI, ROS_IP and ROS_HOSTNAME?

Comment by gvdhoorn on 2017-08-01:
It probably shouldn't matter, but can you remove the two forward-slashes (/) at the end of ROS_MASTER_URI and try again?

Comment by roy on 2017-08-01:
ROS_IP is empty for some reason. Do I need to set this somewhere?

Comment by gvdhoorn on 2017-08-01:
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.

Comment by gvdhoorn on 2017-08-01:
Where does the source suffix on ROS_HOSTNAME come from?

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

Comment by roy on 2017-08-01:
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

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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

Originally posted by gvdhoorn with karma: 86574 on 2017-08-01

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by roy on 2017-08-01:
Awesome, it worked. Although the error messages printed out doesn't seem to be very relevant to the issue.

Thank you very much!

Comment by gvdhoorn on 2017-08-01:
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.

Comment by Milin on 2020-04-17:
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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.