Unity-Technologies / ROS-TCP-Endpoint

ROS package used to create an endpoint to accept ROS messages sent from a Unity scene using the ROS TCP Connector scripts
Apache License 2.0
177 stars 118 forks source link

Publishers / subscribers are never closed when connection closes #139

Open Raphtor opened 2 years ago

Raphtor commented 2 years ago

Describe the bug If I connect to the endpoint via the Unity player, create subscribers/publishers, and then close the connection (i.e by stopping Unity), the subscribers/publishers are never destroyed and remain in the list of ros2 topic list and ros2 node list.

To Reproduce Steps to reproduce the behavior:

  1. Launch Unity
  2. Launch docker container with endpoint
  3. Click play in Unity with scripts that register publishers/subscribers
  4. ros2 topic list and ros2 node list show correct subscribers/publishers
  5. Stop Unity editor execution
  6. ros2 topic list and ros2 node list still show subscribers/publishers, despite the log message [INFO] [1649729856.926835838] [UnityEndpoint]: Disconnected from 172.17.0.1

Console logs / stack traces Docker container endpoint

root@0c49719e8970:/home/dev_ws# ros2 run ros_tcp_endpoint default_server_endpoint --ros-args -p ROS_IP:=0.0.0.0
[INFO] [1649731919.301293293] [UnityEndpoint]: Starting server on 0.0.0.0:10000
[INFO] [1649731924.108205420] [UnityEndpoint]: Connection from 172.17.0.1
[INFO] [1649731924.260963087] [UnityEndpoint]: RegisterSubscriber(/cmd_vel, <class 'geometry_msgs.msg._twist.Twist'>) OK
[INFO] [1649731924.278215629] [UnityEndpoint]: RegisterSubscriber(/tf, <class 'tf2_msgs.msg._tf_message.TFMessage'>) OK
[INFO] [1649731924.287839920] [UnityEndpoint]: RegisterPublisher(/cmd_vel, <class 'geometry_msgs.msg._twist.Twist'>) OK
[INFO] [1649731924.302599337] [UnityEndpoint]: RegisterPublisher(/pose_stamped, <class 'geometry_msgs.msg._pose_stamped.PoseStamped'>) OK
[WARN] [1649731924.304394170] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[INFO] [1649731924.319359004] [UnityEndpoint]: RegisterPublisher(/cmd_vel, <class 'geometry_msgs.msg._twist.Twist'>) OK
[WARN] [1649731924.321670712] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[INFO] [1649731924.341157712] [UnityEndpoint]: RegisterPublisher(/pose_stamped, <class 'geometry_msgs.msg._pose_stamped.PoseStamped'>) OK
[ERROR] [1649731932.677630258] [UnityEndpoint]: Exception: No more data available
[INFO] [1649731932.679670758] [UnityEndpoint]: Disconnected from 172.17.0.1

Environment (please complete the following information, where applicable):