Main Content

removeBody

Remove body from robot

Description

removeBody(robot,bodyname) removes the body and all subsequently attached bodies from the robot model.

newSubtree = removeBody(robot,bodyname) returns the subtree created by removing the body and all subsequently attached bodies from the robot model.

example

Examples

collapse all

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)

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}
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)

Remove an entire body and get the resulting subtree using removeBody. The removed body is included in the subtree.

subtree = removeBody(manipulator,"link_4")
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)

Input Arguments

collapse all

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

collapse all

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

Version History

Introduced in R2016b