-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infrastructure for the new PSim #231
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kylekrol
force-pushed
the
feature/cxx-psim
branch
from
September 12, 2020 18:29
e3eb135
to
938a4dc
Compare
kylekrol
force-pushed
the
feature/cxx-psim
branch
7 times, most recently
from
September 12, 2020 22:22
3ed3ec8
to
d7e1af3
Compare
Description is in progress. I definitely recommend looking at it commit by commit! |
* Removed Docker support. * Added a library.json file for better PIO support. * Migrate gnc tests and sources to a gnc subdirectory. * Refactored test names to be common across all modules. * Update the lin submodule and fixed issues with breaking changes. * Renamed the //:psim Bazel target to //:gnc
kylekrol
force-pushed
the
feature/cxx-psim
branch
from
September 13, 2020 16:58
12397cd
to
1a1a344
Compare
tanishqaggarwal
approved these changes
Sep 20, 2020
athena255
approved these changes
Sep 20, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this is really clean.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Infrastructure for the new PSim
This PR contains most of the C++ infrastructure code and the Bazel build system for the PSim. It's structured as a library of "models" that will later be linked into small PyBind11 packages which will be used to test GNC software and run the simulation with PTest.
To jump right in and run some tests, execute the following commands from the root of the PSim repository:
This will compile the GNC library, PSim library, and link both of those into the current set of PSim unit tests written with GoogleTest. The Python virtual environment is required for the model interface autocoder (more on this later).
To get intellisense working with the Bazel build system, take a look at the
tools/bazel-compilation-database.sh
file.Motivation
The following outlines the new features we're looking for out of a simulation written in C++ and why we're moving away from MATLAB:
In addition to the above grievances, we're striving for some other features as well:
Architecture
As alluded to above, PSim will be written as a collection of "models". These models will interact with the other two main components of PSim when integrated into a full simulation: the configuration and the state field systems.
Configuration
At a high level, the configuration system is responsible for parsing configuration files (simple key-value text files) into a set of "parameters" that can be read in by models during sim initialization.
See the following files for more details:
State Fields
State fields and a simulations state registry are responsible for tracking and providing access to the state of the simulation as it evolves over simulation steps (doesn't necessarily have to be forward in time but it pretty much always is).
State fields can be registered to the simulation state in two fashions: either as a writable field or a plain state field (presented as a read-only field). A writable field can be written from outside the simulation or another model (say a reaction wheel actuator model that's supposed to present a wheel torque to the attitude dynamics model). Fields registered as read-only can only have telemetry pulled from them from outside the simulation or by another model.
There is one kind of read-only field I'd like to draw special attention to and that's the
template <typename T> class StateFieldLazy<T>
. This field holds astd::function<T ()>
that can be called if/when the state field is accessed. This helps handle the "support a wide range of telemetry" requirement as we can "teach" the sim how to evaluate a bunch of parameters that may only be accessed once in a blue moon.See the following files for more details:
Models
Models are where the bulk of future simulation development will be happening. They're responsible for adding there state fields to the simulation state, retrieving additional fields from the state they may need, and specifying how these fields relate and should be stepped forward.
As one could imagine, writing all of the "wiring" code over and over again would get a little annoying. To help combat this and standardize how models should interact with the simulation at large, all model interfaces are to be specified in a YAML file which will then be autocoded into a model base class. This base class interface could have multiple implementations in the form of many derived classes.
Last quick thing to note, a model can also be an ordered list of other models. We call this a
ModelList
and it will be helpful in assembling complex simulations into a single model (important for creating a simulation).See the following files for more details:
Simulation
The last stop on the architecture overview is the full on simulation! The only thing the simulation class as a whole does is bring together the configuration, model, and state field systems into a functioning simulation.
See the following files for more details: