docs.unity3d.com
    Warning

    Warning: Unity Simulation is deprecated as of December 2023, and is no longer available.

    Use the TFBroadcaster

    What is a TF Broadcaster?

    A vehicle model or robotic system typically has many joints each with their own 3D coordinate frames that change over time, such as a world frame, base frame, gripper frame, head frame, etc. The TFBroadcaster can be used to keep track of all these frames over time and the relative position of child frames to their parent frames.

    TFBroadcaster Output

    The TF Broadcaster publishes data to the /tf topic, in the following structure which follow the ROS schema but is ROS-agnostic in how it is serialized and sent.

    Schema

    ROS schema

    geometry_msgs/TransformStamped[] transforms
      # Expresses a transform from coordinate frame header.frame_id
      # to the coordinate frame child_frame_id
      Header header
    
      string child_frame_id # the frame id of the child frame
    
        Transform transform    # represents the transform between two coordinate frames.
        Vector3 translation
          float64 x
          float64 y
          float64 z    
        Quaternion rotation # orientation in quaternion form.
          float64 x
          float64 y
          float64 z
          float64 w
    

    Unity Simulation structure

    public class TFMessageMsg : Message
    {
      public const string k_RosMessageName = "tf2_msgs/TFMessage";
    
      public Geometry.TransformStampedMsg[] transforms;
    }
    
    public class TransformStampedMsg : Message
    {
      public const string k_RosMessageName = "geometry_msgs/TransformStamped";
      //  This expresses a transform from coordinate frame header.frame_id
      //  to the coordinate frame child_frame_id at the time of header.stamp
    
      //  The child_frame_id is necessary in addition to the frame_id
      //  in the Header to communicate the full reference for the transform
      //  in a self contained message.
      //  The frame id in the header is used as the reference frame of this transform.
      public Std.HeaderMsg header;
    
      //  The frame id of the child frame to which this transform points.
      public string child_frame_id;
    
      //  Translation and rotation in 3-dimensions of child_frame_id from header.frame_id.
      public TransformMsg transform;
    }
    
    public class TransformMsg : Message
    {
      public const string k_RosMessageName = "geometry_msgs/Transform";
      //  This represents the transform between two coordinate frames in free space.
    
      public Vector3Msg translation;
      public QuaternionMsg rotation;
    }
    

    Usage

    To use the TF Broadcaster, add the component TfBroadcasterComponent to the root gameObject of the vehicle/robot hierarchy in the scene. When present in the scene, TFBroadcasterComponent object will automatically traverse the hierarchy and publish the transform tree of all children gameObjects with an ArticulationBody component to the /tf topic.

    You can track multiple robots' coordinate frames with TfBroadcaster. You need to add TfBroadcasterComponent to each robot to track them.


    A robot model in Unity (left) and its current the transform tree visualized in RViz (middle) and rqt_tf_tree (right)

    Copyright © 2023 Unity Technologies
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX.