How can I stop errors in Simulink and Simscape?

2 vues (au cours des 30 derniers jours)
Omer Utku Altindag
Omer Utku Altindag le 11 Mai 2021
Commenté : Yifeng Tang le 11 Mai 2021
Hello eveyone,
I am trying to build an basketball shooting arm model with simscape. I got motion capture data and I am trying to create the model according to motion capture motion. To do this I have to optimize 42 parameters and I am using Simulated Annealing Algorithm to optimize them. Everything is ready but I got a problem.
Line 118 runs the simularion and at the end of the simulation, Line 120 gives me the simularion results as a matrix.
My code is like that:
%% .... blah blah blah .....
118- sim('basketball_shooting_simulation.slx')
119
120-out_table= [ans.out_shoulder.time,ans.out_shoulder.signals.values,ans.out_elbow.signals.values,ans.out_wrist.signals.values];
121-assignin('base','ans',ans)
122-t_s=(0:0.004:0.312);
123-angle_results = out_table(ismembertol(out_table(:,1),t_s),:);
124-assignin('base','angle_results',angle_results)
%% after this step bring the results to comparison function .....
When I start the optimization program, it runs several times and it stops immediately because of the simscape errors like:
An error occurred while running the simulation and the simulation was terminated
Caused by:
  • Derivative of state 'basketball_shooting_simulation.Basketball_Shooting_Arm_Model.shoulder_joint.Rz.w' in block 'basketball_shooting_simulation/Basketball Shooting Arm Model/shoulder joint' at time 0.220275 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)
As we can understand here I don't want to use this run's parameters and optimization must be continue but it is not. After this error everything stops immediately.
How can I get the lastes results of simulation without errors and continue the optimization?
I would be appeciate I you can help me.
  1 commentaire
Yifeng Tang
Yifeng Tang le 11 Mai 2021
Maybe use a try ... catch ... syntax for the simulation call? When it fails and falls to a "catch", assign some garbage output that the optimizer will hate.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Run-Time Parameters dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by