docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Introduction to messaging

    Understand the core concepts behind Simulation Pro's publish/subscribe messaging system and how they map to ROS conventions.

    Core concepts

    Concept Type Description
    Connector IConnector The entry point for all messaging. Manages publishers, subscribers, and service calls.
    Publisher IPublisher Sends messages on a topic.
    Subscriber Callback Receives messages on a topic via a registered callback.
    Message IMessage The data payload. Every message has a MessageTypeId.
    Topic string A named channel following ROS conventions (for example /cmd_vel).

    IMessage

    All message types implement IMessage:

    public interface IMessage
    {
        void WriteTo(IMessageSerializer serializer);
        MessageTypeId MessageTypeId { get; }
    }
    

    Message classes follow the naming convention {Name}Msg (for example, TransformStampedMsg, PointMsg). Unity registers generated message types automatically in MessageTypeRegistry at startup.

    MessageTypeId combines a type name string with an optional MessageDisambiguator, which is used when multiple message definitions share the same base name across ROS packages.

    IConnector

    IConnector is the central interface. Get a reference via ConnectorInjector, which discovers the active BaseConnectionComponent in the scene:

    IConnector connector = ConnectorInjector.FindConnector(this);
    

    FindConnector(GameObject) walks the transform hierarchy — current object, then its children, then its parent, and so on — looking for an enabled BaseConnectionComponent. If none is found, it falls back to GetDefaultConnector(), which searches the entire scene.

    // From a MonoBehaviour:
    IConnector connector = ConnectorInjector.FindConnector(this);
    
    // Or override the default manually:
    ConnectorInjector.SetDefaultConnector(myConnectionComponent);
    

    Topic introspection

    // List all active topics (ordered by name):
    foreach (ITopicInfo topic in connector.GetAllTopics())
        Debug.Log(topic.TopicName);
    
    // Watch for new topics:
    connector.AddNewTopicsListener(info => Debug.Log($"New topic: {info.TopicName}"), notifyAllExistingTopics: true);
    
    // Request a refresh from the backend:
    connector.RequestTopicListRefresh();
    

    Additional resources

    • Set up publishers and subscribers workflow
    • Connect to a live ROS environment
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)