Skip to content

Commit 32070f8

Browse files
authored
Adding network troubleshooting doc. (#195)
* Adding network troubleshooting doc.
1 parent 04e2002 commit 32070f8

File tree

12 files changed

+130
-11
lines changed

12 files changed

+130
-11
lines changed

faq.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
- [How can I install the Unity Packages without starting from a template project?](#how-can-i-install-the-unity-packages-without-starting-from-a-template-project)
88
- [ROS-TCP Endpoint/Connector](#ros-tcp-endpointconnector)
99
- [How does the TCP Endpoint compare to Rosbridge Server?](#how-does-the-tcp-endpoint-compare-to-rosbridge-server)
10-
- [I receive a `Starting server on ...` message in my ROS terminal, but see a `SocketException: A connection attempt failed because the connected party did not respond after a period of time, or established connection failed because connected host has failed to respond.` in my Unity console.](#i-receive-a-starting-server-on--message-in-my-ros-terminal-but-see-a-socketexception-a-connection-attempt-failed-because-the-connected-party-did-not-respond-after-a-period-of-time-or-established-connection-failed-because-connected-host-has-failed-to-respond-in-my-unity-console)
1110
- [I'm getting the error: `...failed because unknown error handler name 'rosmsg'`.](#im-getting-the-error-failed-because-unknown-error-handler-name-rosmsg)
12-
- [Unity can't connect to ROS!](#unity-cant-connect-to-ros)
1311
- [URDF-Importer](#urdf-importer)
1412
- [I don't see an option to Import Robot from URDF, or I have compile errors upon importing the URDF-Importer.](#i-dont-see-an-option-to-import-robot-from-urdf-or-i-have-compile-errors-upon-importing-the-urdf-importer)
1513
- [Can't find what you're looking for?](#cant-find-what-youre-looking-for)
@@ -58,23 +56,16 @@ The time was logged when the message was sent from Unity before being serialized
5856
- ROS# with ROS Bridge Suite took ~2 seconds
5957
- TCP Connector with TCP Endpoint took ~0.17 seconds
6058

61-
I receive a `Starting server on ...` message in my ROS terminal, but see a `SocketException: A connection attempt failed because the connected party did not respond after a period of time, or established connection failed because connected host has failed to respond.` in my Unity console.
62-
---
63-
This is likely an issue with how your network adapters are set up if you are using a virtual machine. You may need to do some troubleshooting to ensure that your guest OS can talk to your host OS and vice versa. One simple way to do this is to set up a "Host-Only" style network, but this varies based on what virtualization software you're using. Try to ensure that you can `ping` your host OS's IP from inside the guest, and can `ping` the guest from the host, then try this last step again.
64-
6559
I'm getting the error: `...failed because unknown error handler name 'rosmsg'`.
6660
---
6761
This is due to a bug in an outdated package version. Try running `sudo apt-get update && sudo apt-get upgrade` to upgrade.
6862

69-
Unity can't connect to ROS!
70-
---
71-
Ensure that the ROS IP address is entered correctly as the `Host Name` in the RosConnect component in Unity, and if you are using a `params.yaml` file, that the appropriate IP addresses are filled in.
72-
7363
# URDF-Importer
7464

7565
I don't see an option to Import Robot from URDF, or I have compile errors upon importing the URDF-Importer.
7666
---
7767
The [ArticulationBody](https://docs.unity3d.com/2020.2/Documentation/Manual/class-ArticulationBody.html) has dependencies on Unity Editor versions [2020.2.0](https://unity3d.com/unity/whats-new/2020.2.0)+. Try updating your project to the latest 2020.2 release.
7868

69+
7970
# Can't find what you're looking for?
8071
Connect directly with the Robotics team at [unity-robotics@unity3d.com](mailto:unity-robotics@unity3d.com)!

tutorials/pick_and_place/2_ros_tcp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
140140

141141
- If you are **not** running ROS services in a Docker container, replace the `ROS IP Address` value with the IP address of your ROS machine. Ensure that the `Host Port` is set to `10000`.
142142

143-
- If you **are** running ROS services in a Docker container, fill `ROS IP Address` and `Override Unity IP Address` with the loopback IP address `127.0.0.1`. Otherwise, leave the `Override Unity IP Address` field empty.
143+
- If you **are** running ROS services in a Docker container, fill `ROS IP Address` with the loopback IP address `127.0.0.1` and the `Override Unity IP Address` as your local machine's IP address. Otherwise, leave the `Override Unity IP Address` field empty.
144144

145145
![](img/2_settings.png)
146146

tutorials/ros_unity_integration/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ The `ROSConnection` plugin (also from [ROS TCP Connector](https://github.com/Uni
1414

1515

1616
## Tutorials
17+
- [ROS–Unity Integration: Initial Setup](setup.md) - ROS-Unity Initial Setup
18+
- [ROS–Unity Integration: Network Description](network.md) - Description of network settings and troubleshooting
1719
- [ROS–Unity Integration: Publisher](publisher.md) - Adding a Publisher to a Unity Scene
1820
- [ROS–Unity Integration: Subscriber](subscriber.md) - Adding a Subscriber to a Unity Scene
1921
- [ROS–Unity Integration: Service](service.md) - Adding a Service call to a Unity Scene
43.8 KB
Loading
124 KB
Loading
45 KB
Loading
127 KB
Loading
139 KB
Loading
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# ROS–Unity Integration Networking
2+
3+
## Table of Contents
4+
- [Definitions](#definitions)
5+
- [Communicaton Minimum Requirements](#communication-minimum-requirements)
6+
- [If Using Docker](#if-using-docker)
7+
- [Explicitly Setting UNITY_IP](#explicitly-setting-unity_ip)
8+
- [Troubleshoooting](#troubleshooting)
9+
- [Where Does Communication Break Down](#where-does-communication-break-down)
10+
- [1. Can Unity send messages to ROS?](#1-can-unity-send-messages-to-ros)
11+
- [2. Can ROS send messages to Unity?](#2-can-ros-send-messages-to-unity)
12+
- [Open Port on Windows Firewalll](#open-port-on-windows-firewall)
13+
14+
# Definitions
15+
16+
`ROS_IP` : The IP address of the machine, VM, or container running ROS.
17+
18+
`UNITY_IP` : The IP address of the machine running Unity.
19+
20+
> It is possible to set both of these variables on the machines running Unity and ROS. The specifics of where and why each of these settings will be described below.
21+
22+
On the ROS machine these settings are set as a rosparam and will typically be set in a launch file like [this](https://github.com/Unity-Technologies/Unity-Robotics-Hub/blob/main/tutorials/ros_packages/robotics_demo/launch/robo_demo.launch) or in a [param file](https://github.com/Unity-Technologies/Unity-Robotics-Hub/blob/main/tutorials/pick_and_place/ROS/src/niryo_moveit/config/params.yaml) loaded by a launch file like [this](https://github.com/Unity-Technologies/Unity-Robotics-Hub/blob/main/tutorials/pick_and_place/ROS/src/niryo_moveit/launch/part_3.launch#L2). The param file can also be loaded manually by running the `rosparam load params.yaml` command.
23+
24+
On the Unity machine these settings are set from the menu by going to `Robotics` -> `ROS Settings`
25+
26+
27+
# Communication Minimum Requirements
28+
29+
The minimum settings required for Unity to communicate with ROS is to set the `ROS_IP` on the ROS side in a launch file and on the Unity side in `Robotics` -> `ROS Settings`.
30+
31+
## If Using Docker
32+
33+
The container will need to be started with the following arguments to forward the ports used for communication between ROS and Unity.
34+
35+
`-p 10000:10000 -p 5005:5005`
36+
37+
38+
- On the ROS side, set `ROS_IP` to `0.0.0.0`.
39+
40+
- On the Unity side, set `ROS_IP` to `127.0.0.1` and the `Override Unity IP Address` to your local machine's IP address.
41+
42+
![](images/troubleshoot-docker-unity.png)
43+
44+
## Explicitly setting `UNITY_IP`
45+
46+
The `UNITY_IP` can be set in two different places.
47+
48+
1. If set on the ROS side as a rosparam, the `server_endpoint` will only use this IP to send messages to Unity.
49+
1. If set on the Unity side as the `Override Unity IP Address`, the `UNITY_IP` on the ROS side will be set to this value during the initial handshake between ROS and Unity once play is pressed in the Editor.
50+
51+
> If the `UNITY_IP` is not set in either of these places, then the IP that makes the first connection to ROS during the initial handshake will be used.
52+
53+
# Troubleshooting
54+
55+
## Where Does Communication Break Down
56+
57+
### 1. Can Unity send messages to ROS?
58+
59+
When play is pressed in the Editor, a handshake message is sent from Unity to ROS.
60+
61+
If Unity can communicate with ROS, the following message should be printed to the console screen running the `server_endpoint.py` script.
62+
63+
```[UnityTcpSender]: ROS-Unity Handshake received, will connect to UNITY_IP_ADDRESS:5005```
64+
65+
With the corresponding response message printed to the Unity console,
66+
67+
```ROS-Unity server listening on UNITY_IP_ADDRESS:5005```
68+
69+
70+
If the previous message is not shown and either of the following errors are thrown instead:
71+
72+
```
73+
SocketException: A connection attempt failed because the connected party did not respond after a period of time, or established connection failed because connected host has failed to respond.
74+
```
75+
76+
```
77+
SocketException: Connection refused
78+
```
79+
80+
Confirm that:
81+
82+
- `server_endpoint` is running
83+
- You can ping ROS machine from Unity machine
84+
- From a terminal on the Unity machine, run the following command to confirm whether the ROS machine is reachable over the network. ```ping ROS_IP```
85+
86+
If issue still persists:
87+
88+
- Confirm your IP addresses
89+
- If on Windows you may need to [open ports for the firewall](#open-port-on-windows-firewall).
90+
91+
### 2. Can ROS send messages to Unity?
92+
93+
After it is confirmed that Unity can communicate with ROS, publish a message to a ROS topic to which Unity has instantiated a subscriber.
94+
95+
If an error is thrown in the `server_endpoint` console then ROS cannot connect to Unity.
96+
97+
If issue still persists:
98+
99+
- Confirm your IP addresses
100+
- Explicitly set the `UNITY_IP`
101+
- If on Windows you may need to [open ports for the firewall](#open-port-on-windows-firewall).
102+
103+
## Open port on Windows Firewall
104+
- Open port in Windows Firewall by opening `Windows Defender Firewall` then selecting `Action` -> `New Rule...`
105+
- Port `10000` will need to be added as an outbound rule
106+
- Port `5005` will need to obe added as an inbound rule
107+
108+
![](images/troubleshoot-port-firewall.png)
109+
110+
In some instances opening a port did not resolve the communication issues and the Unity Editor had to be allowed through the firewall
111+
112+
- Allow the Editor through the firewall by opening `Windows Defender Firewall` -> `Allowed Apps` and then modifying the settings for the Unity Editor to allow communication on private and public networks.
113+
114+
![](images/troubleshoot-unity-firewall.png)
115+
116+
117+
118+
119+

tutorials/ros_unity_integration/publisher.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public class RosPublisherExample : MonoBehaviour
9999

100100
- Pressing play in the Editor should publish a message to the terminal running the `rostopic echo pos_rot` command every 0.5 seconds
101101

102+
> Please reference [networking troubleshooting](network.md) doc if any errors are thrown.
103+
102104
![](images/tcp_1.gif)
103105

104106
Continue to the [ROS Subscriber](subscriber.md) tutorial.

0 commit comments

Comments
 (0)