This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Steady-State Simulation with Projection-Based Trim Optimizer

This example shows how to find a steady-state operating point for a Simscape™ Multibody™ model using findop with a projection-based optimizer. Results are verified using simulation.

Open Model

Open the Simulink model.

mdl = 'scdbackhoeTRIM';
open_system(mdl)

Define Operating Point Specifications

Before creating an operating point specification, configure the model to use the model initial condition.

set_param(mdl,'LoadExternalInput','off')
set_param(mdl,'LoadInitialState','off')

Create a default operating point specification object.

ops = operspec(mdl);

Impose constraints on the outputs.

ops.Outputs(1).Known = true(10,1);
ops.Outputs(1).y(1) = 0;    % Bucket angle
ops.Outputs(1).y(3) = 50;   % Upper angle
ops.Outputs(1).y(5) = -50;  % Lower angle
ops.Outputs(1).y(7) = 0;    % Base angle
ops.Outputs(1).y(9) = -45;  % Support angle

Configure Trim Options

Configure trim optimizer options. Set the 'OptimizerType' option to 'graddescent-proj', which is a projection-based trim optimizer that enforces consistency of the model physical states. To display trim progress, set the 'DisplayReport' option to 'iter'.

opt = findopOptions('OptimizerType','graddescent-proj',...
                    'DisplayReport','iter');
opt.OptimizationOptions.MaxFunEvals = 20000;

Trim Model

Find the steady-state operating point that meets these specifications. The following command takes a few minutes.

[op,rpt] = findop(mdl,ops,opt);
Optimizing to solve for all desired dx/dt=0, x(k+1)-x(k)=0, and y=ydes.
 
(Maximum Error)  Block
 ---------------------------------------------------------
(4.50000e+01) scdbackhoeTRIM/Out1
(3.88972e+00) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Right/Revolute Joint  Arm
(3.25130e+00) scdbackhoeTRIM/Plant/Backhoe Arm/Arm-Bucket Joint
(2.92756e+00) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Left/Revolute Joint  Arm
(2.90835e+00) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Left/Revolute Joint  Arm
(2.87033e+00) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Left/Revolute Joint  Arm
(2.88039e+00) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Left/Revolute Joint  Arm
(2.75915e+00) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Left/Revolute Joint  Arm
(2.82770e+00) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Left/Revolute Joint  Arm
(2.83204e+00) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Left/Revolute Joint  Arm
(2.77134e+00) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Left/Revolute Joint  Arm
(2.77170e+00) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Left/Revolute Joint  Arm
(2.66093e+00) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Left/Revolute Joint  Arm
(1.91196e+00) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Left/Revolute Joint  Arm
(1.48418e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.48194e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.92844e+00) scdbackhoeTRIM/Out1
(1.47015e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.46951e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.47048e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.47087e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.47081e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.47072e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.47065e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.47067e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.47062e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.47044e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.47049e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.47044e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.47035e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.47009e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.46945e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.46915e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.46650e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.45218e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.43599e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.39092e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.32192e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.32141e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.34505e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.34732e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.34643e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.34590e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.34577e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.34579e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.34598e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.34609e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.34550e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.34208e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.33732e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(1.21415e+00) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(5.03874e-01) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(5.04915e-01) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(3.02028e-01) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(2.00116e-01) scdbackhoeTRIM/Out1
(2.80354e-01) scdbackhoeTRIM/Out1
(8.41676e-02) scdbackhoeTRIM/Plant/Lower Arm to Mounting Assembly
(9.96485e-02) scdbackhoeTRIM/Plant/Lower Arm to Mounting Assembly
(1.04079e-01) scdbackhoeTRIM/Plant/Lower Arm to Mounting Assembly
(9.08181e-02) scdbackhoeTRIM/Out1
(8.72986e-02) scdbackhoeTRIM/Out1
(2.96463e-02) scdbackhoeTRIM/Plant/Backhoe Arm/Upper-Lower Arm Joint
(9.04872e-03) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Left/Revolute Joint  Arm
(2.39393e-03) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Right/Revolute Joint  Arm
(1.28775e-03) scdbackhoeTRIM/Plant/Backhoe Arm/Hydraulic Actuator Lower - Upper Arm/Prismatic  Joint
(1.61736e-04) scdbackhoeTRIM/Plant/Mounting Assembly/Mounting Base and Support Arms/Support  Arm Left/Revolute Joint  Arm
(1.59106e-04) scdbackhoeTRIM/Plant/Hydraulic Actuator Mounting - Lower Arm/Prismatic  Joint
(1.70351e-05) scdbackhoeTRIM/Plant/Cylinder Base to Mounting Plate
(2.39957e-05) scdbackhoeTRIM/Plant/Hydraulic Actuator Mounting - Lower Arm/Prismatic  Joint
(1.49012e-05) scdbackhoeTRIM/Plant/Hydraulic Actuator Mounting - Lower Arm/Hydraulic Actuator/Simulink-PS Converter1
(7.45058e-06) scdbackhoeTRIM/Plant/Backhoe Arm/Hydraulic Actuator Lower - Upper Arm/Hydraulic Actuator/Simulink-PS Converter1
(7.45058e-06) scdbackhoeTRIM/Plant/Backhoe Arm/Hydraulic Actuator Lower - Upper Arm/Hydraulic Actuator/Simulink-PS Converter1

Operating point specifications were successfully met.

Simulate Model

Simulate the model from the computed steady state.

set_param(mdl, 'LoadExternalInput','on')
set_param(mdl, 'ExternalInput','getinputstruct(op)')
set_param(mdl, 'LoadInitialState','on')
set_param(mdl, 'InitialState','getstatestruct(op)')
sim(mdl)

Open scope to inspect results.

open_system([mdl, '/Joint Angle Trajectories'])

The simulation results show that the five angles are trimmed to their expected values, however the trajectory deviates slightly over time due to numerical noise and instability. You can stabilize the angles using feedback controllers.

bdclose(mdl)

See Also

Functions

Related Topics