Main Content

componentResults

R2026b

Class: simscape.multibody.CompiledMultibody
Namespace: simscape.multibody

Return computed quantities for specified joint component

Since R2026b

Description

results = componentResults(cmb,componentPath,state) returns positions and velocities for the specified joint component. The componentPath argument specifies the path to the joint component in the compiled multibody system, cmb. The state argument provides the system state.

example

results = componentResults(cmb,componentPath,dynamicsResult) returns positions, velocities, accelerations, forces, and torques for the specified joint component. The dynamicsResult argument provides the system dynamics.

example

You can use the componentResults method to query computed quantities for all joint components except simscape.multibody.ConstantVelocityJoint.

Input Arguments

expand all

Compiled multibody system represented by a simscape.multibody.CompiledMultibody object.

Path to the joint component in the compiled multibody system. Separate the path elements by using forward slashes.

Example: "Suspension/Front_Left/Shock/Prismatic_Joint"

State of the compiled multibody system. Use a State object to query the positions and velocities of the specified joint component.

Dynamics of the compiled multibody system. Use a DynamicsResult object to query all computed results of the specified joint component.

Output Arguments

expand all

Component-specific results object that contains computed quantities for the specified joint component. The quantities depend on the input arguments.

When the input is a simscape.multibody.State object, the output include primitive-level results that contain of the position and velocity for each joint primitive in the joint component.

When the input is a simscape.multibody.DynamicsResult object, the output include primitive-level results and joint-level results. The primitive-level results include position, velocity, acceleration, and actuation force or torque for each joint primitive. The joint-level results include composite quantities such as constraint force, constraint torque, total force, and total torque.

All force and torque vectors follow a consistent convention: they represent the follower-on-base direction and are expressed in the base frame coordinate system.

Result LevelQuantityUnits
Primitive-levelPositionm (linear), rad (angular)
Velocitym/s, rad/s
Accelerationm/s², rad/s²
Actuation Force/Torque (Applies only to prismatic and revolute primitives.)N (linear), N·m (angular)
Joint-levelConstraint ForceN (1×3 vector)
Constraint TorqueN·m (1×3 vector)
Total ForceN (1×3 vector)
Total TorqueN·m (1×3 vector)

Attributes

Accesspublic

To learn about attributes of methods, see Method Attributes.

Examples

expand all

This example shows how to use componentResults with a State object to query the position and velocity of a joint.

Open the model from the Creating a Four Bar Multibody Mechanism in MATLAB example. Create a simscape.multibody.Multibody object of the four-bar model, compile it, and compute the state with specified position and velocity targets.

openExample("sm/CreateAFourBarMechanismInMATLABExample");
fb = fourBar(simscape.Value(1,"m"),simscape.Value(0.8,"m"),...
                      simscape.Value(0.4,"m"),simscape.Value(0.7,"m"));
cfb = compile(fb);

op = simscape.op.OperatingPoint;
op("Bottom_Left_Joint/Rz/q") = simscape.op.Target(60,"deg","High");
op("Bottom_Right_Joint/Rz/q") = simscape.op.Target(90,"deg","Low");
op("Bottom_Left_Joint/Rz/w") = simscape.op.Target(simscape.Value(3,"rad/s"),"High");
state = computeState(cfb, op);

Query the position and velocity of the bottom-left joint by passing the State object.

stateResult = componentResults(cfb, "Bottom_Left_Joint", state);
stateResult.Rz
ans =
  RevolutePrimitiveResults with properties:

    Position: 1.0472 (rad)
    Velocity: 3 (rad/s)

This example shows how to use componentResults with a DynamicsResult object to query the acceleration and constraint forces of a joint in a four-bar mechanism under gravity.

Open the model from the Creating a Four Bar Multibody Mechanism in MATLAB example. Create a simscape.multibody.Multibody object of the four-bar model, compile it, and compute the state.

openExample("sm/CreateAFourBarMechanismInMATLABExample");
fb = fourBar(simscape.Value(1,"m"),simscape.Value(0.8,"m"),...
                      simscape.Value(0.4,"m"),simscape.Value(0.7,"m"));
cfb = compile(fb);

op = simscape.op.OperatingPoint;
op("Bottom_Left_Joint/Rz/q") = simscape.op.Target(60,"deg","High");
op("Bottom_Right_Joint/Rz/q") = simscape.op.Target(90,"deg","Low");
state = computeState(cfb, op);

Compute the dynamics of the system with uniform gravity and query the results for the bottom-left joint.

ug = simscape.multibody.UniformGravity(simscape.Value([0 -9.81 0],"m/s^2"));
dynamics = computeDynamics(cfb, state, ug);
jointResult = componentResults(cfb, "Bottom_Left_Joint", dynamics)
jointResult =
  RevoluteJointResults with properties:

                  Rz: [1×1 simscape.multibody.RevolutePrimitiveResults]
     ConstraintForce: [-2.1058 -4.5003 0] (N)
    ConstraintTorque: [0 0 0] (N*m)
          TotalForce: [-2.1058 -4.5003 0] (N)
         TotalTorque: [0 0 0] (N*m)

Access the revolute primitive results to see the acceleration due to gravity.

jointResult.Rz
ans =
  RevolutePrimitiveResults with properties:

           Position: 1.0472 (rad)
           Velocity: 0 (rad/s)
       Acceleration: -8.6431 (rad/s^2)
    ActuationTorque: 0 (N*m)

Version History

Introduced in R2026b