Hauptinhalt

jointPositionFromBodyName

R2026b

Get joint position index in configuration vector from body name

Since R2026b

Description

startIdx = jointPositionFromBodyName(robot,bodyname) returns the index of the configuration‑vector element of the joint attached to the specified body in the rigid body tree robot model.

example

[startIdx,endIdx] = jointPositionFromBodyName(robot,bodyname) returns the start and end indices of the configuration‑vector elements associated with the joint attached to the specified body in the rigid body tree robot model.

Examples

collapse all

Load the Rethink Sawyer robot and show the configuration vector for the home configuration. Sawyer contains 20 joints, many of them being fixed joints that do not contribute elements to the configuration vector.

robot = loadrobot("rethinkSawyer",DataFormat="row");
config = robot.homeConfiguration
config = 1×8
0	0	0	0	0	0	0	0

Get the configuration-vector index of the joint attached to the "head" body and set the corresponding configuration vector element to pi radians.

headIdx = jointPositionFromBodyName(robot,"head");
config(headIdx) = pi;

Input Arguments

collapse all

Rigid body tree robot model, specified as a rigidBodyTree object.

Body name, specified as a string scalar or character vector.

Output Arguments

collapse all

Start index of the joint attached to the body in the configuration vector, returned as a nonnegative integer. startIdx is a positive integer for joints that contribute position degrees of freedom. If the joint is fixed, startIdx is 0, indicating that the joint has no corresponding element in the configuration vector.

End index of the joint attached to the body in the configuration vector, returned as an integer. endIdx is a positive integer for joints that contribute position degrees of freedom. If the joint is fixed, endIdx is -1, indicating that the joint has no corresponding element in the configuration vector.

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2026b