Skip to content

Getting Started With the Sim

Taylor Reynolds edited this page May 15, 2021 · 4 revisions

Where is the most current version

The current version of the flight software that is being worked on is always on the dev branch. Periodically, at major milestones, we will push to Master branch. Eventually, Master is what will be used on the spacecraft.

Folder Structure

The top-level folder structure looks like this:

  • soci-gnc
    • Include
    • Lib
    • Src
    • Test
    • Build

Source Files (Src)

The Src folder contains the main Simulink file as well as its init file, called Sim_init.m. Your first step when you want to work on things should always be to run Sim_init.m with your current Matlab directory set to Src. This will set your paths properly. It will also open the main Simulink model file and initialize everything. I suggest not changing your Matlab directory afterwards.

Library Files (Lib)

The Lib folder contains all of our Simulink libraries and their corresponding init files. All libraries require an init file to set up their specific set of variables or constants -- see the Home page on this wiki for details on that. The sub-folder structure here should be reasonably self-explanatory; things are organized based on the high-level breakdown of the simulation (sensor libraries are all in one folder, flight software libraries are in another, etc.).

Test Files (Test)

The Test folder contains all of our testing scripts and Simulink unit tests. As best as possible, I want the sub-folder structure to mirror what's in Lib. This is just so we can easily find the test that corresponds to a particular library.

Files to be Included (Include)

The Include folder contains files that help define things like bus signals, simulation configuration, two-line element sets, and more. These are auxiliary files that help setup the simulation but are not Simulink libraries themselves. This folder also contains some data files, for example, the coefficients that define the magnetic field model used onboard the spacecraft are stored in WMM.mat.

Build

This is a folder that exists to help us keep the autocoding process from cluttering up the rest of the folders. Simulink will generate some cached files automatically as you work. They're annoying. So we stuff them in the Build folder so that they don't linger all over the place. Everyone will need to do the following:

  1. go to Simulink Preferences -> General
  2. set your Simulation cache folder to ROOT/soci-gnc/Build/cache/
  3. set your Code generation folder to ROOT/soci-gnc/Build/ where ROOT is the path of the soci-gnc repository relative to your home directory (for me, ROOT is /Users/Taylor/SOCI).

Simulink Configuration

You need to set the solver settings so that things run in Fixed Step mode. Open up the Simulink Preferences window. Under Solver, make sure the following options are selected:

  1. Set Type to Fixed-step.
  2. Set Solver to auto (Automatic solver selection)
  3. Set the Fixed-step size (fundamental sample time) to be simParams.sample_time_s.

opts_solver_settings

Running the Main Sim

The steps to run the simulation are the following:

  1. make sure your current Matlab directory is the Src folder
  2. Run the Sim_init.m script
  3. As long as you get no errors, the simulation model file mainSim.slx should be opened automatically
  4. Run the Simulink model.
  5. To check on various signals, use the Simulation Data Inspector tool. Most signals of importance are being recorded and are available for ex post facto or real-time viewing. I don't particularly love this tool, but it's what exists.