-
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.
Added the initial autocoder infrastructure and time model
- Loading branch information
Showing
16 changed files
with
718 additions
and
99 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 --cxxopt=-std=c++17 | ||
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
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
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,53 @@ | ||
// | ||
// MIT License | ||
// | ||
// Copyright (c) 2020 Pathfinder for Autonomous Navigation (PAN) | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
// | ||
|
||
/** @file psim/truth/time.hpp | ||
* @author Kyle Krol | ||
*/ | ||
|
||
#ifndef PSIM_TRUTH_TIME_HPP_ | ||
#define PSIM_TRUTH_TIME_HPP_ | ||
|
||
#include <psim/truth/time.yml.hpp> | ||
|
||
namespace psim { | ||
|
||
class Time : public TimeInterface<Time> { | ||
private: | ||
typedef TimeInterface<Time> Super; | ||
|
||
public: | ||
Time() = delete; | ||
virtual ~Time() = default; | ||
|
||
Time(Configuration const &config, std::string const &prefix); | ||
|
||
virtual void step() override; | ||
|
||
Real prefix_t_s() const; | ||
Real prefix_dt_s() const; | ||
}; | ||
} // namespace psim | ||
|
||
#endif |
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,27 @@ | ||
|
||
name: TimeInterface | ||
type: Model | ||
comment: > | ||
Simple model responsible for stepping the simulation forward in time. Time | ||
is counted since the PAN epoch. | ||
args: | ||
- prefix | ||
|
||
adds: | ||
- name: "{prefix}.t.ns" | ||
type: Initialized Integer | ||
comment: > | ||
Current simulation time in nanoseconds since the PAN epoch. | ||
- name: "{prefix}.t.s" | ||
type: Lazy Real | ||
comment: > | ||
Current simulation time in seconds since the PAN epoch. | ||
- name: "{prefix}.dt.ns" | ||
type: Initialized Writable Integer | ||
comment: > | ||
Current simulation timestep in nanoseconds. | ||
- name: "{prefix}.dt.s" | ||
type: Lazy Real | ||
comment: > | ||
Current simulation timestep in seconds. |
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 |
---|---|---|
|
@@ -7,4 +7,5 @@ cppimport | |
h5py | ||
dulwich | ||
ipykernel | ||
notebook | ||
notebook | ||
pyyaml |
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,45 @@ | ||
// | ||
// MIT License | ||
// | ||
// Copyright (c) 2020 Pathfinder for Autonomous Navigation (PAN) | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
// | ||
|
||
#include <psim/truth/time.hpp> | ||
|
||
namespace psim { | ||
|
||
Time::Time(Configuration const &config, std::string const &prefix) | ||
: Super(config, prefix) { } | ||
|
||
void Time::step() { | ||
this->Super::step(); | ||
|
||
this->prefix_t_ns.get() += this->prefix_dt_ns.get(); | ||
} | ||
|
||
Real Time::prefix_t_s() const { | ||
return ((Real) prefix_t_ns.get()) / 1.0e9; | ||
} | ||
|
||
Real Time::prefix_dt_s() const { | ||
return ((Real) prefix_dt_ns.get()) / 1.0e9; | ||
} | ||
} // namespace psim |
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 @@ | ||
/** @file test/psim/truth/time_test.cpp | ||
* @author Kyle Krol | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <psim/core/configuration.hpp> | ||
#include <psim/core/simulation.hpp> | ||
#include <psim/truth/time.hpp> | ||
|
||
TEST(Time, TestStep) { | ||
auto const config = psim::Configuration::make("test/psim/truth/time_test_config.txt"); | ||
auto sim = psim::Simulation::make<psim::Time>(config, "time"); | ||
|
||
// Assert intial conditions | ||
ASSERT_EQ(sim["time.dt.ns"].get<psim::Integer>(), 5); | ||
ASSERT_EQ(sim["time.t.ns"].get<psim::Integer>(), 0); | ||
|
||
// Check the time.t.ns field is updated | ||
sim.step(); | ||
sim.step(); | ||
ASSERT_EQ(sim["time.t.ns"].get<psim::Integer>(), 10); | ||
|
||
// Check the lazy evaluated fiels | ||
ASSERT_DOUBLE_EQ(sim["time.dt.s"].get<psim::Real>(), 5e-9); | ||
ASSERT_DOUBLE_EQ(sim["time.t.s"].get<psim::Real>(), 1e-8); | ||
|
||
// Update time.dt.ns and try stepping again | ||
sim.get_writable("time.dt.ns")->get<psim::Integer>() = 4; | ||
sim.step(); | ||
ASSERT_EQ(sim["time.t.ns"].get<psim::Integer>(), 14); | ||
} |
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,2 @@ | ||
time.t.ns 0 | ||
time.dt.ns 5 |
Oops, something went wrong.