[ROS TCP Connector] How to disconnect ROS properly

Hello there!

Im trying to disconnect from ROS and then reconnect. Im using de Disconnect() function, but when I create a new RosConnection instance, the HUD shows two connections and log the following message:

ROSConnection.GetOrCreateInstance().Disconnect();

8560796--1145294--image_2022-11-03_170926462.png

8560796--1145297--image_2022-11-03_170946720.png

What else do I have to do to disconnect from ROS properly?

You shouldn’t create a new RosConnection instance, just call Connect (or press the Connect button in the hud) when you want to connect again.

But I`m unloading the scene that contains the RosConnection instace, so it should be destroyed right?

Also when I call the GetOrCreateInstance method, if a RosConnection instance exists, it should be return and not create a new one, shouldn`t it?

Hmm. Ideally yes, that should work, but if it’s causing problems I suggest you set DontDestroyOnLoad on your RosConnection and just keep the same connection from scene to scene.

1 Like

Ok, gonna try this. Thank you!