Main Content


Get transformation between two frames on the TurtleBot robot

Add-On Required: This feature requires the ROS Toolbox Support Package for TurtleBot-Based Robots add-on.



tform = getTransform(tbot,targetframe,sourceframe) returns the latest known transformation between two coordinate frames on the TurtleBot® connected through interface object, tbot.

[tform,tformMsg] = getTransform(tbot,targetframe,sourceframe) also returns the associated ROS TransformStamped message.


collapse all

Connect to the TurtleBot robot. Change '' to the IP address of the robot.

tbot = turtlebot('');

View the active frames by using the TransformFrames property.


Get transform between the 'base_link' and 'camera_link' frames on the TurtleBot.

tform = getTransform(tbot,'camera_link','base_link')
tform = 

    Translation: [0.1180 -1.8431e-18 -0.2710]
       Rotation: [0 0 0]

Input Arguments

collapse all

TurtleBot interface object, specified as a turtlebot object. The object contains properties for activating subscribers and accessing topic names relevant to the TurtleBot. The properties contain the topic name and active status of different subscribers for the TurtleBot. When you create the object with turtlebot, the properties available are:

tbot = turtlebot
tbot = 

  turtlebot with properties:

           Velocity: [1x1 struct]
         ColorImage: [1x1 struct]
          GrayImage: [1x1 struct]
         DepthImage: [1x1 struct]
         PointCloud: [1x1 struct]
          LaserScan: [1x1 struct]
           Odometry: [1x1 struct]
      OdometryReset: [1x1 struct]
                IMU: [1x1 struct]
    TransformFrames: {0x1 cell}
         TopicNames: {3x1 cell}

For properties with relevant ROS data messages , you can view the topic name and a subscriber’s active status. A specific subscriber is active for the given TopicName if Active equals 1.

ans = 

    TopicName: '/mobile_base/commands/velocity'
       Active: 1

Target coordinate frame that you want to transform your source frame into, specified as a string. To see the available frames, use tbot.TransformFrames.

Source coordinate frame, specified as a string. To see the available frames, use tbot.TransformFrames.

Output Arguments

collapse all

Transformation between two coordinate frames, specified as a structure containing these fields:

  • Translation – A row vector containing the 3-D translation between the source and target frames in the form [x y z] in meters.

  • Rotation – A row vector containing the 3-D orientation between the source and target frames in the form [yaw pitch roll] in radians.

Transformation message, returned as a TransformStamped object handle.

Version History

Introduced in R2016a