Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

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.