Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Can't estabilish connection between ROS and Unity

Discussion in 'Robotics' started by xdavidheredia99, Jun 15, 2021.

  1. xdavidheredia99

    xdavidheredia99

    Joined:
    May 9, 2021
    Posts:
    4
    Hi everyone,

    I'm trying to estabilish a connection between ROS and unity using https://github.com/Unity-Technologies/ROS-TCP-Connector . I've followed the tutorial steps in https://github.com/Unity-Technologi...ain/tutorials/ros_unity_integration/README.md but after installing the package ros-tcp-connector package via git url in unity (2021.1.6f1) I'm not able to set UNITY_IP for connection. When I open Robotics -> Ros Settings in unity I haven't option to override/set it.

    Attached photo of Robotics -> Ros Settings window:
    Captura de pantalla de 2021-06-11 13-50-31.png
    For more information I'm trying to connect an urdf charged Baxter Robot in unity and using ROS noetic. Thanks in advance.
     
  2. lorenz_gunreben

    lorenz_gunreben

    Joined:
    May 17, 2021
    Posts:
    6
    Hi!

    I'm working on a similar task with the Kuka Iiwa and got similar problems.
    Concerning your question: I think that they removed the "Override Unity Address" textfield in version 0.4.0. I'm not sure what exactly it does and why they removed it, I remember that I've read about it.

    You can try the older one but that didn't work for me either:
    If you already tried the pick&place tutorial, you can find the 0.3.0 version at:

    pick_and_place\Unity-Robotics-Hub\tutorials\pick_and_place\PickAndPlaceProject\Library\PackageCache\com.unity.robotics.ros-tcp-connector@8ee9d5c391

    You can simply import it with the package manager by selecting "Add package from disk" and selecting the package.json.
    It will import the older version where you should find the textfield.

    For now I got the pick&place tutorial communicating with my ROS-VM using the 0.3.0 ROS-TCP-Connector, but currently I'm failing to establish a connection in a custom project.
    Are you using a virtual machine or are you using docker?

    We can stay in conctact, if we get any further
     
  3. LaurieUnity

    LaurieUnity

    Unity Technologies

    Joined:
    Oct 23, 2020
    Posts:
    77
    Yes, UNITY_IP and the "Override Unity IP" setting have been removed as of 0.4.0 - they're no longer necessary, we just use one TCP connection now (from Unity to the ROS endpoint) so we don't need a separate IP address for Unity to listen on.

    I'm not sure what version of the instructions you're following, but the page you linked to does not mention them. :)

    If you're having trouble getting the connection to work, I'd start by making sure your ros-tcp-endpoint and ros-tcp-connector package are both on version 0.4.0. If that's all ok, please provide more details about your setup and what results you're getting, hopefully we can help.
     
    Last edited: Jun 15, 2021
  4. xdavidheredia99

    xdavidheredia99

    Joined:
    May 9, 2021
    Posts:
    4
    First of all, thanks for anwering guys.
    As Laurie says, it looks like I don't have to use the Override Unity IP using the newest version of the package and I think I don't understand how the connection takes place so. Both packages are in their more recent version.

    I'm running unity in the same machine as ROS in Ubuntu 20, without docker. First, I've run "roslaunch src/ROS-TCP-Endpoint-main/launch/endpoint.launch" specifyng: ROS_IP: 127.0.0.1 and ROS_TCP_PORT: 10000 for having the ROS-side connection. In Unity the configuration is shown in the first post.

    I think I'm losing some small details. Thanks in advance!
     
  5. LaurieUnity

    LaurieUnity

    Unity Technologies

    Joined:
    Oct 23, 2020
    Posts:
    77
    Ok, so to fill you in, the connection is just a standard TCP socket connection: the ROS-TCP-Endpoint listens on the specified IP and port, and Unity connects to it.

    If they're both running on the same machine the setup you described sounds like it should work fine. What happens when you press Play in Unity? Do you see the ROS Connection hud in the top left corner of the game window?
     
  6. xdavidheredia99

    xdavidheredia99

    Joined:
    May 9, 2021
    Posts:
    4
    The uploaded image shows what I see when I press the play button. In the image you can't see Baxter robot because it falls down (another error I have to solve next). Endpoint node doesn't show anything appart from the first message of initialization:
    [INFO] [1624108390.486068]: Starting server on 127.0.0.1:10000

    Captura de pantalla de 2021-06-19 15-18-32.png
     
  7. amanda-unity

    amanda-unity

    Unity Technologies

    Joined:
    May 29, 2020
    Posts:
    19
    @xdavidheredia99, it looks like you're missing something in your Unity scene hierarchy that will actually instantiate the ROSConnection, i.e. something that will call ROSConnection.instance. You can view the ROS Publisher example for reference, or the Pick-and-Place demo (Part 2) for more information on this connection setup. Modifying your ROS Settings should create a ROSConnectionPrefab in your project's Assets/Resources, and calling upon the ROSConnection.instance should instantiate this prefab in your scene on runtime.
     
    Envilon likes this.
  8. xdavidheredia99

    xdavidheredia99

    Joined:
    May 9, 2021
    Posts:
    4
    Thanks for answering Amanda.
    You were right, I had to instance the Ros Connection and, for some reason, I thought that It will work without doing it. Now, after the tutorials, I understand how it works. I'll continue trying to connect baxter and unity.
    Thanks again!