Running Simulations without the GUI - Carleton-SRCL/SPOT GitHub Wiki

There are many reasons why someone might want to run the Simulink diagram without relying on the GUI. These reasons include running multiple cases one after the other or running an optimization. The initialization script has been modified for SPOT 4.1.0 to give this option to users. For SPOT 4.0.0, this can be accomplished with the following code sample:

runWithoutGUI = true

if runWithoutGUI

    simMode = 1;  %#ok<UNRCH> % Tells the Simulink diagram that a Simulation is running
    WhoAmI  = 0;  % Tells the Simulink diagram that all platforms are enabled (for Sim)
    
    % Modify platformSelection to change which platforms are active:
    % 1 - RED
    % 2 - BLACK
    % 3 - RED+BLACK
    % 4 - RED+ARM+BLACK
    % 5 - RED+ARM
    % 6 - BLUE
    % 7 - RED+BLUE
    % 8 - RED+BLUE+BLACK
    % 9 - BLUE+BLACK
    % 10 - RED+ARM+BLUE
    % 11 - RED+ARM+BLACK+BLUE
    
    platformSelection = 3;  % Tells the Simulink diagram which platforms are active
    
    simulinkFileName = 'Template_v4_1_0_2024a_Jetson';  % Change this to the name of the diagram you want to run

    % Checks if the diagram is load, and if not loads it
    if bdIsLoaded(simulinkFileName)
        % Do Nothing
    else
        open_system(simulinkFileName);
    end

    % Checks if the diagram is saved, and if not loads it
    if bdIsDirty(simulinkFileName)
        save_system(simulinkFileName);
    end

    % Run the Simulink diagram - the output of the simulation can be found in the 'out' variable.
    % Users may want to set up any repeat runs here (load parameters, then run diagram).
    % Users could also use the 'sim' command, but using 'set_param' allows for better debugging.
    set_param(simulinkFileName,'SimulationCommand','start');  

end
⚠️ **GitHub.com Fallback** ⚠️