Main Content

Generate Policy Block for Deployment

This example shows how you can generate a Policy block ready for deployment from an agent object. The policy will be generated from the Train TD3 Agent for PMSM Control example. The policy is simulated to validate performance. If Embedded Coder® is installed, a software-in-the-loop (SIL) simulation is run to validate the generated code of the policy.

In general, the workflow for the deployment of a Reinforcement Learning policy via a Simulink® model is accomplished by the following:

  1. Train the agent (see Train TD3 Agent for PMSM Control)

  2. Generate a Policy block from the trained agent

  3. Replace the RL Agent block with the Policy block

  4. Configure the model for code generation

  5. Simulate the policy and verify policy performance

  6. Generate code for the policy, simulate the generated code, and verify policy performance

  7. Deploy to hardware for testing

This example will cover steps 2 through 6.

Load the motor parameters along with the trained TD3 agent.

sim_data;
### The Lq is observed to be lower than Ld. ### 
### Using the lower of these two for the Ld (internal variable) and higher of these two for the Lq (internal variable) for computations. ###
### The Lq is observed to be lower than Ld. ### 
### Using the lower of these two for the Ld (internal variable) and higher of these two for the Lq (internal variable) for computations. ###
             model: 'Maxon-645106'
                sn: '2295588'
                 p: 7
                Rs: 0.2930
                Ld: 8.7678e-05
                Lq: 7.7724e-05
                Ke: 5.7835
                 J: 8.3500e-05
                 B: 7.0095e-05
           I_rated: 7.2600
          QEPSlits: 4096
            N_base: 3476
             N_max: 4300
            FluxPM: 0.0046
           T_rated: 0.3471
    PositionOffset: 0.1650

               model: 'BoostXL-DRV8305'
                  sn: 'INV_XXXX'
                V_dc: 24
              I_trip: 10
              Rds_on: 0.0020
              Rshunt: 0.0070
       CtSensAOffset: 2295
       CtSensBOffset: 2286
             ADCGain: 1
         EnableLogic: 1
        invertingAmp: 1
          ISenseVref: 3.3000
    ISenseVoltPerAmp: 0.0700
           ISenseMax: 21.4286
             R_board: 0.0043
     CtSensOffsetMax: 2500
     CtSensOffsetMin: 1500

                 model: 'LAUNCHXL-F28379D'
                    sn: '123456'
         CPU_frequency: 200000000
         PWM_frequency: 5000
    PWM_Counter_Period: 20000
              ADC_Vref: 3
          ADC_MaxCount: 4095
         SCI_baud_rate: 12000000

    V_base: 13.8564
    I_base: 21.4286
    N_base: 3476
    T_base: 1.0249
    P_base: 445.3845
load("rlPMSMAgent.mat","agent");

Generate the Policy Block

Open the Simulink® model used for training the TD3 agent.

mdl_rl = "mcb_pmsm_foc_sim_RL";
open_system(mdl_rl);

Open the subsystem containing the RL Agent block.

agentblk = mdl_rl + ...
    "/Current Control/Control_System" + ... 
    "/Closed Loop Control/Reinforcement Learning/RL Agent";
open_system(get_param(agentblk,"Parent"));

To create a deployable model, the RL Agent block will be replaced with a Policy block.

Set the agent's UseExplorationPolicy property to false so the generated policy will take the greedy action at each time step. Generate the policy block using generatePolicyBlock and specify the name of the MAT file containing the policy data for the block.

% Set UseExplorationPolicy to false to ensure that the generated policy is
% greedy
agent.UseExplorationPolicy = false;

% Specify the MAT file name for the policy data
fname = "PMSMPolicyBlockData.mat";

% Delete the file if it already exists
if isfile(fname)
    delete(fname);
end

% Generate the block and the policy data
generatePolicyBlock(agent,MATFileName=fname)

Alternatively, the policy block can be generated by clicking the Generate greedy policy block from the RL Agent block mask. Use open_system(agentblk) to open the RL Agent block mask, or simply double-click the block.

