Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. 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
  3. Dismiss Notice

Question Holoens 2 doesn't connect to ROS

Discussion in 'Robotics' started by RendergonPolygons, Dec 15, 2022.

  1. RendergonPolygons

    RendergonPolygons

    Joined:
    Oct 9, 2019
    Posts:
    98
    I follow docker ros setup with ROS IP Address 127.0.0.1 and in Unity editor it works fine, ROS console receives the data from Unity. When I export the release to Hololens 2 the H2 device doesn't publish to ROS console. Any ideas please?

    upload_2022-12-15_10-36-51.png

    I'm on Unity Version: Unity 2022.1.24, Unity Robotics hub branch 0.7.0-preview as per repo.
     
  2. Envilon

    Envilon

    Joined:
    Aug 8, 2020
    Posts:
    55
    I'm unfamiliar with how Hololens 2 work. Is it connected to a PC and only displays the output, or do you build your project as a standalone application, and it runs directly on Hololens 2?

    If it runs directly on Hololens, and you run ROS in Docker on your PC, the localhost IP (127.0.0.1) won't work.
     
  3. RendergonPolygons

    RendergonPolygons

    Joined:
    Oct 9, 2019
    Posts:
    98
    Thank you @Envilon . I run H2 wirelessly and build the project as a standalone app and runs directly on H2. I run docker on PC yes.

    Away from docker on Windows I've tried setup ros melodic manually in Ubuntu (VirtualBox and Ubuntu 18.04.6 LTS), it should connect to Unity run from editor in my win11 desktop too. But I fail to get ros-unity connection, yet all seems fine on Ubuntu but connection fail for Unity. I've disconnected my win11 firewall:

    Unity:
    Connection to 10.0.2.15:10000 failed - System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.


    ROS in ubuntu - Test 1:
    sergio@sergio-VirtualBox:~$ hostname -I
    10.0.2.15

    So my src/niryo_moveit/config/params.yaml has ROS_IP: 10.0.2.15
    sergio@sergio-VirtualBox:~/IoT/Unity-Robotics-Hub/tutorials/pick_and_place/ROS$ roslaunch niryo_moveit part_2.launch
    ... logging to /home/sergio/.ros/log/54bc5532-7de1-11ed-9ffc-0800270c95d8/roslaunch-sergio-VirtualBox-7952.log
    Checking log directory for disk usage. This may take a while.
    Press Ctrl-C to interrupt
    Done checking log file disk usage. Usage is <1GB.
    started roslaunch server http://sergio-VirtualBox:37577/
    SUMMARY
    ========
    PARAMETERS
    * /rosdistro: melodic
    * /rosversion: 1.14.13
    * /server_endpoint/tcp_ip: 0.0.0.0
    * /server_endpoint/tcp_port: 10000
    NODES
    /
    server_endpoint (ros_tcp_endpoint/default_server_endpoint.py)
    trajectory_subscriber (niryo_moveit/trajectory_subscriber.py)
    auto-starting new master
    process[master]: started with pid [7962]
    ROS_MASTER_URI=http://localhost:11311
    setting /run_id to 54bc5532-7de1-11ed-9ffc-0800270c95d8
    process[rosout-1]: started with pid [7973]
    started core service [/rosout]
    process[server_endpoint-2]: started with pid [7980]
    process[trajectory_subscriber-3]: started with pid [7981]
    [INFO] [1671264226.762721]: Starting server on 0.0.0.0:10000


    Then I also tried with in Ubuntu - Test 2:
    sergio@sergio-VirtualBox:~/IoT/Unity-Robotics-Hub/tutorials/pick_and_place/ROS$ roslaunch niryo_moveit part_2.launch tcp_ip:=10.0.2.15 tcp_port:=10000
    ... logging to /home/sergio/.ros/log/64057a5a-7de1-11ed-9ffc-0800270c95d8/roslaunch-sergio-VirtualBox-8010.log
    Checking log directory for disk usage. This may take a while.
    Press Ctrl-C to interrupt
    Done checking log file disk usage. Usage is <1GB.
    started roslaunch server http://sergio-VirtualBox:40633/
    SUMMARY
    ========
    PARAMETERS
    * /rosdistro: melodic
    * /rosversion: 1.14.13
    * /server_endpoint/tcp_ip: 10.0.2.15
    * /server_endpoint/tcp_port: 10000
    NODES
    /
    server_endpoint (ros_tcp_endpoint/default_server_endpoint.py)
    trajectory_subscriber (niryo_moveit/trajectory_subscriber.py)
    auto-starting new master
    process[master]: started with pid [8020]
    ROS_MASTER_URI=http://localhost:11311
    setting /run_id to 64057a5a-7de1-11ed-9ffc-0800270c95d8
    process[rosout-1]: started with pid [8031]
    started core service [/rosout]
    process[server_endpoint-2]: started with pid [8037]
    process[trajectory_subscriber-3]: started with pid [8039]
    [INFO] [1671264252.245165]: Starting server on 10.0.2.15:10000


    And Unity has Robotics->ROS Settings-> ROS IP Address: 10.0.2.15 with port 10000

    Can you share some guidance what may be wrong?

    Thank you! Sergio
     
    Last edited: Dec 17, 2022
  4. Envilon

    Envilon

    Joined:
    Aug 8, 2020
    Posts:
    55
    It's hard for me to give you exact advice because I don't know how your local network between these devices is structured, and networking was always my weak spot. But if I were you, I would take a step back from Unity and ROS and first try to verify that the devices/virtual machines can connect to each other via SSH first.

    So for your 'Unity on Windows <-> ROS on Ubuntu Virtual Machine' setup, I would first try to SSH from windows to that virtual machine (make sure the SSH port is open) to check if that IP is reachable. This should be an easier problem to tackle.

    If you can't SSH to that Ubuntu Virtual Machine, you might be trying to connect to the wrong IP address, or it is not accessible from outside VirtualBox (check how VirtualBox networking works because I have no clue). If you are able to SSH to that machine, then you know that the Unity-ROS connection should be possible and something's wrong in either Unity or ROS.
     
    RendergonPolygons likes this.
  5. RendergonPolygons

    RendergonPolygons

    Joined:
    Oct 9, 2019
    Posts:
    98
    Great suggestion @Envilon , it works now.

    In case someone runs into this issue, the problem for me was that I was running Ubuntu 18.04 Network attached to NAS (which works fine for the win11 machine running Unity to connect to Ubuntu client running in this win11 machine), but for H2 connection to ROS (think of it as another computer in the network that wants to connect), I had to set Ubuntu Network attached to Bridge Adapter with my LAN adaptor. Then restart ubuntu and on terminal "ip a" command to get the ip address to connect. This helped.

    upload_2022-12-18_7-55-15.png
     
    ShozabAbidi10 and Envilon like this.