-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Infrastructure for the new PSim (#231)
* Restructuring for incoming PSim changes: - 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 * Added the PSim configuration/parameter system * Added the PSim state field system * Added the PSim state registry * Added the PSim model and simulation base classes * Added the initial autocoder infrastructure and time model
- Loading branch information
Showing
94 changed files
with
3,538 additions
and
623 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
build --cxxopt=-std=c++14 | ||
build --python_top=//:venv --incompatible_use_python_toolchains=false |
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: PSim Regression Tests | ||
|
||
on: | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
|
||
- uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.7' | ||
architecture: 'x64' | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt-get install bazel | ||
python -m venv venv | ||
source venv/bin/activate | ||
pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Build and Test | ||
run: | | ||
bazel build //:gnc | ||
bazel build //:psim | ||
bazel test //test/psim:ci |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,3 +153,6 @@ bazel-out | |
bazel-psim | ||
bazel-testlogs | ||
bazel-genfiles | ||
|
||
# Compiler commands from Bazel | ||
compile_commands.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,75 @@ | ||
load("@rules_python//python:defs.bzl", "py_runtime", "py_binary") | ||
load("@rules_cc//cc:defs.bzl", "cc_library") | ||
|
||
load("//:tools/psim.bzl", "psim_autocode") | ||
|
||
# Build flight software's gnc code as a library. | ||
cc_library( | ||
name = "gnc", | ||
srcs = glob([ | ||
"src/gnc/**/*.hpp", "src/gnc/*.cpp", "src/gnc/**/*.inl", | ||
"include/gnc/**/*.inl" | ||
]), | ||
hdrs = glob([ | ||
"include/gnc/**/*.hpp", "include/orb/*.h", "include/orb/*.hpp" | ||
]), | ||
includes = ['include'], | ||
copts = ['-Isrc'], | ||
linkstatic = True, | ||
visibility = ["//visibility:public"], | ||
deps = ["@lin//:lin"], | ||
) | ||
|
||
# Let bazel know about our virtual environment. | ||
# | ||
# Also see additional options passed with .bazelrc to ensure we're using the | ||
# virtual environment. | ||
# | ||
# TODO : This is a little hacky and could be cleaned up with toolchains. | ||
py_runtime( | ||
name = "venv", | ||
files = glob(["venv/**"], exclude=["venv/**/* *"]), | ||
interpreter = "venv/bin/python", | ||
python_version = "PY3", | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
# Register the autocoder as an executable. | ||
# | ||
# This is later consumed by the autocoder command. See psim.bzl for more | ||
# information. | ||
py_binary( | ||
name = "autocoder", | ||
srcs = ["tools/autocoder.py"], | ||
srcs_version = "PY3", | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
# Autocode the model interfaces | ||
psim_autocode( | ||
name = "autocode", | ||
srcs = glob(["include/psim/**/*.yml"]), | ||
includes = ["include"], | ||
tool = "//:autocoder", | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
# Build all PSim models as a library | ||
# | ||
# This will be linked with executables later on. | ||
cc_library( | ||
name = "psim", | ||
srcs = glob(["src/**/*.cpp", "src/**/*.inl", "src/**/*.hpp", "include/**/*.inl"], exclude=["src/targets/*.cpp"]), | ||
hdrs = glob(["include/**/*.hpp", "include/**/*.h"]), | ||
copts = ["-Iinclude -Isrc"], | ||
srcs = glob([ | ||
"src/psim/**/*.hpp", "src/psim/**/*.inl", "src/psim/**/*.cpp", | ||
"include/psim/**/*.inl", "include/psim/**/*.yml.hpp", | ||
]), | ||
hdrs = glob( | ||
["include/psim/**/*.hpp"], | ||
exclude = ["include/psim/**/*.yml.hpp"], | ||
), | ||
includes = ["include"], | ||
copts = ["-Isrc"], | ||
linkstatic = True, | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@lin//:lin", | ||
] | ||
deps = ["@lin//:lin", "//:gnc", "//:autocode"], | ||
) |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,74 @@ | ||
|
||
# PSim | ||
|
||
This repository will hold all GNC code for the PAN mission. It will largely be | ||
comprised of the two main executables/modules: | ||
This repository holds all GNC code for the PAN mission. It will be comprised of | ||
two main modules: | ||
|
||
1. MATLAB simulation to support GNC algorithm development. | ||
2. C++ versions of all flight GNC algorithms. | ||
1. GNC algorithms and utility functions implemented in C++ that will be | ||
used by flight software and our internal simulation - PSim. | ||
2. PSim models and simulation implementations. | ||
|
||
See folder specific READMEs for more information. | ||
MATLAB code listed in `MATLAB/**` is deprecated and will be phased out by the | ||
new C++ implementation of PSim. | ||
|
||
## Running CXX Tests Locally | ||
## Getting Setup | ||
|
||
Perform the following from the root PSim directory and replace `python` in the following commands with whatver command matches Python 3.7: | ||
For GNC development, it's only necessary to setup the PlatformIO development | ||
environment. This requires setting up a local virtual environment as shown | ||
below: | ||
|
||
python -m venv venv | ||
source venv/bin/activate | ||
pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pio platform install native | ||
|
||
Officially, we support Python 3.7 (this is what continuous integration runs) but | ||
you'll most likely have success with Python 3.6+. | ||
|
||
You can ensure everything is behaving as expected by building and running tests | ||
for the GNC code with: | ||
|
||
source venv/bin/activate | ||
pio test -e native | ||
|
||
**_Note: Naming your virtual environment `venv` is required for PSim | ||
development!_** | ||
|
||
For PSim development, we need to have the virtual environment setup as shown | ||
above _and_ setup Bazel. You should be able to install Bazel through your | ||
system's package manager. | ||
|
||
It's also recommended to install the Bazel build tools along with the VSCode | ||
extensions 'Bazel' by the 'Bazel Build Team'. With this extension plus | ||
configuring C/C++ intellisense according to | ||
`tools/bazel-compilation-database.sh` the Bazel build system should integrate | ||
fairly well with VSCode. | ||
|
||
To ensure everything is working as expected, you should be able to run the | ||
following successfully: | ||
|
||
bazel test //test/psim:all | ||
|
||
## GNC | ||
|
||
The GNC library is a set of flight software algorithms (mainly controllers and | ||
estimators) along with a myriad of utility functions. | ||
|
||
The source code for the GNC library lives in `include/gnc/**` and `src/gnc/**`. | ||
The associated unit tests are located in `test/gnc/**` and can be built with | ||
PlatformIO using the following command: | ||
|
||
source venv/bin/activate | ||
pio test -e native | ||
|
||
## PSim | ||
|
||
The actual infrastructure for PSim is slightly fluid at the moment; however, | ||
this PR have a good overview of the architecture: [#231](https://github.com/pathfinder-for-autonomous-navigation/psim/pull/231). | ||
|
||
The code lives under `include/psim/**` and `src/psim/**` and leverages the GNC | ||
modules as a dependency. Unit test are implemented under `test/psim/**` and can | ||
be run with the following command: | ||
|
||
bazel test //test/psim:all --test_output=all |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
|
||
lin_build = """ | ||
cc_library( | ||
name = "lin", | ||
srcs = glob(["src/**/*.cpp", "include/**/*.inl"]), | ||
hdrs = glob(["include/**/*.hpp"]), | ||
includes = ["include"], | ||
linkstatic = True, | ||
visibility = ["//visibility:public"] | ||
git_repository( | ||
name = "rules_python", | ||
remote = "https://github.com/bazelbuild/rules_python.git", | ||
commit = "3baa2660569a76898d0f520c73b299ea39b6374d", # (9-8-2020) | ||
) | ||
|
||
http_archive( | ||
name = "gtest", | ||
url = "https://github.com/google/googletest/archive/release-1.10.0.zip", | ||
sha256 = "94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91", | ||
strip_prefix = "googletest-release-1.10.0", | ||
) | ||
""" | ||
|
||
new_git_repository( | ||
# http_archive( | ||
# name = "sofa", | ||
# url = "https://github.com/pathfinder-for-autonomous-navigation/sofa/archive/v1.0.zip", | ||
# sha256 = "a5660ff94270934c33b3fdaaf891620c9a454181dad7fb12378e66a5b73c205f", | ||
# strip_prefix = "sofa-1.0", | ||
# ) | ||
|
||
local_repository( | ||
name = "lin", | ||
init_submodules = True, | ||
remote = "https://github.com/pathfinder-for-autonomous-navigation/lin", | ||
commit = "f8fafaa5a29190663bc313a0b835201749b876b8", | ||
build_file_content = lin_build | ||
path = "lib/lin", | ||
) |
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
Oops, something went wrong.