Simulate the Policy

For this example, the Policy block has already replaced the RL Agent block inside of the pmsm_current_control model. This model has been configured for code generation and the Policy block loads the trained policy from the MAT file PMSMPolicyBlockData.mat generated above.

mdl_current_ctrl = "pmsm_current_control";
open_system(mdl_current_ctrl);

% Show the configuration of the policy block
policyblk = mdl_current_ctrl + ...
    "/Current Control/Control_System" + ...
    "/Closed Loop Control/Reinforcement Learning/Policy";

Use open_system(policyblk) to open the Policy block mask, or simply double-click the block.

The model mcb_pmsm_foc_sim_policy references pmsm_current_control using a model reference block. Simulate the top-level model and plot the responses for the inner and outer control loops.

% Setup the SDI
Simulink.sdi.clear;
Simulink.sdi.setSubPlotLayout(3,1);

% Open the model
mdl_policy = "mcb_pmsm_foc_sim_policy";
open_system(mdl_policy);

% Get the path to the current control block
current_ctrl_blk = mdl_policy + "/Current Control";

% Simulate the model with the current controller run in normal mode
in = Simulink.SimulationInput(mdl_policy);
in = setBlockParameter(in,current_ctrl_blk,"SimulationMode","Normal");
out_sim = sim(in);

% Get the SDI run
runSim = Simulink.sdi.Run.getLatest;

% Plot the outer control loop signals
speedSim    = getSignalsByName(runSim,"Speed_fb" );
speedRefSim = getSignalsByName(runSim,"Speed_Ref");

plotOnSubPlot(speedSim   ,1,1,true);
plotOnSubPlot(speedRefSim,1,1,true);

% Plot the inner control loop signals
idSim    = getSignalsByName(runSim,"id" );
iqSim    = getSignalsByName(runSim,"iq" );
idRefSim = getSignalsByName(runSim,"id_ref");
iqRefSim = getSignalsByName(runSim,"iq_ref");

plotOnSubPlot(idSim   ,2,1,true);
plotOnSubPlot(idRefSim,2,1,true);
plotOnSubPlot(iqSim   ,3,1,true);
plotOnSubPlot(iqRefSim,3,1,true);

Simulink.sdi.view;

Validate the Generated Code for the Policy

If Embedded Coder® is installed, the current controller model reference can be run in SIL mode. Running the current controller in SIL mode will generate code for the current controller model, including the policy block.

% Simulate the model with the current controller run in SIL mode
if ispc
    in = setBlockParameter(in,current_ctrl_blk,"SimulationMode","Software-in-the-loop");
    out_sil = sim(in);
    % Get the SDI run
    runSIL = Simulink.sdi.Run.getLatest;
    
    % Get the speed response when run in SIL mode
    speedSIL = getSignalsByName(runSIL,"Speed_fb");
    
    % Compare the SIL response to the simulated response. The SIL response
    % should be close to the response simulated in normal mode.
    speedSim.AbsTol = 1e-3;
    cr = Simulink.sdi.compareSignals(speedSim.ID,speedSIL.ID);
    
    Simulink.sdi.view;
else
    disp("The model ""pmsm_current_control"" is configured for SIL simulations on a Windows system only.")
