Connect to a live Robot Operating System environment
Bridge a Simulation Pro scene to a running ROS environment using the ROS Endpoint Connector.
The RosEndpointConnector provides a TCP connection to a ROS TCP Endpoint bridge, implementing IConnector for both ROS 1 and ROS 2.
Add the component
Add RosEndpointConnectorComponent to a GameObject in your scene:
- Create an empty GameObject (for example
ROS Connection). - Add the Ros Endpoint Connector Component component to it.
- Set Endpoint IP Address and Endpoint Port to match your ROS TCP Endpoint server.
- Set Is Ros 2 to match the ROS version used by the endpoint.
ConnectorInjector discovers this component automatically. All PublisherBehaviour, SubscriberBehaviour, and AutoPublisher instances in the scene will use it without additional configuration.
For the full list of inspector properties, refer to ROS Endpoint Connector reference
Connection lifecycle
Connect()starts a background thread that maintains the TCP connection and reconnects on failure.Disconnect()cancels the background thread and closes the socket.- When a connection is established, all registered publishers and subscribers are automatically re-registered with the endpoint.
- When the connection is lost, subscriber and publisher registrations are reset and will be re-sent on reconnection.
Check connection state
if (connector.HasConnectionError)
Debug.LogWarning("ROS connection error!");
HasConnectionError is true while the connector is actively trying to reconnect after a failure.