Setup ROS Connection between Robot and PC

I’m trying to connect my pc to ur5 with an ethernet cable. When I tried to run a program from the pendant, a popup shows “The connection to the remote PC at 172.22.22.1:50002 could not be established. Reason: Connection refused.”

I checked the firewall. The status is disabled.

Even, pinging the IP addresses is also working. Not sure, why the error says connection refused.

Please let me know, what might be the error?

Thank you in advance!

1 Like

Hi @dinesh,

More information is needed about your setup to help you here as there are many ways that a PC can interact with a UR robot. Are you talking about a ROS connection here?

Yes, it’s a ROS connection.

Ok I have edited your title and moved the question to the ROS category to increase visibility.

Thank you.

I’m also getting an error when I use this command:

roslaunch ur_robot_driver ur5_bringup.launch robot_ip:=172.22.22.2 [reverse_port:=REVERSE_PORT] kinematics_config:=${HOME}/my_robot_calibration.yaml

Error:
[ INFO] [1635804505.717563440]: Waiting for controller manager service to come up on /controller_manager/switch_controller
[ INFO] [1635804505.721090337]: Initializing dashboard client
[ INFO] [1635804505.722433840]: waitForService: Service [/controller_manager/switch_controller] has not been advertised, waiting…
[ INFO] [1635804505.724842974]: Connected: Universal Robots Dashboard Server.

[ INFO] [1635804505.736611855]: waitForService: Service [/ur_hardware_interface/dashboard/play] has not been advertised, waiting…
[ INFO] [1635804505.748223083]: Initializing urdriver
[ WARN] [1635804505.749180976]: No realtime capabilities found. Consider using a realtime system for better performance
[ INFO] [1635804505.759193665]: waitForService: Service [/ur_hardware_interface/dashboard/play] is now available.
[INFO] [1635804506.051336]: Controller Spawner: Waiting for service controller_manager/load_controller
[INFO] [1635804506.089773]: Controller Spawner: Waiting for service controller_manager/load_controller
[ INFO] [1635804506.197248908]: Negotiated RTDE protocol version to 2.
[ INFO] [1635804506.197940857]: Setting up RTDE communication with frequency 125.000000
[ INFO] [1635804507.221189952]: Checking if calibration data matches connected robot.
[ WARN] [1635804507.221904867]: No realtime capabilities found. Consider using a realtime system for better performance
[ INFO] [1635804508.317021240]: Calibration checked successfully.
[ WARN] [1635804508.344000205]: No realtime capabilities found. Consider using a realtime system for better performance
[ INFO] [1635804508.344302293]: Loaded ur_robot_driver hardware_interface
terminate called after throwing an instance of ‘std::runtime_error’
what(): Did not find ‘target_q’ in data sent from robot. This should not happen!
[ INFO] [1635804508.386043241]: waitForService: Service [/controller_manager/switch_controller] is now available.
[ INFO] [1635804508.386066908]: Service available.
[ INFO] [1635804508.386077734]: Waiting for controller list service to come up on /controller_manager/list_controllers
[ INFO] [1635804508.386746135]: Service available.
[WARN] [1635804508.478895]: wait_for_service(/controller_manager/load_controller): failed to contact, will keep trying
[WARN] [1635804508.519313]: wait_for_service(/controller_manager/load_controller): failed to contact, will keep trying

================================================================================

REQUIRED process [ur_hardware_interface-3] has died!
process has died [pid 15343, exit code -6, cmd /home/dinesh/mr_ws/devel_isolated/ur_robot_driver/lib/ur_robot_driver/ur_robot_driver_node __name:=ur_hardware_interface __log:=/home/dinesh/.ros/log/3ba61f5c-3b60-11ec-b81c-3c2c30f01a2e/ur_hardware_interface-3.log].
log file: /home/dinesh/.ros/log/3ba61f5c-3b60-11ec-b81c-3c2c30f01a2e/ur_hardware_interface-3*.log
Initiating shutdown!

================================================================================

[ur_hardware_interface/ur_robot_state_helper-7] killing on exit
[controller_stopper-6] killing on exit
[ros_control_stopped_spawner-5] killing on exit
[ros_control_controller_spawner-4] killing on exit
[ur_hardware_interface-3] killing on exit
[robot_state_publisher-2] killing on exit
[WARN] [1635804508.754701]: Controller Spawner couldn’t find the expected controller_manager ROS interface.
[WARN] [1635804508.817489]: Controller Spawner couldn’t find the expected controller_manager ROS interface.
^C[controller_stopper-6] escalating to SIGTERM
[rosout-1] killing on exit
[master] killing on exit
shutting down processing monitor…
… shutting down processing monitor complete
done

If you haven’t already, I’d recommend looking through previously addressed issues on the driver github repository to see if anything matches your problem. If you can’t find anything then raising the issue there would make sense.

