-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started With the Sim
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.
The top-level folder structure looks like this:
- soci-gnc
- Include
- Lib
- Src
- Test
- Build
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.
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.).
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.
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.
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:
- go to
Simulink Preferences -> General - set your
Simulation cache foldertoROOT/soci-gnc/Build/cache/ - set your
Code generation foldertoROOT/soci-gnc/Build/whereROOTis the path of thesoci-gncrepository relative to your home directory (for me,ROOTis/Users/Taylor/SOCI).
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:
- Set
TypetoFixed-step. - Set
Solvertoauto (Automatic solver selection) - Set the
Fixed-step size (fundamental sample time)to besimParams.sample_time_s.

The steps to run the simulation are the following:
- make sure your current Matlab directory is the
Srcfolder - Run the
Sim_init.mscript - As long as you get no errors, the simulation model file
mainSim.slxshould be opened automatically - Run the Simulink model.
- 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.