end
### Starting serial model reference code generation build.
### Updating model reference code generation target for: pmsm_current_control
### Generating code and artifacts to 'Model specific' folder structure
### Generating code into build folder: C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control
### Invoking Target Language Compiler on pmsm_current_control.rtw
### Using System Target File: S:\21\gcampa.bdoc\matlab\rtw\c\grt\grt.tlc
### Loading TLC function libraries
........
### Initial pass through model to cache user defined code
..
### Caching model source code
...............................................................................
.......................................
### Writing header file pmsm_current_control_types.h
### Writing source file pmsm_current_control.c
### Writing header file pmsm_current_control_private.h
.
### Writing header file pmsm_current_control.h
### Writing source file C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\_sharedutils\div_s32_floor.c
### Writing header file C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\_sharedutils\div_s32_floor.h
### Writing header file rtwtypes.h
### Writing header file multiword_types.h
.
### Writing header file rtGetInf.h
### Writing source file rtGetInf.c
### Writing header file rt_nonfinite.h
### Writing source file rt_nonfinite.c
### Writing header file rtGetNaN.h
### Writing source file rtGetNaN.c
### TLC code generation complete (took .
7.246s).
..### Saving binary information cache.
### Using toolchain: MinGW64 | gmake (64-bit Windows)
### Creating 'C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\_sharedutils\rtwshared.mk' ...
### Building 'rtwshared': "S:\21\GHAMXJ~Q\matlab\bin\win64\gmake"  -f rtwshared.mk all
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\_sharedutils>call "setup_mingw.bat"  
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\_sharedutils>set "MINGW_ROOT=H:\3rdparty\internal\3265117\win64\MinGW\bin"  
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\_sharedutils>cd .  
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\_sharedutils>if "all" == "" ("S:\21\GHAMXJ~Q\matlab\bin\win64\gmake"  -f rtwshared.mk all )  else ("S:\21\GHAMXJ~Q\matlab\bin\win64\gmake"  -f rtwshared.mk all )  
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DINTEGER_CODE=0  -DNRT -DUSE_RTMODEL  @rtwshared_comp.rsp -o "div_s32_floor.obj" "C:/Users/gcampa/ONEDRI~1/DOCUME~1/MATLAB/EXAMPL~1/GCAMPA~2.BDO/RL-EX3~1/slprj/grt/_sharedutils/div_s32_floor.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DINTEGER_CODE=0  -DNRT -DUSE_RTMODEL  @rtwshared_comp.rsp -o "rtGetInf.obj" "C:/Users/gcampa/ONEDRI~1/DOCUME~1/MATLAB/EXAMPL~1/GCAMPA~2.BDO/RL-EX3~1/slprj/grt/_sharedutils/rtGetInf.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DINTEGER_CODE=0  -DNRT -DUSE_RTMODEL  @rtwshared_comp.rsp -o "rtGetNaN.obj" "C:/Users/gcampa/ONEDRI~1/DOCUME~1/MATLAB/EXAMPL~1/GCAMPA~2.BDO/RL-EX3~1/slprj/grt/_sharedutils/rtGetNaN.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DINTEGER_CODE=0  -DNRT -DUSE_RTMODEL  @rtwshared_comp.rsp -o "rt_nonfinite.obj" "C:/Users/gcampa/ONEDRI~1/DOCUME~1/MATLAB/EXAMPL~1/GCAMPA~2.BDO/RL-EX3~1/slprj/grt/_sharedutils/rt_nonfinite.c" 
"### Creating static library "./rtwshared.lib" ..." 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/ar" ruvs  ./rtwshared.lib @rtwshared.rsp 
a - div_s32_floor.obj 
a - rtGetInf.obj 
a - rtGetNaN.obj 
a - rt_nonfinite.obj 
H:\3rdparty\internal\3265117\win64\MinGW\bin/ar: creating ./rtwshared.lib 
"### Created: ./rtwshared.lib" 
"### Successfully generated all binary outputs." 
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\_sharedutils>exit /B 0  
### Using toolchain: MinGW64 | gmake (64-bit Windows)
### Creating 'C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control\pmsm_current_control.mk' ...
### Building 'pmsm_current_control_rtwlib': "S:\21\GHAMXJ~Q\matlab\bin\win64\gmake"  -f pmsm_current_control.mk all
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control>call "setup_mingw.bat"  
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control>set "MINGW_ROOT=H:\3rdparty\internal\3265117\win64\MinGW\bin"  
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control>cd .  
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control>if "all" == "" ("S:\21\GHAMXJ~Q\matlab\bin\win64\gmake"  -f pmsm_current_control.mk all )  else ("S:\21\GHAMXJ~Q\matlab\bin\win64\gmake"  -f pmsm_current_control.mk all )  
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "pmsm_current_control.obj" "C:/Users/gcampa/ONEDRI~1/DOCUME~1/MATLAB/EXAMPL~1/GCAMPA~2.BDO/RL-EX3~1/slprj/grt/pmsm_current_control/pmsm_current_control.c" 
"### Creating static library "./pmsm_current_control_rtwlib.lib" ..." 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/ar" ruvs  ./pmsm_current_control_rtwlib.lib @pmsm_current_control.rsp 
a - pmsm_current_control.obj 
H:\3rdparty\internal\3265117\win64\MinGW\bin/ar: creating ./pmsm_current_control_rtwlib.lib 
"### Created: ./pmsm_current_control_rtwlib.lib" 
"### Successfully generated all binary outputs." 
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control>exit /B 0  
### Successfully updated the model reference code generation target for: pmsm_current_control