Any update on this? Has it been solved, I have the same issue.

Solved this by opening the port on the PC with nc -lk 50002

1 Like

Same here. “nc -lk 50002” did not work. Any other solution?

First of all: Which ROS version are we talking about? What is your network setup? Usually this can happen when

  • The wrong PC address is configured on the teach pendant
  • There is a firewall blocking access on the ROS machine
  • The reverse port has been altered on the ROS side, but not on the robot
  • The ROS machine is not reachable on the device that the port is opened for (this can happen for example in a VM/Docker NAT situation

Therefore, in order to assist you in finding a solution, we would have to know a bit more about your system setup.

Hey, thanks for replying and sorry for not elaborating.
I am working on ROS2 Foxy, my network setup is UR3e (192.168.0.4) > router > PC (Ubuntu with IP 192.168.0.2 and another network for docker with IP 172.17.0.1) > ROS2 (through docker with IP 172.17.0.2)

  • I set up host IP on the robot 192.168.0.2, and robot’s IP 192.168.0.4

  • I installed the external control urcap

  • I tried with both enable/disable remote control, and with both local/remote control on teach pendant

  • Firewall is disabled (sudo ufw status: inactive)

  • I run

ros2 launch ur_bringup ur_control.launch.py ur_type:=ur5e robot_ip:=192.168.0.4 launch_rviz:=true reverse_ip:=192.168.0.2
  • ping 192.168.0.4 shows successful connection

  • Also when I connect to the robot through ssh, and I ping 192.168.0.2 shows successful connection.

  • I also tried with setting as host IP the docker’s IP: 172.17.0.2 and the robot’s IP: 172.17.0.3 but this doesnt even ping.

For all these, the error is the same: Connection refused.
Attached is my installation and program configuration.

Thank you for your time,

URconfig.zip (3.7 KB)

1 Like

If you run the driver inside your docker container you’ll have to make sure that the robot can reach it either by adding some routing schemes or by using port forwarding when starting your docker container.

For example, the robot will try to connect to port 50002. The ROS driver will open this port inside the docker container, but this will not be visible for machines outside of the docker network.

From my experience with docker the most straight-forward solution would be to forward ports 50001, 50002 and 50003 from the host to the docker machine (add -p 50001-50003:50001-50003 to your docker startup command)

1 Like

This saved my day @mauch thank you a lot!

There is however another problem now. Even though I am able to connect to the robot (and even visualize its pose in rviz), when I try

ur_moveit.launch.py

the robot start state is in a colliding state, and thus there is no way I can plan any trajectory since every state seems to be colliding.

Any idea why is this happening? I may post this question as a different post, if this proves to be an independent from the port issue

PS. On the end effector I have a tool (VGC10) I haven’t yet configured in ROS. Does this creates any problem?

The robot should not by default start in a colliding state. However, you could try moving the robot to a different configuration and try again. If that doesn’t help, I guess we would need more info of how it is colliding (screenshot, output…) But yes, I think this is better suitable for a new post

Good morning, i have the same problem but with a different configuration and i wonder if the problem could be solved in the same way.
I have an UR3 (CB series) on top of a MIR (mobile robot), and i want to connect them both on ROS, so i have the ethernet cable that goes from the UR to the MIR, so they are connected, and then i connect the computer to the MIR Wi-Fi, so the IP of the MIR is 192.168.12.20, the IP of the robot if 192.168.12.2 and the IP of the host computer is 192.168.12.192. In the teach pendant, i wrote in the Host IP of the URcap the Host computer’s IP, but the problem is that after i launch the command ‘roslaunch ur_robot_driver ur3_bringup.launch robot_ip:=192.168.12.2 kinematics_config:=$(rospack find ur_calibration)/ur3_robot_calibration.yaml’ (that runs correctly), if i then try to run the URcap program on the teach pendant it tells me ‘the connection to the remote PC at 192.168.12.192:50002 could not be established. reason:connect timed out’. If i ping the UR’IP from ROS i can see it, but the UR does not see the computer.
EDIT: i found out that i had an active firewall, so i disabled it, and now i have this new error:

[ INFO] [1721124400.383903627]: Robot connected to reverse interface. Ready to receive control commands.
[ INFO] [1721124400.603082789]: Connection to reverse interface dropped.
[ERROR] [1721124400.603212743]: Sending data through socket failed.
[ INFO] [1721124400.612000570]: Robot connected to reverse interface. Ready to receive control commands.
[ INFO] [1721124400.898997001]: Connection to reverse interface dropped.
[ INFO] [1721124400.904126649]: Robot connected to reverse interface. Ready to receive control commands.
[ INFO] [1721124403.044618221]: Connection to reverse interface dropped.
[ERROR] [1721124403.044718419]: Sending data through socket failed.

So i guess is one of the other two problems that mauch pointed, what i have to do in order so solve them? thank you in advance