Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROS2 - Can't unsubscribe #166

Open
mousdahl-unity opened this issue Jun 7, 2023 · 1 comment
Open

ROS2 - Can't unsubscribe #166

mousdahl-unity opened this issue Jun 7, 2023 · 1 comment

Comments

@mousdahl-unity
Copy link

Describe the bug
The ROS TCP endpoint throws an exception and hitches significantly when unsubscribing from topics.

To Reproduce
Steps to reproduce the behavior:

  1. Subscribe to a topic
  2. Unsubscribe
  3. Look at the TCP endpoint connector log
  4. See error

Console logs / stack traces

Exception in thread Thread-4:
Traceback (most recent call last):
  File "c:\python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\source\sol-proj-universal-robopose\ROS2\install\ros_tcp_endpoint\Lib\site-packages\ros_tcp_endpoint\client.py", line 213, in run
    self.tcp_server.handle_syscommand(destination, data)
  File "C:\source\sol-proj-universal-robopose\ROS2\install\ros_tcp_endpoint\Lib\site-packages\ros_tcp_endpoint\server.py", line 121, in handle_syscommand
    function = getattr(self.syscommands, topic[2:])
AttributeError: 'SysCommands' object has no attribute 'remove_subscriber'

Expected behavior
The topic should be unsubscribed with no crashing.

Environment:

  • Unity Version: Unity 2020.3.21f1
  • Unity machine OS + version: Windows 11
  • ROS machine OS + version: Windows 11, ROS Foxy
  • ROS–Unity communication: Windows Environment
  • Branch or version: dev_ros2
@abreu9999
Copy link

Same problem here. Add the following definition to class SysCommands in server.py:

def remove_subscriber(self, topic):
    if topic == "":
        self.tcp_server.send_unity_error(
            "Can't unsubscribe to a blank topic name! SysCommand.remove_subscriber({}, {})".format(
                topic
            )
        )
        return

    node = self.tcp_server.subscribers_table.get(topic)
    if node is not None:
        self.tcp_server.unregister_node(node)
        self.tcp_server.loginfo("UnregisterSubscriber({}) OK".format(topic))
    else:
        self.tcp_server.send_unity_error(
            "Can't unsubscribe node if not previously subscribed! SysCommand.remove_subscriber({})".format(
                topic
            )
        )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants