Main Content

getBody

Get robot body handle by name

Description

body = getBody(robot,bodyname) gets a body handle by name 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 or character vector. A body with this name must be on the robot model specified by robot.

Data Types: char | string

Output Arguments

collapse all

Rigid body, returned as a rigidBody object. The returned rigidBodyTree object is still a part of the rigidBodyTree robot model. Use replaceBody with a new body to modify the body in the robot model.

Extended Capabilities

Version History

Introduced in R2016b