Main Content

Solve kinematics problems for a multibody model

`KinematicsSolver`

objects allow users to
formulate and numerically solve kinematics problems for their Simscape™
Multibody™ models. You can use the object to solve standard forward and inverse kinematics
problems, as well as more general problems with closed-loop kinematic systems and multiple
targets.

A kinematics problem is formulated using kinematic variables. These variables have scalar
values that specify the relationships between frames in the corresponding Simscape Multibody
model. There are two types of kinematic variables: joint and frame. Joint variables correspond
to joint position and velocity states and are created automatically when the object is
constructed. You can view the joint variables using the `jointPositionVariables`

and
`jointVelocityVariables`

object functions. Frame variables correspond to position
and velocity relationships between arbitrary frames in the model and must be defined using the
`addFrameVariables`

object function.
Once defined, they can be viewed using the `frameVariables`

object function.

To formulate a kinematics problem, you must assign roles for the relevant kinematic
variables. There are three roles: targets, initial guesses, and outputs. Variables are
assigned to these roles using the `addTargetVariables`

, `addInitialGuessVariables`

, and
`addOutputVariables`

object function.
To solve the problem with the assigned variables, use the `solve`

object function. Starting from an initial state, the solver attempts to
find a final state of the system consistent with the values of the target variables. The
initial state is synthesized using the values of the initial guess variables. The initial
states that are not specified by initial guess variables are initialized to zero. The values
of the output variables are derived from the final state returned by the solver. If the solver
is unable to find a final state that satisfies all the targets, it tries to at least return a
state that is kinematically feasible.

creates a `ks`

= simscape.multibody.KinematicsSolver(modelName)`KinematicsSolver`

object for the model named in
`mdl`

. The object contains a representation of the model suitable for
kinematic analysis. The representation is a snapshot of the model as it is when the object
is created. Subsequent changes to the model do not carry over to the object. Create a new
object, if necessary to capture those changes.

The model must contain a Simscape Multibody network, and you need to load the model
into memory before creating its `KinematicsSolver`

object. If blocks of the
model have MATLAB variables, you need to numerically define those variables in the model
workspace or MATLAB workspace. The `KinematicsSolver`

object ignores any
contacts and several parameters of joint blocks, like **State Targets**,
**Limits**, **Actuation**, and **Mode
Configuration**. For example, during an analysis, two bodies can penetrate each
other even though there is a Spatial Contact
Force block that connects them. Block parameters set to
`Run-Time`

are evaluated when creating the object and cannot be
modified afterward.

A `KinematicsSolver`

object is a handle object. A variable created from
it contains not a copy of the object but a reference to it. The variable acts as a pointer
or handle. Modifying a handle modifies also the object and all of its remaining handles.
Copying a KinematicsSolver object and adding a frame variable to the copy, for example,
adds that frame variable to the object and so also to any other handles it might
have.

creates a `ks`

= simscape.multibody.KinematicsSolver(___,Name,Value)`KinematicsSolver`

object with additional options specified by
one or more `Name,Value`

pair arguments.

`frameVariables`

|`initialGuessVariables`

|`jointPositionVariables`

|`jointVelocityVariables`

|`outputVariables`

|`targetVariables`

|`addFrameVariables`

|`addInitialGuessVariables`

|`addOutputVariables`

|`addTargetVariables`

|`removeFrameVariables`

|`removeInitialGuessVariables`

|`removeOutputVariables`

|`removeTargetVariables`

|`clearFrameVariables`

|`clearInitialGuessVariables`

|`clearOutputVariables`

|`clearTargetVariables`

|`generateCode`

|`setVariableUnit`

|`solve`

|`viewSolution`

|`closeViewer`