Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

ROS Connection success event

Discussion in 'Robotics' started by rosenm15, Sep 22, 2021.

  1. rosenm15

    rosenm15

    Joined:
    May 12, 2021
    Posts:
    3
    Is there a way to check an event with the ROSConnection to confirm that an established connection has been created?

    I am looking for the event to account for errors where:

    Code (CSharp):
    1. No data available on network stream after 10 attempts.
    Or when
    Code (CSharp):
    1. No connection could be made because the target machine actively refused it?
    What should I look for as an event to confirm when a stable connection has been made?
     
  2. LaurieUnity

    LaurieUnity

    Unity Technologies

    Joined:
    Oct 23, 2020
    Posts:
    77
    You could check the property ROSConnection.HasConnectionError: it will be true until until a message has been received. (ROS_TCP_Endpoint always sends an empty message as soon as a connection is established, to confirm the connection is working.)
    This logic is used by the hud to show red arrows.
     
  3. rosenm15

    rosenm15

    Joined:
    May 12, 2021
    Posts:
    3
    @LaurieUnity , What version of ROS_TCP_ENDPOINT is this available in? I am currently on 0.1.2-preview
     
  4. LaurieUnity

    LaurieUnity

    Unity Technologies

    Joined:
    Oct 23, 2020
    Posts:
    77
  5. rosenm15

    rosenm15

    Joined:
    May 12, 2021
    Posts:
    3
    Thanks, I updated and resolved it with that method.