Main Content

getTransform

Get transform between body frames

Description

transform = getTransform(robot,configuration,bodyname) computes the transform that converts points in the bodyname frame to the robot base frame, using the specified robot configuration.

example

transform = getTransform(robot,configuration,sourcebody,targetbody) computes the transform that converts points from the source body frame to the target body frame, using the specified robot configuration.

Examples

collapse all

Get the transform between two frames for a specific robot configuration.

Load a sample robots that include the puma1 robot.

load exampleRobots.mat

Get the transform between the 'L2' and 'L6' bodies of the puma1 robot given a specific configuration. The transform converts points in 'L6' frame to the 'L2' frame.

transform = getTransform(puma1,randomConfiguration(puma1),'L2','L6')
transform = 4×4

   -0.2232    0.4179    0.8807    0.0212
   -0.8191    0.4094   -0.4018    0.1503
   -0.5284   -0.8111    0.2509   -0.4317
         0         0         0    1.0000

Input Arguments

collapse all

Robot model, specified as a rigidBodyTree object.

Robot configuration, specified as a structure array with joint names and positions for all the bodies in the robot model. You can generate a configuration using homeConfiguration(robot), randomConfiguration(robot), or by specifying your own joint names and positions in a structure array.

Body name, specified as a string scalar or character vector. This body must be on the robot model specified in robot.

Data Types: char | string

Target body name, specified as a character vector. This body must be on the robot model specified in robot. The target frame is the coordinate system you want to transform points into.

Data Types: char | string

Body name, specified as a string scalar or character vector. This body must be on the robot model specified in robot. The source frame is the coordinate system you want points transformed from.

Data Types: char | string

Output Arguments

collapse all

Homogeneous transform, returned as a 4-by-4 matrix.

Introduced in R2016b