Build Summary

Code generation targets built:

Model                 Action                        Rebuild Reason                          
============================================================================================
pmsm_current_control  Code generated and compiled.  pmsm_current_control.c does not exist.  

1 of 1 models built (0 models already up to date)
Build duration: 0h 1m 7.896s
### Preparing to start SIL simulation ...
Building with 'MinGW64 Compiler (C)'.
MEX completed successfully.
### Using toolchain: MinGW64 | gmake (64-bit Windows)
### Creating 'C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control\coderassumptions\lib\pmsm_current_control_ca.mk' ...
### Building 'pmsm_current_control_ca': "S:\21\GHAMXJ~Q\matlab\bin\win64\gmake"  -f pmsm_current_control_ca.mk all
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control\coderassumptions\lib>call "setup_mingw.bat"  
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control\coderassumptions\lib>set "MINGW_ROOT=H:\3rdparty\internal\3265117\win64\MinGW\bin"  
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control\coderassumptions\lib>cd .  
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control\coderassumptions\lib>if "all" == "" ("S:\21\GHAMXJ~Q\matlab\bin\win64\gmake"  -f pmsm_current_control_ca.mk all )  else ("S:\21\GHAMXJ~Q\matlab\bin\win64\gmake"  -f pmsm_current_control_ca.mk all )  
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DINTEGER_CODE=0  -DCA_CHECK_FLOATING_POINT_ENABLED=1 -DCA_CHECK_LONG_LONG_ENABLED=0 -DCA_CHECK_DYNAMIC_MEMORY=0 -DCA_CHECK_DAZ_ENABLED=1 -DNRT -DUSE_RTMODEL  @pmsm_current_control_ca_comp.rsp -o "coder_assumptions_hwimpl.obj" "S:/21/GHAMXJ~Q/matlab/toolbox/rtw/targets/pil/c/coder_assumptions_hwimpl.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DINTEGER_CODE=0  -DCA_CHECK_FLOATING_POINT_ENABLED=1 -DCA_CHECK_LONG_LONG_ENABLED=0 -DCA_CHECK_DYNAMIC_MEMORY=0 -DCA_CHECK_DAZ_ENABLED=1 -DNRT -DUSE_RTMODEL  @pmsm_current_control_ca_comp.rsp -o "coder_assumptions_flt.obj" "S:/21/GHAMXJ~Q/matlab/toolbox/rtw/targets/pil/c/coder_assumptions_flt.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DINTEGER_CODE=0  -DCA_CHECK_FLOATING_POINT_ENABLED=1 -DCA_CHECK_LONG_LONG_ENABLED=0 -DCA_CHECK_DYNAMIC_MEMORY=0 -DCA_CHECK_DAZ_ENABLED=1 -DNRT -DUSE_RTMODEL  @pmsm_current_control_ca_comp.rsp -o "pmsm_current_control_ca.obj" "C:/Users/gcampa/ONEDRI~1/DOCUME~1/MATLAB/EXAMPL~1/GCAMPA~2.BDO/RL-EX3~1/slprj/grt/pmsm_current_control/coderassumptions/pmsm_current_control_ca.c" 
"### Creating static library "./pmsm_current_control_ca.lib" ..." 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/ar" ruvs  ./pmsm_current_control_ca.lib @pmsm_current_control_ca.rsp 
a - coder_assumptions_hwimpl.obj 
a - coder_assumptions_flt.obj 
a - pmsm_current_control_ca.obj 
H:\3rdparty\internal\3265117\win64\MinGW\bin/ar: creating ./pmsm_current_control_ca.lib 
"### Created: ./pmsm_current_control_ca.lib" 
"### Successfully generated all binary outputs." 
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control\coderassumptions\lib>exit /B 0  
### Using toolchain: MinGW64 | gmake (64-bit Windows)
### Creating 'C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control\sil\pmsm_current_control.mk' ...
### Building 'pmsm_current_control': "S:\21\GHAMXJ~Q\matlab\bin\win64\gmake"  -f pmsm_current_control.mk all
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control\sil>call "setup_mingw.bat"  
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control\sil>set "MINGW_ROOT=H:\3rdparty\internal\3265117\win64\MinGW\bin"  
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control\sil>cd .  
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control\sil>if "all" == "" ("S:\21\GHAMXJ~Q\matlab\bin\win64\gmake"  -f pmsm_current_control.mk all )  else ("S:\21\GHAMXJ~Q\matlab\bin\win64\gmake"  -f pmsm_current_control.mk all )  
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCODER_ASSUMPTIONS_ENABLED=1 -DXIL_SIGNAL_HANDLER=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=50000 -DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=50000 -DMEM_UNIT_BYTES=1 -DMemUnit_T=uint8_T -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "xil_interface.obj" "C:/Users/gcampa/ONEDRI~1/DOCUME~1/MATLAB/EXAMPL~1/GCAMPA~2.BDO/RL-EX3~1/slprj/grt/pmsm_current_control/sil/xil_interface.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCODER_ASSUMPTIONS_ENABLED=1 -DXIL_SIGNAL_HANDLER=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=50000 -DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=50000 -DMEM_UNIT_BYTES=1 -DMemUnit_T=uint8_T -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "sil_main.obj" "C:/Users/gcampa/ONEDRI~1/DOCUME~1/MATLAB/EXAMPL~1/GCAMPA~2.BDO/RL-EX3~1/slprj/grt/pmsm_current_control/sil/sil_main.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCODER_ASSUMPTIONS_ENABLED=1 -DXIL_SIGNAL_HANDLER=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=50000 -DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=50000 -DMEM_UNIT_BYTES=1 -DMemUnit_T=uint8_T -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "rtiostream_tcpip.obj" "S:/21/GHAMXJ~Q/matlab/toolbox/coder/rtiostream/src/rtiostreamtcpip/rtiostream_tcpip.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCODER_ASSUMPTIONS_ENABLED=1 -DXIL_SIGNAL_HANDLER=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=50000 -DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=50000 -DMEM_UNIT_BYTES=1 -DMemUnit_T=uint8_T -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "xil_interface_lib.obj" "S:/21/GHAMXJ~Q/matlab/toolbox/rtw/targets/pil/c/xil_interface_lib.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCODER_ASSUMPTIONS_ENABLED=1 -DXIL_SIGNAL_HANDLER=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=50000 -DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=50000 -DMEM_UNIT_BYTES=1 -DMemUnit_T=uint8_T -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "xil_data_stream.obj" "S:/21/GHAMXJ~Q/matlab/toolbox/rtw/targets/pil/c/xil_data_stream.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCODER_ASSUMPTIONS_ENABLED=1 -DXIL_SIGNAL_HANDLER=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=50000 -DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=50000 -DMEM_UNIT_BYTES=1 -DMemUnit_T=uint8_T -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "xil_services.obj" "S:/21/GHAMXJ~Q/matlab/toolbox/rtw/targets/pil/c/xil_services.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCODER_ASSUMPTIONS_ENABLED=1 -DXIL_SIGNAL_HANDLER=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=50000 -DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=50000 -DMEM_UNIT_BYTES=1 -DMemUnit_T=uint8_T -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "xilcomms_rtiostream.obj" "S:/21/GHAMXJ~Q/matlab/toolbox/rtw/targets/pil/c/xilcomms_rtiostream.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCODER_ASSUMPTIONS_ENABLED=1 -DXIL_SIGNAL_HANDLER=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=50000 -DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=50000 -DMEM_UNIT_BYTES=1 -DMemUnit_T=uint8_T -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "xil_rtiostream.obj" "S:/21/GHAMXJ~Q/matlab/toolbox/rtw/targets/pil/c/xil_rtiostream.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCODER_ASSUMPTIONS_ENABLED=1 -DXIL_SIGNAL_HANDLER=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=50000 -DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=50000 -DMEM_UNIT_BYTES=1 -DMemUnit_T=uint8_T -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "rtiostream_utils.obj" "S:/21/GHAMXJ~Q/matlab/toolbox/coder/rtiostream/src/utils/rtiostream_utils.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCODER_ASSUMPTIONS_ENABLED=1 -DXIL_SIGNAL_HANDLER=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=50000 -DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=50000 -DMEM_UNIT_BYTES=1 -DMemUnit_T=uint8_T -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "target_io.obj" "S:/21/GHAMXJ~Q/matlab/toolbox/rtw/targets/pil/c/target_io.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCODER_ASSUMPTIONS_ENABLED=1 -DXIL_SIGNAL_HANDLER=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=50000 -DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=50000 -DMEM_UNIT_BYTES=1 -DMemUnit_T=uint8_T -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "coder_assumptions_app.obj" "S:/21/GHAMXJ~Q/matlab/toolbox/rtw/targets/pil/c/coder_assumptions_app.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCODER_ASSUMPTIONS_ENABLED=1 -DXIL_SIGNAL_HANDLER=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=50000 -DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=50000 -DMEM_UNIT_BYTES=1 -DMemUnit_T=uint8_T -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "coder_assumptions_data_stream.obj" "S:/21/GHAMXJ~Q/matlab/toolbox/rtw/targets/pil/c/coder_assumptions_data_stream.c" 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCODER_ASSUMPTIONS_ENABLED=1 -DXIL_SIGNAL_HANDLER=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DTID01EQ=0 -DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=50000 -DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=50000 -DMEM_UNIT_BYTES=1 -DMemUnit_T=uint8_T -DMODEL=pmsm_current_control -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL  @pmsm_current_control_comp.rsp -o "coder_assumptions_rtiostream.obj" "S:/21/GHAMXJ~Q/matlab/toolbox/rtw/targets/pil/c/coder_assumptions_rtiostream.c" 
"### Creating standalone executable "./pmsm_current_control.exe" ..." 
"H:\3rdparty\internal\3265117\win64\MinGW\bin/g++" -static -m64 -o ./pmsm_current_control.exe @pmsm_current_control.rsp -Wl,--start-group @pmsm_current_control_ref.rsp C:/Users/gcampa/ONEDRI~1/DOCUME~1/MATLAB/EXAMPL~1/GCAMPA~2.BDO/RL-EX3~1/slprj/grt/_sharedutils/rtwshared.lib C:/Users/gcampa/ONEDRI~1/DOCUME~1/MATLAB/EXAMPL~1/GCAMPA~2.BDO/RL-EX3~1/slprj/grt/pmsm_current_control/coderassumptions/lib/pmsm_current_control_ca.lib -Wl,--end-group  -lws2_32 
"### Created: ./pmsm_current_control.exe" 
"### Successfully generated all binary outputs." 
 
C:\Users\gcampa\OneDrive - MathWorks\Documents\MATLAB\ExampleManager\gcampa.bdoc\rl-ex31454746\slprj\grt\pmsm_current_control\sil>exit /B 0  
### Starting SIL simulation for component: pmsm_current_control
### Application stopped
### Stopping SIL simulation for component: pmsm_current_control

Once satisfied with the performance of the policy in simulation, you can use an appropriate target/hardware support package to deploy the policy to hardware.

See Also

| | | |

Related Examples

More About