How to deploy simscape models with tunable block parameters?

조회 수: 4 (최근 30일)
David Cheneler
David Cheneler 2020년 10월 2일
댓글: David Cheneler 2020년 10월 6일
I have a simscape model that I wish to deploy with simulink complier to create a standalone application. The model contains blocks (specifically revolute joints) that I wish to be able to change properties when it is an executable without using matlab. I can change variables using 'setVariable', but this doesn't work for the block properties of interest. 'setBlockParameter' will change the desired properties but this seems to be incompatible with 'simulink.compiler.configureForDeployment' which won't let the model be rebuilt.
Sample code that doesn't work:
function deployParameterTuning(params_filename,scenario_filename)
mdl = 'UR10_Motion_Driven_sim' ; % Name of simscape model generated when code is ran
in = Simulink.SimulationInput(mdl) ;
in = in.setVariable('t_max', params.t_max) ; % This is the simulation time and does update
in = in.setBlockParameter([mdl '/Payload'],'Mass','params.mp') ; % This does not update
in = simulink.compiler.configureForDeployment(in) ;
out = sim(in) ;
end
Without the 'setBlockParameter' command all runs well, but the block parameter is not updated. Is there a work around?

채택된 답변

Guy Rouleau
Guy Rouleau 2020년 10월 5일
It looks like you need to enable the display of Simscape run-tim parameter settings in blocks dialog, this cna be done fomr the Simscape preferences.
Once you se the Mass property of your block to be run-time tunable, you will be able to use setVariable on it.
Thanks,
Guy
  댓글 수: 3
Guy Rouleau
Guy Rouleau 2020년 10월 6일
For Simscape Multibody, the compile-time versus run-time property of parameters is usually the parameter name followed by "_conf". So for the Mass of a solid, it would be "Mass_conf" and the two valid choices are 'compiletime' and 'runtime'.
you can do "get_param(gcb,'dialogparameters')" to get the list of dialog parameters that cna be set using set_param.
It is not possible "re-read" the MAT-file for the Signal Editor once the model is compiled. A fw options you have:
  1. Include multiple scenarios and change the scenario
  2. Use Root-level Inport blocks. That way you will be able to read MAT-files using "load" and pass the signals to the Inport blocks using setExternalInput.
David Cheneler
David Cheneler 2020년 10월 6일
That's great. Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Run-Time Parameters에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by