removeBody
Remove body from robot
Description
Examples
Make changes to an existing rigidBodyTree object. You can get replace joints, bodies and subtrees in the rigid body tree.
Load an ABB IRB-120T manipulator from the Robotics System Toolbox™ loadrobot. It is specified as a rigidBodyTree object.
manipulator = loadrobot("abbIrb120T");View the robot with show and read the details of the robot using showdetails.
show(manipulator);

showdetails(manipulator)
-------------------- Robot: (8 bodies) Idx Body Name Joint Name Joint Type Parent Name(Idx) Children Name(s) --- --------- ---------- ---------- ---------------- ---------------- 1 base base_link-base fixed base_link(0) 2 link_1 joint_1 revolute base_link(0) link_2(3) 3 link_2 joint_2 revolute link_1(2) link_3(4) 4 link_3 joint_3 revolute link_2(3) link_4(5) 5 link_4 joint_4 revolute link_3(4) link_5(6) 6 link_5 joint_5 revolute link_4(5) link_6(7) 7 link_6 joint_6 revolute link_5(6) tool0(8) 8 tool0 joint6-tool0 fixed link_6(7) --------------------
Get a specific body to inspect the properties. The only child of the link_3 body is the link_4 body. You can copy a specific body as well.
body3 = getBody(manipulator,"link_3");
childBody = body3.Children{1}childBody =
rigidBody with properties:
Name: 'link_4'
Joint: [1×1 rigidBodyJoint]
Mass: 1.3280
CenterOfMass: [0.2247 1.5000e-04 4.1000e-04]
Inertia: [0.0028 0.0711 0.0723 1.3052e-05 -1.3878e-04 -6.6037e-05]
Parent: [1×1 rigidBody]
Children: {[1×1 rigidBody]}
Visuals: {'Mesh Filename link_4.stl'}
Collisions: {'Mesh Filename link_4.stl'}
FrameNames: {'link_4'}
ParentFrame: 'link_3'
body3Copy = copy(body3);
Replace the joint on the link_3 body. You must create a new Joint object and use replaceJoint to ensure the downstream body geometry is unaffected. Call setFixedTransform if necessary to define a transform between the bodies instead of with the default identity matrices.
newJoint = rigidBodyJoint("prismatic"); replaceJoint(manipulator,"link_3",newJoint); showdetails(manipulator)
-------------------- Robot: (8 bodies) Idx Body Name Joint Name Joint Type Parent Name(Idx) Children Name(s) --- --------- ---------- ---------- ---------------- ---------------- 1 base base_link-base fixed base_link(0) 2 link_1 joint_1 revolute base_link(0) link_2(3) 3 link_2 joint_2 revolute link_1(2) link_3(4) 4 link_3 prismatic fixed link_2(3) link_4(5) 5 link_4 joint_4 revolute link_3(4) link_5(6) 6 link_5 joint_5 revolute link_4(5) link_6(7) 7 link_6 joint_6 revolute link_5(6) tool0(8) 8 tool0 joint6-tool0 fixed link_6(7) --------------------
Remove an entire body and get the resulting subtree using removeBody. The removed body is included in the subtree.
subtree = removeBody(manipulator,"link_4")subtree =
rigidBodyTree with properties:
NumBodies: 4
Bodies: {[1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody]}
Base: [1×1 rigidBody]
BodyNames: {'link_4' 'link_5' 'link_6' 'tool0'}
BaseName: 'link_3'
Gravity: [0 0 0]
DataFormat: 'struct'
FrameNames: {'link_3' 'link_4' 'link_5' 'link_6' 'tool0'}
show(subtree);

Remove the modified link_3 body. Add the original copied link_3 body to the link_2 body, followed by the returned subtree. The robot model remains the same. See a detailed comparison through showdetails.
removeBody(manipulator,"link_3"); addBody(manipulator,body3Copy,"link_2") addSubtree(manipulator,"link_3",subtree) showdetails(manipulator)
-------------------- Robot: (8 bodies) Idx Body Name Joint Name Joint Type Parent Name(Idx) Children Name(s) --- --------- ---------- ---------- ---------------- ---------------- 1 base base_link-base fixed base_link(0) 2 link_1 joint_1 revolute base_link(0) link_2(3) 3 link_2 joint_2 revolute link_1(2) link_3(4) 4 link_3 joint_3 revolute link_2(3) link_4(5) 5 link_4 joint_4 revolute link_3(4) link_5(6) 6 link_5 joint_5 revolute link_4(5) link_6(7) 7 link_6 joint_6 revolute link_5(6) tool0(8) 8 tool0 joint6-tool0 fixed link_6(7) --------------------
Input Arguments
Robot model, specified as a rigidBodyTree
object.
Body name, specified as a string scalar character vector. This body must be on the robot model
specified in robot.
Data Types: char | string
Output Arguments
Robot subtree, returned as a rigidBodyTree object. This new subtree uses
the parent name of the body specified by bodyname as the
base name. All bodies that are attached in the previous robot model
(including the body with bodyname specified) are added
to the subtree.
Extended Capabilities
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 R2016b
See Also
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)