frameinfo
Description
Examples
This example showcases how to manage frames within a rigid body, covering operations such as adding, removing, and updating frames, as well as retrieving transforms between them.
Create a rigid body robot model and display initial frame information.
A rigid body can contain multiple frames used to define coordinate systems for attaching sensors, tools, or other components.
rb = rigidBody('rb'); rbFrame = frameinfo(rb, 'rb')
rbFrame = struct with fields:
Name: 'rb'
RigidTransform: [4×4 double]
ParentFrame: ''
ChildFrames: {1×0 cell}
Add a new frame named test
to the rigid body rb
, defining its position with a translation relative to the root frame rb
.
addFrame(rb, 'test', 'rb', trvec2tform([1 2 3]));
Next, add another frame, test1
, which is positioned relative to the newly added frame test
using a combination of translation and rotation.
Each frame is defined by its name, parent frame, and rigid transform.
addFrame(rb, 'test1', 'test', trvec2tform([1 2 3]));
Display information about these added frames to verify their properties and confirm their placement within the rigid body.
testFrame = frameinfo(rb, 'test1')
testFrame = struct with fields:
Name: 'test1'
RigidTransform: [4×4 double]
ParentFrame: 'test'
ChildFrames: {1×0 cell}
You can also remove frames, which updates the frame tree to maintain its kinematic structure. Remove the frame test
and observe its effect on test1
frame.
% Remove frame 'test' removeFrame(rb, 'test'); % Check updated frame information for 'test1' frameAfterRemove = frameinfo(rb, 'test1')
frameAfterRemove = struct with fields:
Name: 'test1'
RigidTransform: [4×4 double]
ParentFrame: 'rb'
ChildFrames: {1×0 cell}
Now, modify existing frames by updating their properties, such as the name, parent frame, or rigid transform.
First, rename test1
frame to test2
.
updateFrame(rb, 'test1', 'Name', 'test2');
Add a new frame test3
and update test2
to use it as the parent frame.
addFrame(rb, 'test3', 'rb', trvec2tform([1 1 1])); updateFrame(rb, 'test2', 'ParentFrame', 'test3', ... 'RigidTransform', trvec2tform([1 2 3]));
Display updated frame information.
frameAfterUpdate = frameinfo(rb, 'test2')
frameAfterUpdate = struct with fields:
Name: 'test2'
RigidTransform: [4×4 double]
ParentFrame: 'test3'
ChildFrames: {1×0 cell}
Input Arguments
Rigid body, specified as a rigidBody
object.
Name of the frame to be queried, specified as a string scalar or character vector.
Data Types: char
| string
Output Arguments
Information of the frame specified by framename
, returned as a
structure containing these fields:
Name
— Name of the queried frame in the rigid body, specified as a string scalar or character vector.RigidTransform
— Rigid body transform of the queried frame in the rigid body, specified as 4-by-4 homogeneous transformation.ParentFrame
— Name of the parent frame of the queried frame in the rigid body, as a string scalar or character vector.ChildFrames
— Name of the child frames of the queried frame in the rigid body, specified as a cell array.
Data Types: struct
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2025a
See Also
addFrame
| updateFrame
| removeFrame
| getTransform
| rigidBody
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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)