Skip to content

Commit 1a1a344

Browse files
committed
Added the initial autocoder infrastructure and time model
1 parent 0a07790 commit 1a1a344

File tree

16 files changed

+717
-98
lines changed

16 files changed

+717
-98
lines changed

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
build --cxxopt=-std=c++14
2+
build --python_top=//:venv --incompatible_use_python_toolchains=false

.github/workflows/bazel.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/main.yml renamed to .github/workflows/gnc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PSim Regression Tests
1+
name: GNC Regression Tests
22

33
on:
44
pull_request:
@@ -11,6 +11,7 @@ jobs:
1111
- uses: actions/checkout@v2
1212
with:
1313
submodules: 'recursive'
14+
1415
- uses: actions/setup-python@v1
1516
with:
1617
python-version: '3.7'

.github/workflows/psim.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: PSim Regression Tests
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
with:
13+
submodules: 'recursive'
14+
15+
- uses: actions/setup-python@v1
16+
with:
17+
python-version: '3.7'
18+
architecture: 'x64'
19+
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get install bazel
23+
python -m venv venv
24+
source venv/bin/activate
25+
pip install --upgrade pip
26+
pip install -r requirements.txt
27+
28+
- name: Build and Test
29+
run: |
30+
bazel build //:gnc
31+
bazel build //:psim
32+
bazel test //test/psim:ci

BUILD

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# load("@rules_python//python:defs.bzl", "py_runtime", "py_binary")
1+
load("@rules_python//python:defs.bzl", "py_runtime", "py_binary")
22
load("@rules_cc//cc:defs.bzl", "cc_library")
33

4-
# load("//:tools/psim.bzl", "psim_autocode")
4+
load("//:tools/psim.bzl", "psim_autocode")
55

