Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Error with TCP End Point while unsubscrbing from a topic.

Discussion in 'Robotics' started by alessandro7111, Sep 29, 2023.

  1. alessandro7111


    Jul 2, 2020
    I have a subscriber that receives raw image from a ros node. I have the following code to pause/resume the visualization of the images:
    Code (CSharp):
    1.  if (Input.GetKeyDown("space"))
    2.         {
    3.             if (listening)
    4.             {
    5.                rosConnection.Unsubscribe(topicName);
    6.                listening = false;
    7.             } else
    8.             {
    9.                 rosConnection.Subscribe<ImageMsg>(topicName, msg => OnImageReceived(msg));
    10.                 listening = true;
    11.             }
    13.         }
    When i try to unsubscribe i get an error in the tcp end point and i lose the connection with Ros for abount 2/3 seconds. After disconnecting, unity reconnects with ros and everything seems to work.
    TCP End Point error:

    Traceback (most recent call last):
    File "/usr/lib/python3.8/", line 932, in _bootstrap_inner
    File "/root/catkin_ws/src/ROS-TCP-Endpoint/src/ros_tcp_endpoint/", line 222, in run
    self.tcp_server.handle_syscommand(destination, data)
    File "/root/catkin_ws/src/ROS-TCP-Endpoint/src/ros_tcp_endpoint/", line 112, in handle_syscommand
    function = getattr(self.syscommands, topic[2:])
    AttributeError: 'SysCommands' object has no attribute 'remove_subscriber'

    Any indeas? Thanks for reading and sorry for my english

    Edit: i'm using ros1 noetic
  2. Envilon


    Aug 8, 2020
    Hi, the whole unsubscribe functionality in ROS TCP Connector seems to be a bit of a mess right now (hence another discussion here).

    Unfortunately, I am currently unable to dig into the code for a few days, but it looks like the ROS TCP Connector is not using the ROS TCP Endpoint correctly. Please make sure you are using the corresponding versions of the connector and the endpoint. You should be using the same Git Tag in both repositories (make sure it’s for ROS 1 in your case). If it matches in your project and you still have this problem, there might be a bug in Unity’s implementation.

    If the problem prevails after you check the versions, a quick solution for now might be to keep the connection running and just toggle the visualization of the image data in Unity.
    alessandro7111 likes this.
  3. alessandro7111


    Jul 2, 2020