docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Scene setup workflow

    Learn how to set up your scene for Simulation Pro.

    To set up your scene for Simulation Pro, follow these steps:

    1. Add a connector
    2. Add a sensor
    3. Publish a message
    4. Subscribe to a message
    5. Configure the transform broadcast hierarchy
    6. Configure compass direction

    Add a connector

    A connector is the bridge between your Unity scene and an external messaging back end. Two options are available:

    Dummy connection component

    The Dummy Connection Component works without any back end. This component is useful for development and testing.

    1. Create an empty GameObject (for example ROS Connection).
    2. Add Dummy Connection Component to it.

    ROS endpoint connector component

    The Robot Operating System (ROS) Endpoint Connector Component connects to a live ROS environment via the ROS TCP Endpoint bridge.

    1. Create an empty GameObject (for example ROS Connection).
    2. Add Ros Endpoint Connector Component to it.
    3. Set Endpoint IP Address and Endpoint Port to match your ROS TCP Endpoint server.
    4. Set Is Ros 2 to match your ROS version.

    ConnectorInjector discovers the active BaseConnectionComponent automatically. If multiple connectors exist in the scene, the one closest to the scene root takes priority.

    Add a sensor

    To add a sensor to your scene:

    1. Select a GameObject in your scene. For the IMU sensor, the GameObject must already have an ArticulationBody component; other sensors add their own required components automatically.
    2. Add a sensor component, for example Camera Sensor.
    3. Configure the topic names and parameters in the Inspector.
    4. Press Play. The sensor starts publishing immediately once the connector is active.

    For a full list of available sensors and their configuration options, refer to Sensor types reference.

    Publish a message

    To publish a message, add the following code to any GameObject in your scene:

    using Unity.SimulationPro.Foundation;
    using Unity.SimulationPro.Foundation.StdMessages;
    using UnityEngine;
    
    public class HelloPublisher : PublisherBehaviour<StringMsg>
    {
        public override string DefaultTopic => "/hello";
    
        void Update()
        {
            if (CanPublish)
                Publish(new StringMsg("Hello from Unity!"));
        }
    }
    

    PublisherBehaviour<T> resolves the connector automatically in Start().

    Subscribe to a message

    Use the following code to subscribe to a message:

    using System;
    using Unity.SimulationPro.Foundation;
    using Unity.SimulationPro.Foundation.StdMessages;
    using UnityEngine;
    
    public class HelloSubscriber : SubscriberBehaviour<StringMsg>
    {
        public override string DefaultTopic => "/hello";
    
        protected override Action<StringMsg> Callback =>
            msg => Debug.Log($"Received: {msg.data}");
    }
    

    Configure the transform broadcast hierarchy

    Add TfBroadcasterComponent to the root GameObject of your robot. You don't need to add any additional code. The component publishes the full transform tree to /tf on every FixedUpdate.

    Configure compass direction

    NED and ENU coordinate spaces require knowing which cardinal direction Unity's z-axis represents. Configure this once per project before you perform any coordinate conversion:

    // Set once, e.g. in a scene initializer
    CompassDirection.UnityZAxisDirection = CardinalDirection.North;
    

    In the Unity Editor, configure this via the Simulation > Simulation Settings menu.

    Additional resources

    • Connect and communicate with ROS
    • Manage coordinates and time
    • Broadcast transforms
    • Generate sensor data
    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)