getTransform
Get transform between body frames
Syntax
Description
computes
the transform that converts points in the transform
= getTransform(robot
,configuration
,bodyname
)bodyname
frame
to the robot base frame, using the specified robot configuration.
computes the transform that converts points from the source body frame to the target
body frame, using the specified robot configuration.transform
= getTransform(robot
,configuration
,sourcebody
,targetbody
)
Examples
Get Transform Between Frames for Robot Configuration
Get the transform between two frames for a specific robot configuration.
Load a Yaskawa Motoman MH-5 manipulator from the Robotics System Toolbox™ loadrobot
.
motoman = loadrobot("yaskawaMotomanMH5");
showdetails(motoman)
-------------------- Robot: (6 bodies) Idx Body Name Joint Name Joint Type Parent Name(Idx) Children Name(s) --- --------- ---------- ---------- ---------------- ---------------- 1 link_s joint_s revolute base_link(0) link_l(2) 2 link_l joint_l revolute link_s(1) link_u(3) 3 link_u joint_u revolute link_l(2) link_r(4) 4 link_r joint_r revolute link_u(3) link_b(5) 5 link_b joint_b revolute link_r(4) link_t(6) 6 link_t joint_t revolute link_b(5) --------------------
Get the transform between the "link_l"
and "link_t"
bodies of the motoman
robot given a specific configuration. The transform converts points in "link_l"
frame to the "link_t"
frame.
q = randomConfiguration(motoman); show(motoman,q);
transform = getTransform(motoman,q,"link_l","link_t")
transform = 4×4
0.7787 0.0961 -0.6199 0.3115
0.5256 0.4396 0.7283 -0.4624
0.3425 -0.8930 0.2918 -0.1886
0 0 0 1.0000
Input Arguments
robot
— Robot model
rigidBodyTree
object
Robot model, specified as a rigidBodyTree
object.
configuration
— Robot configuration
structure array
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.
bodyname
— Body name
string scalar | character vector
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
targetbody
— Target body name
string scalar | character vector
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
sourcebody
— Body name
string scalar | character vector
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
transform
— Homogeneous transform
4-by-4 matrix
Homogeneous transform, returned as a 4-by-4 matrix.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
When creating the rigidBodyTree
object, use the syntax that specifies the
MaxNumBodies
as an upper bound for adding bodies to the robot model.
You must also specify the DataFormat
property as a name-value pair. For
example:
robot = rigidBodyTree("MaxNumBodies",15,"DataFormat","row")
To minimize data usage, limit the upper bound to a number close to the expected number of bodies in the model. All data formats are supported for code generation. To use the dynamics functions, the data format must be set to "row"
or "column"
.
The show
and showdetails
functions do not support code generation.
Version History
Introduced in R2016bR2024a: Static memory allocation support
getTransform
now supports code generation with disabled dynamic memory allocation. For more information about disabling dynamic memory allocation, see Set Dynamic Memory Allocation Threshold (MATLAB Coder).
See Also
rigidBodyJoint
| rigidBody
| geometricJacobian
| homeConfiguration
| randomConfiguration
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)