Hello there,
I am trying to subscribe messages published from ROS into Unity. I am using a PC with Ubuntu 18.04. I have ROS Melodic and Unity 2021.3.23f1 installed. Also, ROS TCP Endpoint git cloned (without any versioning or git checkout) then, built into my catkin workspace and ROS TCP Connector installed into Unity using package manager via GIT URL (both ROS TCP Endpoint and Connector is 0.7.0). I have implemented both publisher (on ROS side with Python) and subscriber (Unity side with C#) then, prepared my Unity scene. First, i have through ROS Settings at the âroboticsâ tab, have set ROS IP address to 127.0.0.1 and kept ROS Port as 10000. Then, added two empty game objects. After that, added ROSConnection script included in ROS Connection package as component of one of these empty game objects and subscriber as component of the other one. I didnât forget to set ROS IP Address to 127.0.0.1 and Port to 10000 under ROS Connection (Script) field. Later on, i wanted to test it. Through terminal i have entered the command: âroscoreâ and opened a new tab at that terminal then, ran the publisher there. After that, when i pressed that play button to run the Unity side i have encountered this error looping on my Unity console: "
Connection to 127.0.0.1:10000 failed - System.Net.Sockets.SocketException (0x80004005): Connection refused
at System.Net.Sockets.TcpClient.Connect (System.String hostname, System.Int32 port) [0x0019d] in :0
"
Thatâs the log if i am not mistaken:
"
Connection to 127.0.0.1:10000 failed - System.Net.Sockets.SocketException (0x80004005): Connection refused
at System.Net.Sockets.TcpClient.Connect (System.String hostname, System.Int32 port) [0x0019d] in :0
at Unity.Robotics.ROSTCPConnector.ROSConnection.ConnectionThread (System.String rosIPAddress, System.Int32 rosPort, System.Single networkTimeoutSeconds, System.Single keepaliveTime, System.Int32 sleepMilliseconds, System.Action1[T] OnConnectionStartedCallback, System.Action DeregisterAll, Unity.Robotics.ROSTCPConnector.ROSConnection+OutgoingMessageQueue outgoingQueue, System.Collections.Concurrent.ConcurrentQueue1[T] incomingQueue, System.Threading.CancellationToken token) [0x000b2] in /home/baran/liveFeedToVR/Library/PackageCache/com.unity.robotics.ros-tcp-connector@c27f00c6cf/Runtime/TcpConnector/ROSConnection.cs:790
UnityEngine.Debug:Log (object)
Unity.Robotics.ROSTCPConnector.ROSConnection/d__115:MoveNext () (at Library/PackageCache/com.unity.robotics.ros-tcp-connector@c27f00c6cf/Runtime/TcpConnector/ROSConnection.cs:854)
System.Threading._ThreadPoolWaitCallback:PerformWaitCallback ()
"
These are my ROS parameters:
ROS_IP: 127.0.0.1
ROS_MASTER_URI: http://127.0.0.1:10000
ROS_HOSTNAME: 127.0.0.1
*** Note: ****
If i open another terminal and enter: âroslaunch ros_tcp_endpoint endpoint.launchâ before i press the play button in Unity, i can see the icon in front of ROS_IP is blue, i can get messages into Unity as i want and donât get any errors. But, unfortunately i donât have such an option for my case. Since, i need to get Unity side to connect to ROS at the start without any terminal or prompt. Just as it should have when using ROSConnection script.
Thanks in advance all the support you have offered.