Main Content

simscape.multibody.State Class

R2026b

Namespace: simscape.multibody

State of compiled multibody system

Since R2022a

Description

A simscape.multibody.State object represents the position and velocity of every joint primitive in a compiled multibody system. You use the State object in many analyses, such as computing the dynamics or querying the transformation of a frame in the system.

To compute the state of a compiled multibody system, use the computeState method. The Status property shows whether the state is valid. If the state is not valid, the Status property shows what type of problem occurred.

You can only use a State object with the simscape.multibody.CompiledMultibody object that was used to create the State object. Attempting to pass a State object to a method of a different CompiledMultibody object generates an error.

Class Attributes

Sealed
true
ConstructOnLoad
true
RestrictsSubclassing
true

For information on class attributes, see Class Attributes.

Creation

To create the simscape.multibody.State object of a compiled multibody system, use the computeState method.

Properties

expand all

State status, returned as a member of the simscape.multibody.StateStatus class. The status indicates the high-level result of attempt at computing the state of a compiled multibody system:

  • simscape.multibody.StateStatus.Valid: All kinematic constraints of the multibody system are satisfied. Note that a valid status does not indicate that all the specified targets have been met.

  • simscape.multibody.StateStatus.PositionViolation: Not all position constraints of the multibody system are satisfied.

  • simscape.multibody.StateStatus.VelocityViolation: All position constraints are satisfied, but at least one velocity constraint is not satisfied.

  • simscape.multibody.StateStatus.SingularityViolation: All kinematic constraints of the multibody system are satisfied, but at least one joint primitive or kinematic constraint is in singularity.

Attributes:

GetAccess
public
SetAccess
Restricts access
NonCopyable
true
Transient
true

Methods

expand all

Examples

collapse all

This example shows how to compute the state of a compiled multibody system and check the status.

Create a multibody system with two solid bodies connected by a revolute joint.

mb = simscape.multibody.Multibody;
addComponent(mb, "s1", simscape.multibody.UniformSolid);
addComponent(mb, "s2", simscape.multibody.UniformSolid);

rj = simscape.multibody.RevoluteJoint;
addComponent(mb, "rj", rj);

connect(mb, "s1/R", "rj/B");
connect(mb, "rj/F", "s2/R");

Compile the multibody system and compute the state with a target joint position of 45 deg.

cmb = compile(mb);

op = simscape.op.OperatingPoint;
op("rj/Rz/q") = simscape.op.Target(simscape.Value(45,"deg"));

state = computeState(cmb, op)
state =
  State with properties:

    Status: Valid

Version History

Introduced in R2022a