The SimMechanics™ Kinematics and Inverse Dynamics modes enable you to find all the forces on a closed-loop machine or an open machine, respectively, given a model that completely specifies the system's motions. (See Choosing an Analysis Mode)
You can use the Forward Dynamics mode to analyze inverse dynamics, but these two alternative modes are more efficient: unlike Forward Dynamics mode, they do not need to compute the positions, velocities, and accelerations of the model's components, because the model specifies them. Consequently, Kinematics and Inverse Dynamics modes take less time than Forward Dynamics to compute the forces on a system. The time saving depends on the size and complexity of the system being simulated.
The following sections show how to use the Inverse Dynamics and Kinematics modes to find the forces on the joints of an open- and closed-topology system, respectively.
To use these modes, you must first build a kinematic model of the system, one that specifies completely the positions, velocities, and accelerations of the system's bodies. You create a kinematic model by interconnecting blocks representing the bodies and joints of the system and then connecting actuators to the joints to specify the motions of the bodies.
A model does not have to actuate every joint to specify completely the motions of a system. In fact, the model need actuate only as many joints as there are independent degrees of freedom in the system. (See Counting Model Degrees of Freedom.) For example, a model of a four bar mechanism need actuate only one of the mechanism's joints, because a four bar mechanism has only one degree of freedom. To avoid overconstraining the model's solution, the number of actuated joints should not exceed the number of independent degrees of freedom.
Warning Attempting to simulate an overconstrained model causes Simulink® to stop the simulation with an error.
Consider a double pendulum consisting of two thin rods each 1 meter long and weighing 1 kilogram. The upper rod is initially rotated 15 degrees from the perpendicular.
Suppose that you want the pendulum to follow a certain trajectory. How much torque is required to make the pendulum follow this prescribed motion? Solving this problem entails building a kinematic model of the moving pendulum.
The model must represent the geometry of the double pendulum and specify its motion trajectory throughout the simulation.
The model must also measure the computed torque on each joint, the torque necessary to reproduce the specified motion.
Except in simple cases, you can find these computed torques only as approximate functions of time.
The kinematic model can take different approaches to specifying the initial state of the pendulum.
One approach uses Body block parameters to specify the initial states.
Another approach uses Actuator block signals.
Open the model
It illustrates the Body block approach to modeling initial states.
This model represents the pendulum by two Body blocks and two Revolute Joint blocks.
The CS1 axis of the upper body (B1) of the pendulum is rotated 15 degrees from the perpendicular (see annotation for block B1).
The coordinate systems for the lower block (B2) are aligned with CS1 of the upper block. The CS1 of B2 is rotated -15 degrees relative to CS1 of B1, i.e., it is perpendicular to the World coordinate system.
Open the model
It shows the use of Joint Actuator blocks to specify the initial kinematic
state. Using actuators to specify the displacement slightly simplifies
the configuration of the Body blocks.
In either model, the Joint Actuator blocks connected to the
Joint blocks specify that the upper and lower joints accelerate at
two distinct rates, 2 and -1 degrees/second2,
respectively. Sensor blocks connected to To Workspace blocks measure
the computed torques on the upper and lower joints as MATLAB® workspace
respectively. These vectors capture the upper and lower computed torques
at each major time step. You must simulate either model in Inverse
Dynamics mode to compute the joint torques required to maintain the
pendulum in its motion.
Once you know the computed torques as functions of time, you can verify that these are the correct answers by creating a version of the model that applies the computed torques to the joints and simulating that model in Forward Dynamics mode.
Open the model
It illustrates a forward dynamics version of the kinematic model that
uses the joint actuators to specify the initial angular displacement
of the pendulum bodies.
This model uses Initial Condition blocks to specify the initial 15 degree displacement of the upper body from the vertical in the world coordinate system and the corresponding initial -15 degree displacement of the lower body from the vertical in the coordinate system of the upper body. The negative displacement of the lower body is equivalent to positioning it as vertical in the world coordinate system.
From a MAT-file, the model loads the upper and lower torques,
as two matrices representing discrete functions of time. Simulating
this model in Forward Dynamics mode results in the following display
on the upper joint scope.
If the computed torques were known exactly as continuous functions
of time in the two inverse dynamics models, this plot would exactly
match the upper joint motion in the original models. But the torques
are measured only in a discrete approximation, and
not exactly reproduce the original motion.
You can achieve better approximations by adjusting Simulink to report sensor outputs in the original models with finer time steps. Refer to the Simulink documentation for more about exporting simulation data and refining output.
Also, there must be no Joint Stiction Actuators and no nonholonomic constraints.
Suppose that you want to keep this system from collapsing under its own weight. Because the four bar has only one degree of freedom, applying a counterclockwise torque to the joint labeled Revolute1 would accomplish this objective. But how much torque is sufficient?
To answer this question, you must build a kinematic model of the stationary four bar system, starting with the tutorial model. The kinematic model must specify how the system moves over time. In this case, the four bar remains stationary. You can use a Joint Actuator to implement this requirement.
Open the model
The model uses a Joint Actuator block driven by a Constant block to specify the motion on the Revolute1 joint. The Constant block outputs a three-element vector that specifies the angular position, velocity, and acceleration, respectively, of the joint as 0.
The model uses a Joint Sensor block connected to a Scope block to display the resulting torque on the joint and a To Workspace block to save the torque signal to the MATLAB workspace.
Now obtain and verify the inverse dynamics solution to the question.
Run this model in Kinematics mode. The output reveals that the torque on the Revolute1 joint is 27.9 newton-meters, to the precision of the assembly tolerances specified in the Machine Environment block.
To verify that the
computed torque is, indeed, the torque required to keep the system
stationary, create a forward-dynamics model that applies the computed
torque to the Revolute1 joint. Open such a model contained in
Run the model in Forward Dynamics mode, with the Revolute1 Angle Scope open.
The Scope display reveals that the machine does, indeed, remain stationary, although only for about 0.4 seconds. The derived computed force is not exact, and the model is begins nonlinear oscillations after this period.
Tip You can reduce the inaccuracy of the derived computed force by rerunning the mech_four_bar_kin model with more restricted solver, assembly, and constraint tolerances. For the highest accuracy (at greater computational cost), consider shifting to the machine precision constraint solver. See Configuring Methods of Solution.