66
# Build flight software's gnc code as a library.
77
cc_library(
@@ -26,33 +26,33 @@ cc_library(
2626
# virtual environment.
2727
#
2828
# TODO : This is a little hacky and could be cleaned up with toolchains.
29-
# py_runtime(
30-
# name = "venv",
31-
# files = glob(["venv/**"], exclude=["venv/**/* *"]),
32-
# interpreter = "venv/bin/python",
33-
# python_version = "PY3",
34-
# visibility = ["//visibility:private"],
35-
# )
29+
py_runtime(
30+
name = "venv",
31+
files = glob(["venv/**"], exclude=["venv/**/* *"]),
32+
interpreter = "venv/bin/python",
33+
python_version = "PY3",
34+
visibility = ["//visibility:private"],
35+
)
3636

3737
# Register the autocoder as an executable.
3838
#
3939
# This is later consumed by the autocoder command. See psim.bzl for more
4040
# information.
41-
# py_binary(
42-
# name = "autocoder",
43-
# srcs = ["tools/autocoder.py"],
44-
# srcs_version = "PY3",
45-
# visibility = ["//visibility:private"],
46-
# )
41+
py_binary(
42+
name = "autocoder",
43+
srcs = ["tools/autocoder.py"],
44+
srcs_version = "PY3",
45+
visibility = ["//visibility:private"],
46+
)
4747

4848
# Autocode the model interfaces
49-
# psim_autocode(
50-
# name = "autocode",
51-
# srcs = glob(["include/psim/**/*.yml"]),
52-
# includes = ["include"],
53-
# tool = "//:autocoder",
54-
# visibility = ["//visibility:private"],
55-
# )
49+
psim_autocode(
50+
name = "autocode",
51+
srcs = glob(["include/psim/**/*.yml"]),
52+
includes = ["include"],
53+
tool = "//:autocoder",
54+
visibility = ["//visibility:private"],
55+
)
5656

5757
# Build all PSim models as a library
5858
#
@@ -61,15 +61,15 @@ cc_library(
6161
name = "psim",
6262
srcs = glob([
6363
"src/psim/**/*.hpp", "src/psim/**/*.inl", "src/psim/**/*.cpp",
64-
"include/psim/**/*.inl", # "include/psim/**/*.yml.hpp",
64+
"include/psim/**/*.inl", "include/psim/**/*.yml.hpp",
6565
]),
6666
hdrs = glob(
6767
["include/psim/**/*.hpp"],
68-
#exclude = ["include/psim/**/*.yml.hpp"],
68+
exclude = ["include/psim/**/*.yml.hpp"],
6969
),
7070
includes = ["include"],
7171
copts = ["-Isrc"],
7272
linkstatic = True,
7373
visibility = ["//visibility:public"],
74-
deps = ["@lin//:lin", "//:gnc"],# "//:autocode"],
74+
deps = ["@lin//:lin", "//:gnc", "//:autocode"],
7575
)

WORKSPACE

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2-
# load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
2+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
33

4-
# git_repository(
5-
# name = "rules_python",
6-
# remote = "https://github.com/bazelbuild/rules_python.git",
7-
# commit = "3baa2660569a76898d0f520c73b299ea39b6374d", # (9-8-2020)
8-
# )
4+
git_repository(
5+
name = "rules_python",
6+
remote = "https://github.com/bazelbuild/rules_python.git",
7+
commit = "3baa2660569a76898d0f520c73b299ea39b6374d", # (9-8-2020)
8+
)
99

1010
http_archive(
1111
name = "gtest",

estimatortest/pythonwrapper/pwrap.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ mypath=Path(filepath)
77
psimpath= mypath.parent.parent.parent
88
#flightsoftwarepath= psimpath.parent/'FlightSoftware'
99
# 'dependencies' controls what get checked for changes before recompile
10-
cfg['dependencies'] = [str(p) for p in (psimpath/'src').rglob('*') if p.is_file()]
10+
cfg['dependencies'] = [str(p) for p in (psimpath/'src/gnc').rglob('*') if p.is_file()]
1111
cfg['dependencies'] += [str(p) for p in (psimpath/'lib').rglob('*') if p.is_file()]
12-
cfg['dependencies'] += [str(p) for p in (psimpath/'include').rglob('*') if p.is_file()]
12+
cfg['dependencies'] += [str(p) for p in (psimpath/'include/gnc').rglob('*') if p.is_file()]
13+
cfg['dependencies'] += [str(p) for p in (psimpath/'include/orb').rglob('*') if p.is_file()]
1314
cfg['dependencies'] += [str(mypath.parent/'lin_ext.cpp')]
1415
cfg['dependencies'] += [str(mypath.parent/'orb_ext.cpp')]
1516
#cfg['dependencies'] += [str(p) for p in (flightsoftwarepath/'src').rglob('*') if p.is_file()]
1617
#cfg['dependencies'] += [str(p) for p in (flightsoftwarepath/'lib').rglob('*') if p.is_file()]
1718
1819
cfg['sources'] = ['lin_ext.cpp', 'orb_ext.cpp']
19-
cfg['sources'] += [str(p) for p in (psimpath/'src').rglob('*.cpp') if (p.is_file() and p.parent.name!='targets')]
20+
cfg['sources'] += [str(p) for p in (psimpath/'src/gnc').rglob('*.cpp') if (p.is_file() and p.parent.name!='targets')]
2021
#cfg['sources'] += [str(p) for p in (flightsoftwarepath/'src/fsw').rglob('*.cpp') if (p.is_file() and p.parent.name!='targets')]
2122
#cfg['sources'] += [str(p) for p in (flightsoftwarepath/'src/common').rglob('*.cpp') if (p.is_file() and p.parent.name!='targets')]
2223

include/psim/truth/time.hpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// MIT License
3+
//
4+
// Copyright (c) 2020 Pathfinder for Autonomous Navigation (PAN)
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
// SOFTWARE.
23+
//
24+
25+
/** @file psim/truth/time.hpp
26+
* @author Kyle Krol
27+
*/
28+
29+
#ifndef PSIM_TRUTH_TIME_HPP_
30+
#define PSIM_TRUTH_TIME_HPP_
31+
32+
#include <psim/truth/time.yml.hpp>
33+
34+
namespace psim {
35+
36+
class Time : public TimeInterface<Time> {
37+
private:
38+
typedef TimeInterface<Time> Super;
39+
40+
public:
41+
Time() = delete;
42+
virtual ~Time() = default;
43+
44+
Time(Configuration const &config, std::string const &prefix);
45+
46+
virtual void step() override;
47+
48+
Real prefix_t_s() const;
49+
Real prefix_dt_s() const;
50+
};
51+
} // namespace psim
52+
53+
#endif

include/psim/truth/time.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
name: TimeInterface
3+
type: Model
4+
comment: >
5+
Simple model responsible for stepping the simulation forward in time. Time
6+
is counted since the PAN epoch.
7+
8+
args:
9+
- prefix
10+
11+
adds:
12+
- name: "{prefix}.t.ns"
13+
type: Initialized Integer
14+
comment: >
15+
Current simulation time in nanoseconds since the PAN epoch.
16+
- name: "{prefix}.t.s"
17+
type: Lazy Real
18+
comment: >
19+
Current simulation time in seconds since the PAN epoch.
20+
- name: "{prefix}.dt.ns"
21+
type: Initialized Writable Integer
22+
comment: >
23+
Current simulation timestep in nanoseconds.
24+
- name: "{prefix}.dt.s"
25+
type: Lazy Real
26+
comment: >
27+
Current simulation timestep in seconds.

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ cppimport
77
h5py
88
dulwich
99
ipykernel
10-
notebook
10+
notebook
11+
pyyaml

0 commit comments

Comments
 (0)