├── .devcontainer └── devcontainer.json ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── tutorial_wanted.md ├── dependabot.yml └── workflows │ ├── build-test.yml │ └── release.yml ├── .gitignore ├── .vscode ├── c_cpp_properties.json ├── launch.json ├── settings.json └── tasks.json ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── bindings └── python │ ├── CMakeLists.txt │ ├── README.md │ ├── docs │ └── Reference.ipynb │ ├── requirements.txt │ ├── src │ ├── OpenSpaceToolkitSimulationPy.cxx │ └── OpenSpaceToolkitSimulationPy │ │ ├── Component.cpp │ │ ├── Component │ │ ├── Geometry.cpp │ │ └── State.cpp │ │ ├── Entity.cpp │ │ ├── Satellite.cpp │ │ ├── Simulator.cpp │ │ └── Utility │ │ ├── ArrayCasting.hpp │ │ ├── ComponentHolder.cpp │ │ └── ShiftToString.hpp │ ├── test │ ├── __init__.py │ ├── test_import.py │ ├── test_satellite.py │ └── test_simulator.py │ ├── thirdparty │ └── boost_numpy_eigen │ │ ├── eigen_numpy.cpp │ │ └── eigen_numpy.h │ └── tools │ ├── cmake │ ├── DocumentationTargets.cmake │ ├── FindBoostNumPy.cmake │ ├── FindEigen3.cmake │ ├── GetGitRevisionDescription.cmake │ ├── GetGitRevisionDescription.cmake.in │ └── UninstallTarget.cmake.in │ └── python │ ├── ostk │ ├── __init__.py │ └── simulation │ │ └── __init__.py │ ├── pyproject.toml.in │ └── setup.cfg.in ├── docker ├── development │ └── Dockerfile ├── jupyter │ ├── Dockerfile │ └── shortcuts-extension │ │ └── plugin.jupyterlab-settings └── release │ └── Dockerfile ├── docs ├── .gitkeep ├── CMakeLists.txt ├── Tutorial.md ├── conf.py ├── cpp.rst ├── doxygen │ ├── Doxyfile.in │ └── html │ │ ├── DoxygenLayout.xml │ │ ├── doxygenextra.css │ │ ├── footer.html │ │ └── header.html ├── index.html ├── index.md ├── python.rst ├── requirements.txt └── templates │ ├── custom-class-template.rst │ └── custom-module-template.rst ├── include └── OpenSpaceToolkit │ └── Simulation │ ├── Component.hpp │ ├── Component │ ├── Geometry.hpp │ └── State.hpp │ ├── Entity.hpp │ ├── Satellite.hpp │ ├── Simulator.hpp │ └── Utility │ ├── ComponentHolder.hpp │ └── Identifier.hpp ├── share └── .gitkeep ├── src └── OpenSpaceToolkit │ └── Simulation │ ├── Component.cpp │ ├── Component │ ├── Geometry.cpp │ └── State.cpp │ ├── Entity.cpp │ ├── Satellite.cpp │ ├── Simulator.cpp │ └── Utility │ ├── ComponentHolder.cpp │ └── Identifier.cpp ├── test ├── Global.test.hpp ├── Main.test.cxx ├── OpenSpaceToolkit │ └── Simulation │ │ ├── Component │ │ └── State.test.cpp │ │ ├── Satellite.test.cpp │ │ ├── Simulator.test.cpp │ │ └── Utility │ │ └── Identifier.test.cpp └── Setup.test.hpp ├── thirdparty ├── clang │ └── .clang-format ├── doxygen │ └── CMakeLists.txt └── gtest │ └── CMakeLists.txt ├── tools ├── cmake │ ├── CodeCoverage.cmake │ ├── DocumentationTargets.cmake │ ├── FindNLopt.cmake │ ├── FindSGP4.cmake │ ├── GetGitRevisionDescription.cmake │ ├── GetGitRevisionDescription.cmake.in │ ├── OpenSpaceToolkitSimulationConfig.cmake.in │ ├── OpenSpaceToolkitSimulationConfigVersion.cmake.in │ └── UninstallTarget.cmake.in └── development │ └── start.sh └── tutorials ├── cpp └── .gitkeep └── python └── .gitkeep /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Open Space Toolkit Simulation", 3 | "image": "ghcr.io/loft-orbital/open-space-toolkit-simulation-development-non-root:latest", 4 | "initializeCommand": "make build-development-image-non-root && mkdir -p ${localWorkspaceFolder}/build", 5 | "workspaceMount": "source=${localWorkspaceFolder},target=/app,type=bind", 6 | "workspaceFolder": "/app", 7 | "containerUser": "developer", 8 | "updateRemoteUserUID": true, 9 | "runArgs": [ 10 | "--name", 11 | "open-space-toolkit-simulation-dev-non-root" 12 | ], 13 | "mounts": [ 14 | "source=ostk_simulation_vscode_extensions,target=/home/developer/.vscode-server/extensions,type=volume", 15 | "source=${localEnv:HOME}/.ssh,target=/home/developer/.ssh,type=bind,readonly", 16 | "source=${localEnv:HOME}/.gitconfig,target=/home/developer/.gitconfig,type=bind,readonly" 17 | ], 18 | "shutdownAction": "stopContainer", 19 | "customizations": { 20 | "vscode": { 21 | "extensions": [ 22 | "ms-vscode.cpptools", 23 | "ms-python.python", 24 | "ms-python.black-formatter", 25 | "mhutchie.git-graph", 26 | "ms-vscode.cpptools-extension-pack", 27 | "mechatroner.rainbow-csv", 28 | "twxs.cmake" 29 | ], 30 | "settings": { 31 | "C_Cpp.clang_format_style": "file:/app/thirdparty/clang/.clang-format", 32 | "terminal.integrated.cwd": "/app/build", 33 | "terminal.integrated.profile.linux": { 34 | "zsh": { 35 | "path": "/bin/zsh" 36 | } 37 | }, 38 | "terminal.integrated.defaultProfile.linux": "zsh", 39 | "python.defaultInterpreterPath": "/usr/local/bin/python3.11", 40 | "python.analysis.diagnosticSeverityOverrides": { 41 | "reportMissingModuleSource": "none" 42 | } 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.ipynb linguist-vendored 2 | *.sc linguist-vendored 3 | *.t linguist-vendored 4 | *.tf linguist-vendored 5 | 6 | *.bsp filter=lfs diff=lfs merge=lfs -text 7 | *.dat filter=lfs diff=lfs merge=lfs -text 8 | *.tf filter=lfs diff=lfs merge=lfs -text 9 | *.bpc filter=lfs diff=lfs merge=lfs -text 10 | *.tls filter=lfs diff=lfs merge=lfs -text 11 | *.pc filter=lfs diff=lfs merge=lfs -text 12 | *.tpc filter=lfs diff=lfs merge=lfs -text 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[fix] Issue title" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. Describe if the bug appears in the cpp code, in the bindings, if it affects the unit tests, the compilation steps. Provide the versions of the library that are used in your setup or the hash of the images used (if any). 12 | 13 | **Steps to reproduce** 14 | Steps to reproduce the behavior (add code snippets as needed): 15 | 1. 16 | 2. 17 | 3. 18 | 4. 19 | 20 | Don't hesitate to add screenshots if that helps. 21 | 22 | **Expected behavior** 23 | A clear and concise description of what you expected to happen with code snippets if possible. 24 | 25 | **Additional context** 26 | Add any other context about the problem here. 27 | 28 | **Potential suggestion** 29 | Add envisioned options to fix the bug if you have thought of any. 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[feat] Issue title" 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. Any relevant information related to your specific use case should be added! 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/tutorial_wanted.md: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: Tutorial wanted 4 | about: Request tutorial for a specific topic 5 | title: "[feat] Tutorial title" 6 | labels: tutorial 7 | assignees: '' 8 | 9 | --- 10 | 11 | **Is the tutorial related to a new feature that is not yet documented?** 12 | New features are added often. Does this concern a recently released feature that is not covered by an existing tutorial? 13 | 14 | **Are you trying to figure out how to do something with the existing set of features?** 15 | Please describe the scenario you are trying to implement. If the capability does not exist, this could lead to a new feature request! 16 | 17 | **Additional context** 18 | Add any other context or screenshots about the tutorial request here. Any relevant information related to your specific use case should be added! 19 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | version: 2 4 | updates: 5 | - package-ecosystem: "pip" 6 | directory: "/bindings/python/" # Location of package manifests 7 | schedule: 8 | interval: "daily" 9 | ignore: 10 | - dependency-name: "*" 11 | update-types: ["version-update:semver-major"] 12 | -------------------------------------------------------------------------------- /.github/workflows/build-test.yml: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | name: Build and Test 4 | 5 | on: 6 | push: 7 | branches: 8 | - main 9 | pull_request: 10 | 11 | concurrency: 12 | group: main-${{ github.ref }} 13 | cancel-in-progress: true 14 | 15 | env: 16 | PROJECT_NAME: open-space-toolkit-simulation 17 | 18 | jobs: 19 | prepare-environment: 20 | name: Prepare Environment Variables 21 | runs-on: ubuntu-latest 22 | outputs: 23 | project_name: ${{ steps.project-name.outputs.value }} 24 | project_version: ${{ steps.project-version.outputs.value }} 25 | steps: 26 | - name: Checkout Repository 27 | uses: actions/checkout@v4 28 | with: 29 | fetch-depth: 0 30 | lfs: true 31 | - id: project-name 32 | name: Get Project Name 33 | run: | 34 | echo "Project name: ${{ env.PROJECT_NAME }}" 35 | echo "value=${{ env.PROJECT_NAME }}" >> $GITHUB_OUTPUT 36 | - id: project-version 37 | name: Get Project Version 38 | run: | 39 | project_version=$(git describe --tags --always) 40 | echo "Project version: ${project_version}" 41 | echo "value=${project_version}" >> $GITHUB_OUTPUT 42 | 43 | build-development-image: 44 | name: Build Development Image 45 | needs: 46 | - prepare-environment 47 | uses: open-space-collective/open-space-toolkit/.github/workflows/build-image.yml@main 48 | with: 49 | project_name: ${{ needs.prepare-environment.outputs.project_name }} 50 | project_version: ${{ needs.prepare-environment.outputs.project_version }} 51 | secrets: inherit 52 | 53 | test: 54 | name: Test 55 | needs: 56 | - prepare-environment 57 | - build-development-image 58 | uses: open-space-collective/open-space-toolkit/.github/workflows/test.yml@main 59 | with: 60 | project_name: ${{ needs.prepare-environment.outputs.project_name }} 61 | project_version: ${{ needs.prepare-environment.outputs.project_version }} 62 | secrets: inherit 63 | 64 | package: 65 | name: Package 66 | needs: 67 | - prepare-environment 68 | - build-development-image 69 | - test 70 | uses: open-space-collective/open-space-toolkit/.github/workflows/build-packages.yml@main 71 | with: 72 | project_name: ${{ needs.prepare-environment.outputs.project_name }} 73 | project_version: ${{ needs.prepare-environment.outputs.project_version }} 74 | secrets: inherit 75 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | name: Release 4 | 5 | on: 6 | release: 7 | types: [published] 8 | 9 | env: 10 | PROJECT_NAME: open-space-toolkit-simulation 11 | 12 | jobs: 13 | prepare-environment: 14 | name: Prepare Environment Variables 15 | runs-on: ubuntu-latest 16 | outputs: 17 | project_name: ${{ steps.project-name.outputs.value }} 18 | project_version: ${{ steps.project-version.outputs.value }} 19 | steps: 20 | - name: Checkout Repository 21 | uses: actions/checkout@v4 22 | with: 23 | fetch-depth: 0 24 | lfs: true 25 | - id: project-name 26 | name: Get Project Name 27 | run: | 28 | echo "Project name: ${{ env.PROJECT_NAME }}" 29 | echo "value=${{ env.PROJECT_NAME }}" >> $GITHUB_OUTPUT 30 | - id: project-version 31 | name: Get Project Version 32 | run: | 33 | project_version=$(git describe --tags --always) 34 | echo "Project version: ${project_version}" 35 | echo "value=${project_version}" >> $GITHUB_OUTPUT 36 | 37 | build-development-image: 38 | name: Build Development Image 39 | needs: 40 | - prepare-environment 41 | uses: open-space-collective/open-space-toolkit/.github/workflows/build-image.yml@main 42 | with: 43 | project_name: ${{ needs.prepare-environment.outputs.project_name }} 44 | project_version: ${{ needs.prepare-environment.outputs.project_version }} 45 | secrets: inherit 46 | 47 | test: 48 | name: Test 49 | needs: 50 | - prepare-environment 51 | - build-development-image 52 | uses: open-space-collective/open-space-toolkit/.github/workflows/test.yml@main 53 | with: 54 | project_name: ${{ needs.prepare-environment.outputs.project_name }} 55 | project_version: ${{ needs.prepare-environment.outputs.project_version }} 56 | secrets: inherit 57 | 58 | package: 59 | name: Package 60 | needs: 61 | - prepare-environment 62 | - build-development-image 63 | - test 64 | uses: open-space-collective/open-space-toolkit/.github/workflows/build-packages.yml@main 65 | with: 66 | project_name: ${{ needs.prepare-environment.outputs.project_name }} 67 | project_version: ${{ needs.prepare-environment.outputs.project_version }} 68 | secrets: inherit 69 | 70 | release: 71 | name: Release 72 | needs: 73 | - prepare-environment 74 | - build-development-image 75 | - test 76 | - package 77 | uses: open-space-collective/open-space-toolkit/.github/workflows/release.yml@main 78 | with: 79 | project_name: ${{ needs.prepare-environment.outputs.project_name }} 80 | project_version: ${{ needs.prepare-environment.outputs.project_version }} 81 | secrets: inherit 82 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | # Operating Systems 4 | 5 | ## Mac OS 6 | 7 | **/.DS_Store 8 | 9 | # Editors 10 | 11 | ## Visual Studio Code 12 | 13 | .vscode/* 14 | !.vscode/settings.json 15 | !.vscode/tasks.json 16 | !.vscode/launch.json 17 | !.vscode/extensions.json 18 | !.vscode/*.code-snippets 19 | !.vscode/c_cpp_properties.json 20 | 21 | ### Local History for Visual Studio Code 22 | .history/ 23 | 24 | ### Built Visual Studio Code Extensions 25 | *.vsix 26 | 27 | ## Sublime Text 28 | 29 | *.sublime-workspace 30 | *.sublime-project 31 | 32 | # Project 33 | 34 | ## Common 35 | 36 | !.gitignore 37 | !.gitkeep 38 | 39 | ## Binaries 40 | 41 | bin/* 42 | lib/* 43 | build/ 44 | *.so* 45 | *.a 46 | *.exe* 47 | *.rpm* 48 | packages/ 49 | coverage/ 50 | 51 | ## Documentation 52 | 53 | docs/html/ 54 | docs/latex/ 55 | docs/xml/ 56 | docs/_autosummary 57 | docs/_build 58 | docs/_notebooks 59 | docs/cpp_rst 60 | 61 | ## Misc. 62 | 63 | tmp/ 64 | __pycache__ 65 | .ipynb_checkpoints 66 | .open-space-toolkit 67 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/include", 7 | "${workspaceFolder}/test" 8 | ], 9 | "defines": [], 10 | "compilerPath": "/usr/bin/gcc", 11 | "cStandard": "gnu17", 12 | "cppStandard": "gnu++14", 13 | "intelliSenseMode": "linux-gcc-x64", 14 | "configurationProvider": "ms-vscode.cmake-tools" 15 | } 16 | ], 17 | "version": 4 18 | } 19 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "C++: Debug Tests", 5 | "type": "cppdbg", 6 | "request": "launch", 7 | "program": "${workspaceFolder}/bin/open-space-toolkit-simulation.test", 8 | "args": [], 9 | "stopAtEntry": false, 10 | "cwd": "${workspaceFolder}", 11 | "environment": [], 12 | "externalConsole": false, 13 | "MIMode": "gdb", 14 | "miDebuggerPath": "/usr/bin/gdb", 15 | "setupCommands": [ 16 | { 17 | "description": "Enable pretty-printing for gdb", 18 | "text": "-enable-pretty-printing", 19 | "ignoreFailures": true 20 | } 21 | ] 22 | }, 23 | // Not working yet. 24 | // { 25 | // "name": "C/C++: g++ build and debug active file", 26 | // "type": "cppdbg", 27 | // "request": "launch", 28 | // "program": "${fileDirname}/${fileBasenameNoExtension}", 29 | // "args": [], 30 | // "stopAtEntry": false, 31 | // "cwd": "${fileDirname}", 32 | // "environment": [], 33 | // "externalConsole": false, 34 | // "MIMode": "gdb", 35 | // "miDebuggerPath": "/usr/bin/gdb", 36 | // "setupCommands": [ 37 | // { 38 | // "description": "Enable pretty-printing for gdb", 39 | // "text": "-enable-pretty-printing", 40 | // "ignoreFailures": true 41 | // }, 42 | // { 43 | // "description": "Set Disassembly Flavor to Intel", 44 | // "text": "-gdb-set disassembly-flavor intel", 45 | // "ignoreFailures": true 46 | // } 47 | // ], 48 | // "preLaunchTask": "C++: build active file" 49 | // }, 50 | { 51 | "name": "Python: Debug Tests", 52 | "type": "cppdbg", 53 | "request": "launch", 54 | "program": "/usr/local/bin/python3.8", 55 | "args": [ 56 | "-m", 57 | "pytest", 58 | "-svx" 59 | ], 60 | "stopAtEntry": false, 61 | // "cwd": "${workspaceFolder}", 62 | "cwd": "${workspaceFolder}/bindings/python/test", 63 | "environment": [ 64 | { 65 | "name": "PYTHONPATH", 66 | "value": "/usr/local/lib" 67 | } 68 | ], 69 | "externalConsole": false, 70 | "MIMode": "gdb", 71 | "setupCommands": [ 72 | { 73 | "description": "Enable pretty-printing for gdb", 74 | "text": "-enable-pretty-printing", 75 | "ignoreFailures": true 76 | } 77 | ] 78 | }, 79 | ], 80 | "version": "2.0.0" 81 | } 82 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "*.cpp___": "cpp", 4 | "core": "cpp", 5 | "*.tpp": "cpp", 6 | "complex": "cpp" 7 | }, 8 | } 9 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "label": "C++: build active file", 5 | "type": "cppbuild", 6 | "command": "/usr/bin/cpp", 7 | "args": [ 8 | "-I", 9 | "/usr/local/include", 10 | "-I", 11 | "/usr/local/include/eigen3", 12 | "-I", 13 | "${workspaceFolder}/include", 14 | "-I", 15 | "${workspaceFolder}/test", 16 | "-I", 17 | "-fdiagnostics-color=always", 18 | "-g", 19 | "${file}", 20 | "-o", 21 | "${fileDirname}/${fileBasenameNoExtension}" 22 | ], 23 | "options": { 24 | "cwd": "${fileDirname}" 25 | }, 26 | "problemMatcher": [ 27 | "$gcc" 28 | ], 29 | "group": { 30 | "kind": "build", 31 | "isDefault": true 32 | }, 33 | "detail": "Task generated by Debugger." 34 | } 35 | ], 36 | "version": "2.0.0" 37 | } 38 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | *⚠ This document is a work in progress.* 4 | 5 | [TOC] 6 | 7 | ## Introduction {#Introduction} 8 | 9 | *To be completed...* 10 | 11 | ## Guidelines {#Guidelines} 12 | 13 | ### Codebase {#Codebase} 14 | 15 | #### C++ {#C} 16 | 17 | Include order from specific to generic: 18 | 19 | ```cpp 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | ``` 28 | 29 | References: 30 | 31 | - https://stackoverflow.com/questions/2762568/c-c-include-file-order-best-practices 32 | - https://blog.kowalczyk.info/article/qg/order-of-include-headers-in-cc.html 33 | 34 | #### Python {#Python} 35 | 36 | *To be completed...* 37 | 38 | ### Version Control {#Version} 39 | 40 | #### Rules {#Rules} 41 | 42 | *To be completed...* 43 | 44 | #### Commit Messages {#Commit} 45 | 46 | [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/) 47 | 48 | Use active form (`Do something`). 49 | 50 | Prefix commit messages using the following tags: 51 | 52 | - [feature] 53 | - [fix] 54 | - [misc] 55 | 56 | Examples: 57 | 58 | ```txt 59 | [feature] Implement high fidelity orbit propagator 60 | ``` 61 | 62 | ```txt 63 | [fix] Segmentation fault when fetching ephemeris data 64 | ``` 65 | 66 | ## Code of Conduct {#CodeOfConduct} 67 | 68 | *To be completed...* 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Open Space Toolkit ▸ Simulation 2 | 3 | [![Build and Test](https://github.com/open-space-collective/open-space-toolkit-simulation/actions/workflows/build-test.yml/badge.svg?branch=main)](https://github.com/open-space-collective/open-space-toolkit-simulation/actions/workflows/build-test.yml) 4 | [![Code Coverage](https://codecov.io/gh/open-space-collective/open-space-toolkit-simulation/branch/main/graph/badge.svg)](https://codecov.io/gh/open-space-collective/open-space-toolkit-simulation) 5 | [![Documentation](https://img.shields.io/readthedocs/pip/stable.svg)](https://open-space-collective.github.io/open-space-toolkit-simulation) 6 | [![GitHub version](https://badge.fury.io/gh/open-space-collective%2Fopen-space-toolkit-simulation.svg)](https://badge.fury.io/gh/open-space-collective%2Fopen-space-toolkit-simulation) 7 | [![PyPI version](https://badge.fury.io/py/open-space-toolkit-simulation.svg)](https://badge.fury.io/py/open-space-toolkit-simulation) 8 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 9 | 10 | Spacecraft simulation. 11 | 12 | *This library is still in draft state. Do not use!* 13 | 14 | ## Getting Started 15 | 16 | Want to get started? This is the simplest and quickest way: 17 | 18 | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-space-collective/open-space-toolkit/main?urlpath=lab/tree/notebooks) 19 | 20 | *Nothing to download or install! This will automatically start a [JupyterLab](https://jupyterlab.readthedocs.io/en/stable/) environment in your browser with Open Space Toolkit libraries and example notebooks ready to use.* 21 | 22 | ### Alternatives 23 | 24 | #### Docker Images 25 | 26 | [Docker](https://www.docker.com/) must be installed on your system. 27 | 28 | ##### iPython 29 | 30 | The following command will start an [iPython](https://ipython.org/) shell within a container where the OSTk components are already installed: 31 | 32 | ```bash 33 | docker run -it openspacecollective/open-space-toolkit-simulation-development python3.11 -m IPython 34 | ``` 35 | 36 | Once the shell is up and running, playing with it is easy: 37 | 38 | ```py 39 | # TBC... 40 | ``` 41 | 42 | By default, OSTk fetches the ephemeris from JPL, Earth Orientation Parameters (EOP) and leap second count from IERS. 43 | 44 | As a result, when running OSTk for the first time, it may take a minute to fetch all the necessary data. 45 | 46 | *Tip: Use tab for auto-completion!* 47 | 48 | ##### JupyterLab 49 | 50 | The following command will start a [JupyterLab](https://jupyterlab.readthedocs.io/en/stable/) server within a container where the OSTk components are already installed: 51 | 52 | ```bash 53 | docker run --publish=8888:8888 openspacecollective/open-space-toolkit-simulation-jupyter 54 | ``` 55 | 56 | Once the container is running, access [http://localhost:8888/lab](http://localhost:8888/lab) and create a Python 3 Notebook. 57 | 58 | ## Installation 59 | 60 | ### C++ 61 | 62 | The binary packages are hosted using [GitHub Releases](https://github.com/open-space-collective/open-space-toolkit-simulation/releases): 63 | 64 | - Runtime libraries: `open-space-toolkit-simulation-X.Y.Z-1.x86_64-runtime` 65 | - C++ headers: `open-space-toolkit-simulation-X.Y.Z-1.x86_64-devel` 66 | - Python bindings: `open-space-toolkit-simulation-X.Y.Z-1.x86_64-python` 67 | 68 | #### Debian / Ubuntu 69 | 70 | After downloading the relevant `.deb` binary packages, install: 71 | 72 | ```bash 73 | apt install open-space-toolkit-simulation-*.deb 74 | ``` 75 | 76 | ### Python 77 | 78 | Install from [PyPI](https://pypi.org/project/open-space-toolkit-simulation/): 79 | 80 | ```bash 81 | pip install open-space-toolkit-simulation 82 | ``` 83 | 84 | ## Documentation 85 | 86 | Documentation is available here: 87 | 88 | - [C++](https://open-space-collective.github.io/open-space-toolkit-simulation) 89 | - [Python](./bindings/python/docs) 90 | 91 |
92 | Structure 93 |

94 | 95 | The library exhibits the following detailed and descriptive structure: 96 | 97 | ```txt 98 | └── Satellite 99 | ``` 100 | 101 |

102 |
103 | 104 | ## Tutorials 105 | 106 | Tutorials are available here: 107 | 108 | - [C++](./tutorials/cpp) 109 | - [Python](./tutorials/python) 110 | 111 | ## Setup 112 | 113 | ### Development Environment 114 | 115 | Using [Docker](https://www.docker.com) for development is recommended, to simplify the installation of the necessary build tools and dependencies. 116 | Instructions on how to install Docker are available [here](https://docs.docker.com/install/). 117 | 118 | To start the development environment: 119 | 120 | ```bash 121 | make start-development 122 | ``` 123 | 124 | This will: 125 | 126 | 1. Build the `openspacecollective/open-space-toolkit-simulation-development` Docker image. 127 | 2. Create a development environment container with local source files and helper scripts mounted. 128 | 3. Start a `bash` shell from the `./build` working directory. 129 | 130 | If installing Docker is not an option, you can manually install the development tools (GCC, CMake) and all required dependencies, 131 | by following a procedure similar to the one described in the [Development Dockerfile](./docker/development/Dockerfile). 132 | 133 | ### Build 134 | 135 | From the `./build` directory: 136 | 137 | ```bash 138 | cmake .. 139 | make 140 | ``` 141 | 142 | *Tip: `ostk-build` simplifies building from within the development environment.* 143 | 144 | ### Test 145 | 146 | To start a container to build and run the tests: 147 | 148 | ```bash 149 | make test 150 | ``` 151 | 152 | Or to run them manually: 153 | 154 | ```bash 155 | ./bin/open-space-toolkit-simulation.test 156 | ``` 157 | 158 | *Tip: `ostk-test` simplifies running tests from within the development environment.* 159 | 160 | ## Dependencies 161 | 162 | | Name | Version | License | Link | 163 | | ------------- | ------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | 164 | | Pybind11 | 2.12.0 | BSD-3-Clause | [github.com/pybind/pybind11](https://github.com/pybind/pybind11) | 165 | | Core | main | Apache License 2.0 | [github.com/open-space-collective/open-space-toolkit-core](https://github.com/open-space-collective/open-space-toolkit-core) | 166 | | I/O | main | Apache License 2.0 | [github.com/open-space-collective/open-space-toolkit-io](https://github.com/open-space-collective/open-space-toolkit-io) | 167 | | Mathematics | main | Apache License 2.0 | [github.com/open-space-collective/open-space-toolkit-mathematics](https://github.com/open-space-collective/open-space-toolkit-mathematics) | 168 | | Physics | main | Apache License 2.0 | [github.com/open-space-collective/open-space-toolkit-physics](https://github.com/open-space-collective/open-space-toolkit-physics) | 169 | | Astrodynamics | main | Apache License 2.0 | [github.com/open-space-collective/open-space-toolkit-astrodynamics](https://github.com/open-space-collective/open-space-toolkit-astrodynamics) | 170 | 171 | ## Contribution 172 | 173 | Contributions are more than welcome! 174 | 175 | Please read our [contributing guide](CONTRIBUTING.md) to learn about our development process, how to propose fixes and improvements, and how to build and test the code. 176 | 177 | ## Special Thanks 178 | 179 | [![Loft Orbital](https://github.com/open-space-collective/open-space-toolkit/blob/main/assets/thanks/loft_orbital.png)](https://www.loftorbital.com/) 180 | 181 | ## License 182 | 183 | Apache License 2.0 184 | -------------------------------------------------------------------------------- /bindings/python/README.md: -------------------------------------------------------------------------------- 1 | # Open Space Toolkit ▸ Simulation 2 | 3 | Spacecraft simulation. 4 | 5 | [![Build and Test](https://github.com/open-space-collective/open-space-toolkit-simulation/actions/workflows/build-test.yml/badge.svg?branch=main)](https://github.com/open-space-collective/open-space-toolkit-simulation/actions/workflows/build-test.yml) 6 | [![Code Coverage](https://codecov.io/gh/open-space-collective/open-space-toolkit-simulation/branch/main/graph/badge.svg)](https://codecov.io/gh/open-space-collective/open-space-toolkit-simulation) 7 | [![Documentation](https://img.shields.io/readthedocs/pip/stable.svg)](https://open-space-collective.github.io/open-space-toolkit-simulation) 8 | [![GitHub version](https://badge.fury.io/gh/open-space-collective%2Fopen-space-toolkit-simulation.svg)](https://badge.fury.io/gh/open-space-collective%2Fopen-space-toolkit-simulation) 9 | [![PyPI version](https://badge.fury.io/py/open-space-toolkit-simulation.svg)](https://badge.fury.io/py/open-space-toolkit-simulation) 10 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 11 | -------------------------------------------------------------------------------- /bindings/python/docs/Reference.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Open Space Toolkit ▸ Simulation" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "[Simulation ▸ Satellite](./Reference/Satellite.ipynb)" 15 | ] 16 | } 17 | ], 18 | "metadata": { 19 | "kernelspec": { 20 | "display_name": "Python 3", 21 | "language": "python", 22 | "name": "python3" 23 | }, 24 | "language_info": { 25 | "codemirror_mode": { 26 | "name": "ipython", 27 | "version": 3 28 | }, 29 | "file_extension": ".py", 30 | "mimetype": "text/x-python", 31 | "name": "python", 32 | "nbconvert_exporter": "python", 33 | "pygments_lexer": "ipython3", 34 | "version": "3.6.8" 35 | } 36 | }, 37 | "nbformat": 4, 38 | "nbformat_minor": 2 39 | } 40 | -------------------------------------------------------------------------------- /bindings/python/requirements.txt: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | open-space-toolkit-core~=5.0 4 | open-space-toolkit-io~=4.0 5 | open-space-toolkit-mathematics~=4.3 6 | open-space-toolkit-physics~=12.0 7 | open-space-toolkit-astrodynamics~=16.0 8 | -------------------------------------------------------------------------------- /bindings/python/src/OpenSpaceToolkitSimulationPy.cxx: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | PYBIND11_MODULE(OpenSpaceToolkitSimulationPy, m) 18 | { 19 | // Add optional docstring for package OpenSpaceToolkitSimulationPy 20 | m.doc() = "Elementary space systems blocks for Simulation in Open Space Toolkit."; 21 | 22 | // Change attribute __name__ to make OpenSpaceToolkitSimulationPy invisible in import path 23 | m.attr("__name__") = "ostk.simulation"; 24 | 25 | // Package version information 26 | #ifdef VERSION_INFO 27 | m.attr("__version__") = VERSION_INFO; 28 | #else 29 | m.attr("__version__") = "dev"; 30 | #endif 31 | 32 | OpenSpaceToolkitSimulationPy_Utility_ComponentHolder(m); 33 | 34 | OpenSpaceToolkitSimulationPy_Simulator(m); 35 | OpenSpaceToolkitSimulationPy_Entity(m); 36 | OpenSpaceToolkitSimulationPy_Component(m); 37 | OpenSpaceToolkitSimulationPy_Satellite(m); 38 | } 39 | -------------------------------------------------------------------------------- /bindings/python/src/OpenSpaceToolkitSimulationPy/Component.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | inline void OpenSpaceToolkitSimulationPy_Component(pybind11::module& aModule) 9 | { 10 | using namespace pybind11; 11 | 12 | using ostk::core::container::Array; 13 | using ostk::core::type::Shared; 14 | using ostk::core::type::String; 15 | 16 | using ostk::mathematics::geometry::d3::transformation::rotation::Quaternion; 17 | 18 | using ostk::physics::coordinate::Frame; 19 | 20 | using ostk::simulation::Component; 21 | using ostk::simulation::component::Geometry; 22 | using ostk::simulation::component::GeometryConfiguration; 23 | using ostk::simulation::component::State; 24 | using ostk::simulation::ComponentConfiguration; 25 | using ostk::simulation::Entity; 26 | using ostk::simulation::Simulator; 27 | using ostk::simulation::utility::ComponentHolder; 28 | 29 | { 30 | class_> component_class(aModule, "Component"); 31 | 32 | component_class 33 | .def( 34 | init< 35 | const String&, 36 | const String&, 37 | const Component::Type&, 38 | const Array&, 39 | const Array>&, 40 | const Array>&, 41 | const Shared&, 42 | const Shared&, 43 | const Shared&>(), 44 | arg("id"), 45 | arg("name"), 46 | arg("type"), 47 | arg("tags"), 48 | arg("geometries"), 49 | arg("components"), 50 | arg("parent"), 51 | arg("frame"), 52 | arg("simulator") 53 | ) 54 | 55 | .def("__str__", &(shiftToString)) 56 | .def("__repr__", &(shiftToString)) 57 | 58 | .def("is_defined", &Component::isDefined) 59 | 60 | .def("access_frame", &Component::accessFrame) 61 | .def("access_geometry_with_name", &Component::accessGeometryWithName, arg("name")) 62 | .def("access_simulator", &Component::accessSimulator) 63 | 64 | .def("get_type", &Component::getType) 65 | .def("get_tags", &Component::getTags) 66 | .def("get_geometries", &Component::getGeometries) 67 | 68 | .def("set_parent", &Component::setParent, arg("component")) 69 | .def("add_geometry", &Component::addGeometry, arg("geometry")) 70 | .def("add_component", &Component::addComponent, arg("component")) 71 | 72 | .def_static("undefined", &Component::Undefined) 73 | .def_static("configure", &Component::Configure, arg("configuration"), arg("parent_component")) 74 | 75 | .def_static("string_from_type", &Component::StringFromType, arg("type")) 76 | 77 | ; 78 | 79 | enum_(component_class, "Type") 80 | 81 | .value("Undefined", Component::Type::Undefined) 82 | .value("Assembly", Component::Type::Assembly) 83 | .value("Controller", Component::Type::Controller) 84 | .value("Sensor", Component::Type::Sensor) 85 | .value("Actuator", Component::Type::Actuator) 86 | .value("Other", Component::Type::Other); 87 | } 88 | 89 | class_(aModule, "ComponentConfiguration") 90 | 91 | .def( 92 | init< 93 | const String&, 94 | const String&, 95 | const Component::Type&, 96 | const Array&, 97 | const Quaternion&, 98 | const Array&, 99 | const Array&>(), 100 | arg("id"), 101 | arg("name"), 102 | arg("type") = DEFAULT_COMPONENT_TYPE, 103 | arg("tags") = DEFAULT_TAGS, 104 | arg("orientation") = DEFAULT_ORIENTATION, 105 | arg("geometries") = DEFAULT_GEOMETRIES, 106 | arg("components") = DEFAULT_COMPONENTS 107 | ) 108 | 109 | ; 110 | 111 | // Create python submodule 112 | auto component = aModule.def_submodule("component"); 113 | 114 | // Add objects to python submodule 115 | OpenSpaceToolkitSimulationPy_Component_Geometry(component); 116 | OpenSpaceToolkitSimulationPy_Component_State(component); 117 | } 118 | -------------------------------------------------------------------------------- /bindings/python/src/OpenSpaceToolkitSimulationPy/Component/Geometry.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | inline void OpenSpaceToolkitSimulationPy_Component_Geometry(pybind11::module& aModule) 6 | { 7 | using namespace pybind11; 8 | 9 | using ostk::core::container::Array; 10 | using ostk::core::type::Shared; 11 | using ostk::core::type::String; 12 | 13 | using ostk::mathematics::geometry::d3::Object; 14 | using ostk::mathematics::geometry::d3::object::Composite; 15 | 16 | using ostk::physics::coordinate::Frame; 17 | using ObjectGeometry = ostk::physics::environment::object::Geometry; 18 | using ostk::physics::environment::object::Celestial; 19 | 20 | using ostk::simulation::Component; 21 | using ostk::simulation::component::Geometry; 22 | using ostk::simulation::component::GeometryConfiguration; 23 | 24 | class_>(aModule, "Geometry") 25 | 26 | .def( 27 | init&>(), 28 | arg("name"), 29 | arg("composite"), 30 | arg("component") 31 | ) 32 | 33 | .def("__str__", &(shiftToString)) 34 | .def("__repr__", &(shiftToString)) 35 | 36 | .def("is_defined", &Geometry::isDefined) 37 | 38 | .def("access_component", &Geometry::accessComponent) 39 | 40 | .def("get_name", &Geometry::getName) 41 | 42 | .def("intersects", overload_cast(&Geometry::intersects, const_), arg("geometry")) 43 | .def("intersects", overload_cast(&Geometry::intersects, const_), arg("celestial_object")) 44 | .def("contains", overload_cast(&Geometry::contains, const_), arg("geometry")) 45 | .def("contains", overload_cast(&Geometry::contains, const_), arg("geometry")) 46 | .def("access_composite", &Geometry::accessComposite, return_value_policy::reference) 47 | .def("access_frame", &Geometry::accessFrame) 48 | .def("get_geometry_in", &Geometry::getGeometryIn, arg("frame")) 49 | .def( 50 | "intersection_with", 51 | overload_cast(&Geometry::intersectionWith, const_), 52 | arg("geometry") 53 | ) 54 | .def( 55 | "intersection_with", 56 | overload_cast(&Geometry::intersectionWith, const_), 57 | arg("celestial_object") 58 | ) 59 | 60 | .def_static("undefined", &Geometry::Undefined) 61 | .def_static("configure", &Geometry::Configure, arg("configuration"), arg("component")) 62 | 63 | ; 64 | 65 | class_(aModule, "GeometryConfiguration") 66 | 67 | .def(init(), arg("name"), arg("composite")) 68 | 69 | ; 70 | } 71 | -------------------------------------------------------------------------------- /bindings/python/src/OpenSpaceToolkitSimulationPy/Component/State.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | inline void OpenSpaceToolkitSimulationPy_Component_State(pybind11::module& aModule) 6 | { 7 | using namespace pybind11; 8 | 9 | using ostk::simulation::component::State; 10 | 11 | class_ state(aModule, "State"); 12 | 13 | state 14 | .def(init()) 15 | 16 | // .def("__str__", &(shiftToString)) 17 | // .def("__repr__", &(shiftToString)) 18 | 19 | .def("is_defined", &State::isDefined) 20 | 21 | .def("get_status", &State::getStatus) 22 | 23 | .def_static("undefined", &State::Undefined) 24 | 25 | ; 26 | 27 | enum_(state, "Status") 28 | 29 | .value("Undefined", State::Status::Undefined) 30 | .value("Disabled", State::Status::Disabled) 31 | .value("Idle", State::Status::Idle) 32 | .value("Busy", State::Status::Busy) 33 | .value("Error", State::Status::Error) 34 | 35 | ; 36 | } 37 | -------------------------------------------------------------------------------- /bindings/python/src/OpenSpaceToolkitSimulationPy/Entity.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | inline void OpenSpaceToolkitSimulationPy_Entity(pybind11::module& aModule) 6 | { 7 | using namespace pybind11; 8 | 9 | using ostk::core::type::Shared; 10 | 11 | using ostk::simulation::Entity; 12 | 13 | { 14 | class_>(aModule, "Entity") 15 | 16 | .def("is_defined", &Entity::isDefined) 17 | 18 | .def("get_id", &Entity::getId) 19 | .def("get_name", &Entity::getName) 20 | 21 | .def_static("undefined", &Entity::Undefined) 22 | 23 | ; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bindings/python/src/OpenSpaceToolkitSimulationPy/Satellite.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | inline void OpenSpaceToolkitSimulationPy_Satellite(pybind11::module& aModule) 6 | { 7 | using namespace pybind11; 8 | 9 | using ostk::core::container::Array; 10 | using ostk::core::type::Shared; 11 | using ostk::core::type::String; 12 | 13 | using ostk::physics::coordinate::Frame; 14 | 15 | using ostk::astrodynamics::flight::Profile; 16 | 17 | using ostk::simulation::Component; 18 | using ostk::simulation::component::Geometry; 19 | using ostk::simulation::component::GeometryConfiguration; 20 | using ostk::simulation::ComponentConfiguration; 21 | using ostk::simulation::Satellite; 22 | using ostk::simulation::SatelliteConfiguration; 23 | using ostk::simulation::Simulator; 24 | 25 | class_>(aModule, "Satellite") 26 | 27 | .def( 28 | init< 29 | const String&, 30 | const String&, 31 | const Array&, 32 | const Array>&, 33 | const Array>&, 34 | const Shared&, 35 | const Shared&, 36 | const Shared&>(), 37 | arg("id"), 38 | arg("name"), 39 | arg("tags"), 40 | arg("geometries"), 41 | arg("components"), 42 | arg("frame"), 43 | arg("profile"), 44 | arg("simulator") 45 | ) 46 | 47 | .def("is_defined", &Satellite::isDefined) 48 | .def("access_profile", &Satellite::accessProfile) 49 | 50 | .def_static("undefined", &Satellite::Undefined) 51 | .def_static("configure", &Satellite::Configure, arg("configuration"), arg("simulator") = nullptr) 52 | 53 | ; 54 | 55 | class_(aModule, "SatelliteConfiguration") 56 | 57 | .def( 58 | init< 59 | const String&, 60 | const String&, 61 | const Profile&, 62 | const Array&, 63 | const Array&, 64 | const Array&>(), 65 | arg("id"), 66 | arg("name"), 67 | arg("profile"), 68 | arg("components") = DEFAULT_COMPONENTS, 69 | arg("tags") = DEFAULT_TAGS, 70 | arg("geometries") = DEFAULT_GEOMETRIES 71 | ) 72 | 73 | ; 74 | } 75 | -------------------------------------------------------------------------------- /bindings/python/src/OpenSpaceToolkitSimulationPy/Simulator.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | inline void OpenSpaceToolkitSimulationPy_Simulator(pybind11::module& aModule) 6 | { 7 | using namespace pybind11; 8 | 9 | using ostk::core::container::Array; 10 | using ostk::core::type::Shared; 11 | 12 | using ostk::physics::Environment; 13 | 14 | using ostk::simulation::Satellite; 15 | using ostk::simulation::SatelliteConfiguration; 16 | using ostk::simulation::Simulator; 17 | using ostk::simulation::SimulatorConfiguration; 18 | 19 | class_>(aModule, "Simulator") 20 | 21 | .def(init>&>(), arg("environment"), arg("satellites")) 22 | 23 | .def("is_defined", &Simulator::isDefined) 24 | .def("has_satellite_with_name", &Simulator::hasSatelliteWithName, arg("name")) 25 | 26 | .def("access_environment", &Simulator::accessEnvironment) 27 | .def("access_satellite_map", &Simulator::accessSatelliteMap) 28 | .def("access_satellite_with_name", &Simulator::accessSatelliteWithName, arg("name")) 29 | 30 | .def("get_instant", &Simulator::getInstant) 31 | 32 | .def("set_instant", &Simulator::setInstant, arg("instant")) 33 | .def("step_forward", &Simulator::stepForward, arg("duration")) 34 | .def("add_satellite", &Simulator::addSatellite, arg("satellite")) 35 | 36 | .def_static("undefined", &Simulator::Undefined) 37 | .def_static("configure", &Simulator::Configure, arg("configuration")) 38 | 39 | ; 40 | 41 | class_(aModule, "SimulatorConfiguration") 42 | 43 | .def( 44 | init&>(), 45 | arg("environment"), 46 | arg("satellites") = DEFAULT_SATELLITES 47 | ) 48 | 49 | ; 50 | } 51 | -------------------------------------------------------------------------------- /bindings/python/src/OpenSpaceToolkitSimulationPy/Utility/ArrayCasting.hpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace pybind11 9 | { 10 | namespace detail 11 | { 12 | 13 | using ostk::core::container::Array; 14 | 15 | template 16 | struct type_caster> : list_caster, T> 17 | { 18 | }; 19 | 20 | } // namespace detail 21 | } // namespace pybind11 22 | -------------------------------------------------------------------------------- /bindings/python/src/OpenSpaceToolkitSimulationPy/Utility/ComponentHolder.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | inline void OpenSpaceToolkitSimulationPy_Utility_ComponentHolder(pybind11::module& aModule) 6 | { 7 | using namespace pybind11; 8 | 9 | using ostk::core::type::Shared; 10 | 11 | using ostk::simulation::utility::ComponentHolder; 12 | 13 | class_>(aModule, "ComponentHolder") 14 | 15 | .def("has_component_with_id", &ComponentHolder::hasComponentWithId) 16 | .def("has_component_with_name", &ComponentHolder::hasComponentWithName) 17 | .def("has_component_at", &ComponentHolder::hasComponentAt) 18 | 19 | .def("access_components", &ComponentHolder::accessComponents) 20 | .def("access_component_with_id", &ComponentHolder::accessComponentWithId) 21 | .def("access_component_with_name", &ComponentHolder::accessComponentWithName) 22 | .def("access_components_with_tag", &ComponentHolder::accessComponentsWithTag) 23 | .def("access_component_at", &ComponentHolder::accessComponentAt) 24 | 25 | .def("add_component", &ComponentHolder::addComponent) 26 | 27 | ; 28 | } 29 | -------------------------------------------------------------------------------- /bindings/python/src/OpenSpaceToolkitSimulationPy/Utility/ShiftToString.hpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | /// @brief Shift to String Template Function 6 | /// 7 | /// Template function used for __str__ and __repr__ 8 | /// methods on classes exposed in python. 9 | 10 | template 11 | std::string shiftToString(const T& aClass) 12 | { 13 | std::ostringstream out; 14 | out << aClass; 15 | return out.str(); 16 | } 17 | -------------------------------------------------------------------------------- /bindings/python/test/__init__.py: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | -------------------------------------------------------------------------------- /bindings/python/test/test_import.py: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | 4 | class TestImport: 5 | def test_import(self): 6 | from ostk.simulation import Satellite 7 | -------------------------------------------------------------------------------- /bindings/python/test/test_satellite.py: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | import pytest 4 | 5 | from datetime import datetime 6 | 7 | from ostk.physics import Environment 8 | from ostk.physics.unit import Length 9 | from ostk.physics.time import Instant 10 | from ostk.physics.time import Scale 11 | from ostk.physics.time import Time 12 | 13 | from ostk.astrodynamics.trajectory import Orbit 14 | from ostk.astrodynamics.flight import Profile 15 | 16 | from ostk.simulation import Satellite 17 | from ostk.simulation import SatelliteConfiguration 18 | 19 | 20 | @pytest.fixture 21 | def environment() -> Environment: 22 | return Environment.default() 23 | 24 | 25 | @pytest.fixture 26 | def orbit(environment: Environment) -> Orbit: 27 | return Orbit.sun_synchronous( 28 | epoch=Instant.date_time(datetime(2020, 1, 1, 0, 0, 0), Scale.UTC), 29 | altitude=Length.kilometers(500.0), 30 | local_time_at_descending_node=Time(14, 0, 0), 31 | celestial_object=environment.access_celestial_object_with_name("Earth"), 32 | ) 33 | 34 | 35 | @pytest.fixture 36 | def satellite_configuration(orbit: Orbit) -> SatelliteConfiguration: 37 | return SatelliteConfiguration( 38 | id="9ea22c07-6977-48a7-8f68-dff758971d57", 39 | name="LoftSat-1", 40 | profile=Profile.local_orbital_frame_pointing( 41 | orbit=orbit, 42 | orbital_frame_type=Orbit.FrameType.VVLH, 43 | ), 44 | ) 45 | 46 | 47 | @pytest.fixture 48 | def satellite(satellite_configuration: SatelliteConfiguration) -> Satellite: 49 | return Satellite.configure(configuration=satellite_configuration) 50 | 51 | 52 | class TestSatellite: 53 | def test_configure(self, satellite: Satellite): 54 | assert satellite is not None 55 | 56 | def test_is_defined(self, satellite: Satellite): 57 | assert satellite.is_defined() 58 | 59 | def test_access_profile(self, satellite: Satellite): 60 | assert satellite.access_profile().is_defined() 61 | -------------------------------------------------------------------------------- /bindings/python/test/test_simulator.py: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | import pytest 4 | 5 | from datetime import datetime 6 | 7 | from ostk.mathematics.geometry.d2.object import Point as Point2d 8 | from ostk.mathematics.geometry.d2.object import Polygon as Polygon2d 9 | from ostk.mathematics.geometry.d3.object import Point 10 | from ostk.mathematics.geometry.d3.object import Polygon 11 | from ostk.mathematics.geometry.d3.object import Pyramid 12 | from ostk.mathematics.geometry.d3.object import Composite 13 | from ostk.mathematics.geometry.d3.transformation.rotation import Quaternion 14 | 15 | from ostk.physics import Environment 16 | from ostk.physics.unit import Length 17 | from ostk.physics.time import Instant 18 | from ostk.physics.time import Scale 19 | from ostk.physics.time import Time 20 | from ostk.physics.time import Duration 21 | from ostk.physics.coordinate import Frame 22 | 23 | from ostk.astrodynamics.trajectory import Orbit 24 | from ostk.astrodynamics.flight import Profile 25 | 26 | from ostk.simulation import Simulator 27 | from ostk.simulation import SimulatorConfiguration 28 | from ostk.simulation import Satellite 29 | from ostk.simulation import SatelliteConfiguration 30 | from ostk.simulation import Component 31 | from ostk.simulation import ComponentConfiguration 32 | from ostk.simulation.component import Geometry 33 | from ostk.simulation.component import GeometryConfiguration 34 | 35 | 36 | @pytest.fixture 37 | def environment() -> Environment: 38 | return Environment.default() 39 | 40 | 41 | @pytest.fixture 42 | def orbit(environment: Environment) -> Orbit: 43 | return Orbit.sun_synchronous( 44 | epoch=Instant.date_time(datetime(2020, 1, 1, 0, 0, 0), Scale.UTC), 45 | altitude=Length.kilometers(500.0), 46 | local_time_at_descending_node=Time(14, 0, 0), 47 | celestial_object=environment.access_celestial_object_with_name("Earth"), 48 | ) 49 | 50 | 51 | @pytest.fixture 52 | def satellite_name() -> str: 53 | return "LoftSat-1" 54 | 55 | 56 | @pytest.fixture 57 | def satellite_configuration( 58 | satellite_name: str, 59 | orbit: Orbit, 60 | ) -> SatelliteConfiguration: 61 | return SatelliteConfiguration( 62 | id="9ea22c07-6977-48a7-8f68-dff758971d57", 63 | name=satellite_name, 64 | tags=["a", "b"], 65 | profile=Profile.local_orbital_frame_pointing( 66 | orbit=orbit, 67 | orbital_frame_type=Orbit.FrameType.VVLH, 68 | ), 69 | components=[ 70 | ComponentConfiguration( 71 | id="dc261118-dad7-476d-ab6c-fdfef12f20fd", 72 | name="Camera", 73 | type=Component.Type.Sensor, 74 | tags=["c", "d"], 75 | orientation=Quaternion.unit(), 76 | geometries=[ 77 | GeometryConfiguration( 78 | name="FOV", 79 | composite=Composite( 80 | Pyramid( 81 | base=Polygon( 82 | Polygon2d( 83 | [ 84 | Point2d(-0.1, -1.0), 85 | Point2d(+0.1, -1.0), 86 | Point2d(+0.1, +1.0), 87 | Point2d(-0.1, +1.0), 88 | ] 89 | ), 90 | Point(0.0, 0.0, 1.0), 91 | (1.0, 0.0, 0.0), 92 | (0.0, 1.0, 0.0), 93 | ), 94 | apex=Point(0.0, 0.0, 0.0), 95 | ), 96 | ), 97 | ), 98 | ], 99 | ), 100 | ], 101 | ) 102 | 103 | 104 | @pytest.fixture 105 | def simulator( 106 | environment: Environment, 107 | satellite_configuration: SatelliteConfiguration, 108 | ) -> Simulator: 109 | simulator = Simulator.configure( 110 | configuration=SimulatorConfiguration( 111 | environment=environment, 112 | satellites=[satellite_configuration], 113 | ), 114 | ) 115 | return simulator 116 | 117 | 118 | @pytest.fixture 119 | def instant() -> Instant: 120 | return Instant.date_time(datetime(2020, 1, 1, 0, 0, 0), Scale.UTC) 121 | 122 | 123 | class TestSimulator: 124 | def test_is_defined(self, simulator: Simulator): 125 | assert simulator.is_defined() 126 | 127 | def test_access_environment(self, simulator: Simulator): 128 | assert simulator.access_environment() is not None 129 | 130 | def test_access_satellite_map(self, simulator: Simulator): 131 | assert simulator.access_satellite_map() is not None 132 | 133 | def test_access_satellite_with_name( 134 | self, 135 | simulator: Simulator, 136 | satellite_name: str, 137 | ): 138 | assert simulator.access_satellite_with_name(satellite_name) is not None 139 | 140 | def test_get_instant(self, simulator: Simulator): 141 | assert simulator.get_instant() is not None 142 | 143 | def test_set_instant(self, simulator: Simulator): 144 | instant: Instant = Instant.date_time(datetime(2022, 1, 1, 0, 0, 0), Scale.UTC) 145 | simulator.set_instant(instant) 146 | 147 | assert simulator.get_instant() == instant 148 | 149 | def test_step_forward(self, simulator: Simulator): 150 | initial_instant: Instant = simulator.get_instant() 151 | 152 | simulator.step_forward(Duration.seconds(10.0)) 153 | 154 | assert simulator.get_instant() > initial_instant 155 | 156 | def test_add_satellite( 157 | self, 158 | environment: Environment, 159 | satellite_configuration: SatelliteConfiguration, 160 | ): 161 | simulator: Simulator = Simulator.configure( 162 | SimulatorConfiguration(environment, []) 163 | ) 164 | satellite: Satellite = Satellite.configure(satellite_configuration) 165 | 166 | assert len(simulator.access_satellite_map()) == 0 167 | 168 | simulator.add_satellite(satellite) 169 | 170 | assert satellite in simulator.access_satellite_map().values() 171 | 172 | def test_undefined(self): 173 | simulator: Simulator = Simulator.undefined() 174 | 175 | assert not simulator.is_defined() 176 | 177 | def test_configure(self, environment: Environment): 178 | configuration: SimulatorConfiguration = SimulatorConfiguration(environment, []) 179 | simulator: Simulator = Simulator.configure(configuration) 180 | 181 | assert simulator.is_defined() 182 | 183 | def test_end_to_end(self, simulator: Simulator): 184 | camera: Component = simulator.access_satellite_with_name( 185 | "LoftSat-1" 186 | ).access_component_with_name("Camera") 187 | camera_geometry: Geometry = camera.access_geometry_with_name("FOV") 188 | earth = simulator.access_environment().access_celestial_object_with_name( 189 | "Earth" 190 | ) 191 | 192 | assert camera_geometry.intersects(earth) is True 193 | 194 | assert camera_geometry.access_composite() is not None 195 | assert camera_geometry.access_frame() is not None 196 | assert camera_geometry.get_geometry_in(Frame.GCRF()) is not None 197 | assert camera_geometry.get_geometry_in(Frame.ITRF()) is not None 198 | 199 | assert ( 200 | camera_geometry.intersection_with(earth) 201 | .access_composite() 202 | .get_object_count() 203 | == 2 204 | ) 205 | assert ( 206 | camera_geometry.intersection_with(earth) 207 | .access_composite() 208 | .access_object_at(0) 209 | .is_line_string() 210 | is True 211 | ) 212 | assert ( 213 | camera_geometry.intersection_with(earth) 214 | .access_composite() 215 | .access_object_at(1) 216 | .is_line_string() 217 | is True 218 | ) 219 | -------------------------------------------------------------------------------- /bindings/python/thirdparty/boost_numpy_eigen/eigen_numpy.h: -------------------------------------------------------------------------------- 1 | #ifndef _EIGEN_NUMPY_H_ 2 | #define _EIGEN_NUMPY_H 3 | 4 | void SetupEigenConverters(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /bindings/python/tools/cmake/DocumentationTargets.cmake: -------------------------------------------------------------------------------- 1 | # Michael Aaron Safyan (michaelsafyan@gmail.com). Copyright (C) 2009. Simplified BSD License. 2 | 3 | # 4 | # This CMake package creates a Doxygen documentation target. 5 | # 6 | 7 | FIND_PACKAGE (Doxygen) 8 | IF (DOXYGEN_FOUND) 9 | IF (EXISTS ${PROJECT_SOURCE_DIR}/Doxyfile) 10 | ADD_CUSTOM_TARGET( 11 | doxygen 12 | ${DOXYGEN_EXECUTABLE} Doxyfile 13 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 14 | COMMENT "Generating doxygen project documentation." VERBATIM 15 | ) 16 | ADD_CUSTOM_TARGET( 17 | documentation 18 | ${DOXYGEN_EXECUTABLE} Doxyfile 19 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 20 | COMMENT "Generating doxygen project documentation." VERBATIM 21 | ) 22 | ADD_CUSTOM_TARGET( 23 | docs 24 | ${DOXYGEN_EXECUTABLE} Doxyfile 25 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 26 | COMMENT "Generating doxygen project documentation." VERBATIM 27 | ) 28 | ELSE (EXISTS ${PROJECT_SOURCE_DIR}/Doxyfile) 29 | ADD_CUSTOM_TARGET(doxygen COMMENT "Doxyfile not found. Please generate a doxygen configuration file to use this target." VERBATIM) 30 | ADD_CUSTOM_TARGET(documentation COMMENT "Doxyfile not found. Please generate a doxygen configuration file to use this target." VERBATIM) 31 | ADD_CUSTOM_TARGET(docs COMMENT "Doxyfile not found. Please generate a doxygen configuration file to use this target." VERBATIM) 32 | ENDIF (EXISTS ${PROJECT_SOURCE_DIR}/Doxyfile) 33 | ELSE (DOXYGEN_FOUND) 34 | ADD_CUSTOM_TARGET(doxygen COMMENT "Doxygen not found. Please install doxygen to use this target." VERBATIM) 35 | ADD_CUSTOM_TARGET(documentation COMMENT "Doxygen not found. Please install doxygen to use this target." VERBATIM) 36 | ADD_CUSTOM_TARGET(docs COMMENT "Doxygen not found. Please install doxygen to use this target." VERBATIM) 37 | ENDIF (DOXYGEN_FOUND) 38 | -------------------------------------------------------------------------------- /bindings/python/tools/cmake/FindBoostNumPy.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find BoostNumPy 2 | 3 | # BOOST_NUMPY_FOUND - System has BoostNumPy 4 | # BOOST_NUMPY_INCLUDE_DIRS - The BoostNumPy include directories 5 | # BOOST_NUMPY_LIBRARIES - The libraries needed to use BoostNumPy 6 | # BOOST_NUMPY_DEFINITIONS - Compiler switches required for using BoostNumPy 7 | 8 | SET (BOOST_NUMPY_ROOT_DIR ${BOOST_NUMPY_ROOT_DIR} "/usr/local") 9 | 10 | FIND_PATH (BOOST_NUMPY_INCLUDE_DIR "boost/numpy.hpp" PATHS ${BOOST_NUMPY_ROOT_DIR} PATH_SUFFIXES "include" NO_DEFAULT_PATH) 11 | 12 | FIND_LIBRARY (BOOST_NUMPY_LIBRARY NAMES "libboost_numpy.a" PATHS ${BOOST_NUMPY_ROOT_DIR} PATH_SUFFIXES "lib64" NO_DEFAULT_PATH) 13 | 14 | SET (BOOST_NUMPY_INCLUDE_DIRS ${BOOST_NUMPY_INCLUDE_DIR}) 15 | SET (BOOST_NUMPY_LIBRARIES ${BOOST_NUMPY_LIBRARY}) 16 | 17 | # MESSAGE (STATUS "BOOST_NUMPY_ROOT_DIR = ${BOOST_NUMPY_ROOT_DIR}") 18 | # MESSAGE (STATUS "BOOST_NUMPY_INCLUDE_DIRS = ${BOOST_NUMPY_INCLUDE_DIRS}") 19 | # MESSAGE (STATUS "BOOST_NUMPY_LIBRARIES = ${BOOST_NUMPY_LIBRARIES}") 20 | 21 | INCLUDE (FindPackageHandleStandardArgs) 22 | FIND_PACKAGE_HANDLE_STANDARD_ARGS (BOOST_NUMPY DEFAULT_MSG BOOST_NUMPY_LIBRARY BOOST_NUMPY_INCLUDE_DIR) 23 | 24 | MARK_AS_ADVANCED (BOOST_NUMPY_INCLUDE_DIR BOOST_NUMPY_LIBRARY) 25 | -------------------------------------------------------------------------------- /bindings/python/tools/cmake/FindEigen3.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Eigen3 lib 2 | # 3 | # This module supports requiring a minimum version, e.g. you can do 4 | # find_package(Eigen3 3.1.2) 5 | # to require version 3.1.2 or newer of Eigen3. 6 | # 7 | # Once done this will define 8 | # 9 | # EIGEN3_FOUND - system has eigen lib with correct version 10 | # EIGEN3_INCLUDE_DIR - the eigen include directory 11 | # EIGEN3_VERSION - eigen version 12 | 13 | # Copyright (c) 2006, 2007 Montel Laurent, 14 | # Copyright (c) 2008, 2009 Gael Guennebaud, 15 | # Copyright (c) 2009 Benoit Jacob 16 | # Redistribution and use is allowed according to the terms of the 2-clause BSD license. 17 | 18 | if(NOT Eigen3_FIND_VERSION) 19 | if(NOT Eigen3_FIND_VERSION_MAJOR) 20 | set(Eigen3_FIND_VERSION_MAJOR 2) 21 | endif(NOT Eigen3_FIND_VERSION_MAJOR) 22 | if(NOT Eigen3_FIND_VERSION_MINOR) 23 | set(Eigen3_FIND_VERSION_MINOR 91) 24 | endif(NOT Eigen3_FIND_VERSION_MINOR) 25 | if(NOT Eigen3_FIND_VERSION_PATCH) 26 | set(Eigen3_FIND_VERSION_PATCH 0) 27 | endif(NOT Eigen3_FIND_VERSION_PATCH) 28 | 29 | set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}") 30 | endif(NOT Eigen3_FIND_VERSION) 31 | 32 | macro(_eigen3_check_version) 33 | file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header) 34 | 35 | string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}") 36 | set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}") 37 | string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}") 38 | set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}") 39 | string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}") 40 | set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}") 41 | 42 | set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION}) 43 | if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) 44 | set(EIGEN3_VERSION_OK FALSE) 45 | else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) 46 | set(EIGEN3_VERSION_OK TRUE) 47 | endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) 48 | 49 | if(NOT EIGEN3_VERSION_OK) 50 | 51 | message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, " 52 | "but at least version ${Eigen3_FIND_VERSION} is required") 53 | endif(NOT EIGEN3_VERSION_OK) 54 | endmacro(_eigen3_check_version) 55 | 56 | if (EIGEN3_INCLUDE_DIR) 57 | 58 | # in cache already 59 | _eigen3_check_version() 60 | set(EIGEN3_FOUND ${EIGEN3_VERSION_OK}) 61 | 62 | else (EIGEN3_INCLUDE_DIR) 63 | 64 | find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library 65 | PATHS 66 | ${CMAKE_INSTALL_PREFIX}/include 67 | ${KDE4_INCLUDE_DIR} 68 | PATH_SUFFIXES eigen3 eigen 69 | ) 70 | 71 | if(EIGEN3_INCLUDE_DIR) 72 | _eigen3_check_version() 73 | endif(EIGEN3_INCLUDE_DIR) 74 | 75 | include(FindPackageHandleStandardArgs) 76 | find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK) 77 | 78 | mark_as_advanced(EIGEN3_INCLUDE_DIR) 79 | 80 | endif(EIGEN3_INCLUDE_DIR) 81 | 82 | -------------------------------------------------------------------------------- /bindings/python/tools/cmake/GetGitRevisionDescription.cmake: -------------------------------------------------------------------------------- 1 | # - Returns a version string from Git 2 | # 3 | # These functions force a re-configure on each git commit so that you can 4 | # trust the values of the variables in your build system. 5 | # 6 | # get_git_head_revision( [ ...]) 7 | # 8 | # Returns the refspec and sha hash of the current head revision 9 | # 10 | # git_describe( [ ...]) 11 | # 12 | # Returns the results of git describe on the source tree, and adjusting 13 | # the output so that it tests false if an error occurs. 14 | # 15 | # git_get_exact_tag( [ ...]) 16 | # 17 | # Returns the results of git describe --exact-match on the source tree, 18 | # and adjusting the output so that it tests false if there was no exact 19 | # matching tag. 20 | # 21 | # Requires CMake 2.6 or newer (uses the 'function' command) 22 | # 23 | # Original Author: 24 | # 2009-2010 Ryan Pavlik 25 | # http://academic.cleardefinition.com 26 | # Iowa State University HCI Graduate Program/VRAC 27 | # 28 | # Copyright Iowa State University 2009-2010. 29 | # Distributed under the Boost Software License, Version 1.0. 30 | # (See accompanying file LICENSE_1_0.txt or copy at 31 | # http://www.boost.org/LICENSE_1_0.txt) 32 | 33 | if(__get_git_revision_description) 34 | return() 35 | endif() 36 | set(__get_git_revision_description YES) 37 | 38 | # We must run the following at "include" time, not at function call time, 39 | # to find the path to this module rather than the path to a calling list file 40 | get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) 41 | 42 | function(get_git_head_revision _refspecvar _hashvar) 43 | set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 44 | set(GIT_DIR "${GIT_PARENT_DIR}/.git") 45 | while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories 46 | set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") 47 | get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) 48 | if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) 49 | # We have reached the root directory, we are not in git 50 | set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) 51 | set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) 52 | return() 53 | endif() 54 | set(GIT_DIR "${GIT_PARENT_DIR}/.git") 55 | endwhile() 56 | # check if this is a submodule 57 | if(NOT IS_DIRECTORY ${GIT_DIR}) 58 | file(READ ${GIT_DIR} submodule) 59 | string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) 60 | get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) 61 | get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) 62 | endif() 63 | set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") 64 | if(NOT EXISTS "${GIT_DATA}") 65 | file(MAKE_DIRECTORY "${GIT_DATA}") 66 | endif() 67 | 68 | if(NOT EXISTS "${GIT_DIR}/HEAD") 69 | return() 70 | endif() 71 | set(HEAD_FILE "${GIT_DATA}/HEAD") 72 | configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) 73 | 74 | configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" 75 | "${GIT_DATA}/grabRef.cmake" 76 | @ONLY) 77 | include("${GIT_DATA}/grabRef.cmake") 78 | 79 | set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) 80 | set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) 81 | endfunction() 82 | 83 | function(git_describe _var) 84 | if(NOT GIT_FOUND) 85 | find_package(Git QUIET) 86 | endif() 87 | get_git_head_revision(refspec hash) 88 | if(NOT GIT_FOUND) 89 | set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) 90 | return() 91 | endif() 92 | if(NOT hash) 93 | set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) 94 | return() 95 | endif() 96 | 97 | # TODO sanitize 98 | #if((${ARGN}" MATCHES "&&") OR 99 | # (ARGN MATCHES "||") OR 100 | # (ARGN MATCHES "\\;")) 101 | # message("Please report the following error to the project!") 102 | # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") 103 | #endif() 104 | 105 | #message(STATUS "Arguments to execute_process: ${ARGN}") 106 | 107 | execute_process(COMMAND 108 | "${GIT_EXECUTABLE}" 109 | describe 110 | ${hash} 111 | ${ARGN} 112 | WORKING_DIRECTORY 113 | "${CMAKE_CURRENT_SOURCE_DIR}" 114 | RESULT_VARIABLE 115 | res 116 | OUTPUT_VARIABLE 117 | out 118 | ERROR_QUIET 119 | OUTPUT_STRIP_TRAILING_WHITESPACE) 120 | if(NOT res EQUAL 0) 121 | set(out "${out}-${res}-NOTFOUND") 122 | endif() 123 | 124 | set(${_var} "${out}" PARENT_SCOPE) 125 | endfunction() 126 | 127 | function(git_get_exact_tag _var) 128 | git_describe(out --exact-match ${ARGN}) 129 | set(${_var} "${out}" PARENT_SCOPE) 130 | endfunction() 131 | -------------------------------------------------------------------------------- /bindings/python/tools/cmake/GetGitRevisionDescription.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Internal file for GetGitRevisionDescription.cmake 3 | # 4 | # Requires CMake 2.6 or newer (uses the 'function' command) 5 | # 6 | # Original Author: 7 | # 2009-2010 Ryan Pavlik 8 | # http://academic.cleardefinition.com 9 | # Iowa State University HCI Graduate Program/VRAC 10 | # 11 | # Copyright Iowa State University 2009-2010. 12 | # Distributed under the Boost Software License, Version 1.0. 13 | # (See accompanying file LICENSE_1_0.txt or copy at 14 | # http://www.boost.org/LICENSE_1_0.txt) 15 | 16 | set(HEAD_HASH) 17 | 18 | file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) 19 | 20 | string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) 21 | if(HEAD_CONTENTS MATCHES "ref") 22 | # named branch 23 | string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") 24 | if(EXISTS "@GIT_DIR@/${HEAD_REF}") 25 | configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 26 | else() 27 | configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) 28 | file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) 29 | if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") 30 | set(HEAD_HASH "${CMAKE_MATCH_1}") 31 | endif() 32 | endif() 33 | else() 34 | # detached HEAD 35 | configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) 36 | endif() 37 | 38 | if(NOT HEAD_HASH) 39 | file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) 40 | string(STRIP "${HEAD_HASH}" HEAD_HASH) 41 | endif() 42 | -------------------------------------------------------------------------------- /bindings/python/tools/cmake/UninstallTarget.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 3 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | 5 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 9 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 10 | exec_program( 11 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 12 | OUTPUT_VARIABLE rm_out 13 | RETURN_VALUE rm_retval 14 | ) 15 | if(NOT "${rm_retval}" STREQUAL 0) 16 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 17 | endif(NOT "${rm_retval}" STREQUAL 0) 18 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 19 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 20 | endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 21 | endforeach(file) -------------------------------------------------------------------------------- /bindings/python/tools/python/ostk/__init__.py: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | -------------------------------------------------------------------------------- /bindings/python/tools/python/ostk/simulation/__init__.py: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | from ostk.astrodynamics import * 4 | 5 | from .OpenSpaceToolkitSimulationPy import * 6 | -------------------------------------------------------------------------------- /bindings/python/tools/python/pyproject.toml.in: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | [build-system] 4 | requires = ["setuptools"] 5 | build-backend = "setuptools.build_meta" 6 | -------------------------------------------------------------------------------- /bindings/python/tools/python/setup.cfg.in: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | [bdist_wheel] 4 | python_tag=py${EXTENSION} 5 | bdist_dir=./dist${EXTENSION} 6 | plat_name=${PLATFORM} 7 | 8 | [metadata] 9 | name = open-space-toolkit-simulation 10 | version = ${PROJECT_VERSION_STRING} 11 | author = Open Space Collective 12 | author_email = contact@open-space-collective.org 13 | description = Spacecraft simulation. 14 | keywords = open-space-collective, open-space-toolkit simulation 15 | long_description = file: README.md 16 | long_description_content_type = text/markdown 17 | license = Apache License 2.0 18 | classifiers = 19 | Development Status :: 3 - Alpha 20 | Programming Language :: Python :: 3 21 | License :: OSI Approved :: Apache Software License 22 | Operating System :: POSIX :: Linux 23 | 24 | [options] 25 | zip_safe = True 26 | include_package_data = True 27 | install_requires = file: requirements.txt 28 | 29 | [options.package_data] 30 | ostk.simulation=${SHARED_LIBRARY_TARGET}.${PROJECT_VERSION_MAJOR}, ${LIBRARY_TARGET}.*${EXTENSION}*.so 31 | *=*/data/* 32 | -------------------------------------------------------------------------------- /docker/jupyter/Dockerfile: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | ARG JUPYTER_NOTEBOOK_IMAGE_REPOSITORY=jupyter/scipy-notebook:x86_64-python-3.11.3 4 | 5 | FROM ${JUPYTER_NOTEBOOK_IMAGE_REPOSITORY} 6 | 7 | LABEL maintainer="lucas@loftorbital.com" 8 | 9 | ENV JUPYTER_ENABLE_LAB="yes" 10 | 11 | # Set user to root 12 | 13 | USER root 14 | 15 | # Install Python utilities 16 | 17 | RUN apt-get update \ 18 | && apt-get install -y curl git-lfs \ 19 | && rm -rf /var/lib/apt/lists/* 20 | 21 | RUN pip install --quiet "numpy~=2.0" "pandas" "plotly" "ipywidgets>=7.6" "ipympl>=0.9.0" 22 | 23 | # Install JupyterLab extensions 24 | 25 | RUN jupyter labextension install --no-build \ 26 | @jupyterlab/shortcuts-extension 27 | 28 | COPY ./shortcuts-extension /home/jovyan/.jupyter/lab/user-settings/@jupyterlab/shortcuts-extension 29 | 30 | RUN chown -R ${NB_UID}:${NB_GID} /home/jovyan 31 | 32 | # Install OSTk data 33 | 34 | ARG OSTK_DATA_LOCAL_CACHE="/var/cache/open-space-toolkit-data" 35 | ENV OSTK_DATA_LOCAL_CACHE="${OSTK_DATA_LOCAL_CACHE}" 36 | ENV OSTK_PHYSICS_DATA_LOCAL_REPOSITORY="${OSTK_DATA_LOCAL_CACHE}/data" 37 | 38 | RUN git clone --branch v1 --single-branch --depth=1 https://github.com/open-space-collective/open-space-toolkit-data.git ${OSTK_DATA_LOCAL_CACHE} && chmod -R g+w ${OSTK_DATA_LOCAL_CACHE} 39 | 40 | RUN chown -R ${NB_UID}:${NB_GID} ${OSTK_DATA_LOCAL_CACHE} 41 | 42 | # Install Open Space Toolkit 43 | 44 | RUN pip install open-space-toolkit-simulation 45 | 46 | # Restore user 47 | 48 | USER ${NB_UID} 49 | 50 | # Disable token 51 | 52 | CMD ["start-notebook.sh", "--NotebookApp.token=''"] 53 | -------------------------------------------------------------------------------- /docker/jupyter/shortcuts-extension/plugin.jupyterlab-settings: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "editmenu:clear-all": 4 | { 5 | "command": "editmenu:clear-all", 6 | "keys": 7 | [ 8 | "Ctrl Shift Delete" 9 | ], 10 | "selector": "[data-jp-undoer]", 11 | "title": "Clear All", 12 | "category": "Editing" 13 | }, 14 | 15 | "kernelmenu:restart-and-clear": 16 | { 17 | "command": "kernelmenu:restart-and-clear", 18 | "keys": 19 | [ 20 | "1", 21 | "1" 22 | ], 23 | "selector": "[data-jp-kernel-user]:focus", 24 | "title": "Restart Kernel and Clear", 25 | "category": "Kernel Operations" 26 | }, 27 | 28 | "notebook:run-all-above": 29 | { 30 | "command": "notebook:run-all-above", 31 | "keys": 32 | [ 33 | "Ctrl Alt Enter" 34 | ], 35 | "selector": "[data-jp-undoer]", 36 | "title": "Clear All", 37 | "category": "Editing" 38 | }, 39 | 40 | "notebook:run-all-below": 41 | { 42 | "command": "notebook:run-all-below", 43 | "keys": 44 | [ 45 | "Ctrl Shift Enter" 46 | ], 47 | "selector": "[data-jp-undoer]", 48 | "title": "Clear All", 49 | "category": "Editing" 50 | }, 51 | 52 | "notebook:move-cell-up": 53 | { 54 | "selector": ".jp-Notebook:focus", 55 | "command": "notebook:move-cell-up", 56 | "keys": 57 | [ 58 | "Ctrl ArrowUp" 59 | ] 60 | }, 61 | 62 | "notebook:move-cell-down": 63 | { 64 | "selector": ".jp-Notebook:focus", 65 | "command": "notebook:move-cell-down", 66 | "keys": 67 | [ 68 | "Ctrl ArrowDown" 69 | ] 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /docker/release/Dockerfile: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | ARG VERSION 4 | 5 | ARG PYTHON_TEST_VERSION="3.11" 6 | ARG PYTHON_TEST_VERSION_WITHOUT_DOT="311" 7 | 8 | FROM openspacecollective/open-space-toolkit-simulation-development:${VERSION} AS cpp-builder 9 | 10 | RUN mkdir -p /app/bin /app/build /app/lib 11 | 12 | WORKDIR /app/build 13 | 14 | COPY ./bindings /app/bindings 15 | COPY ./docs /app/docs 16 | COPY ./include /app/include 17 | COPY ./share /app/share 18 | COPY ./src /app/src 19 | COPY ./test /app/test 20 | COPY ./thirdparty /app/thirdparty 21 | COPY ./tools /app/tools 22 | COPY CMakeLists.txt /app/CMakeLists.txt 23 | COPY LICENSE /app/LICENSE 24 | COPY README.md /app/README.md 25 | COPY .git /app/.git 26 | 27 | RUN cmake .. \ 28 | && make -j $(nproc) \ 29 | && make install 30 | 31 | FROM debian:buster AS cpp-release 32 | 33 | ENV LD_LIBRARY_PATH="/usr/local/lib" 34 | 35 | # Install OSTk data 36 | 37 | ARG OSTK_DATA_LOCAL_CACHE="/var/cache/open-space-toolkit-data" 38 | ENV OSTK_DATA_LOCAL_CACHE="${OSTK_DATA_LOCAL_CACHE}" 39 | ENV OSTK_PHYSICS_DATA_LOCAL_REPOSITORY="${OSTK_DATA_LOCAL_CACHE}/data" 40 | 41 | RUN git clone --branch v1 --single-branch --depth=1 https://github.com/open-space-collective/open-space-toolkit-data.git ${OSTK_DATA_LOCAL_CACHE} && chmod -R g+w ${OSTK_DATA_LOCAL_CACHE} 42 | 43 | COPY --from=cpp-builder /usr/local/include/OpenSpaceToolkit /usr/local/include/OpenSpaceToolkit 44 | COPY --from=cpp-builder /usr/local/lib/libopen-space-toolkit-simulation.* /usr/local/lib/ 45 | COPY --from=cpp-builder /usr/local/share/OpenSpaceToolkit /usr/local/share/OpenSpaceToolkit 46 | COPY --from=cpp-builder /usr/local/test/OpenSpaceToolkit /usr/local/test/OpenSpaceToolkit 47 | 48 | ENTRYPOINT ["/usr/local/test/OpenSpaceToolkit/Simulation/open-space-toolkit-simulation.test"] 49 | 50 | FROM python:${PYTHON_TEST_VERSION}-slim AS python-builder 51 | 52 | COPY --from=cpp-builder /app/build/bindings/python/dist /dist 53 | 54 | RUN pip install /dist/*${PYTHON_TEST_VERSION_WITHOUT_DOT}*.whl 55 | 56 | FROM python:${PYTHON_TEST_VERSION}-slim AS python-release 57 | 58 | LABEL maintainer="lucas@loftorbital.com" 59 | 60 | RUN apt-get update -y \ 61 | && apt-get install -y libcurl4-openssl-dev libssl-dev wget unzip \ 62 | && rm -rf /var/lib/apt/lists/* 63 | 64 | RUN pip install "ipython" "numpy~=2.0" 65 | 66 | # Install OSTk data 67 | 68 | ARG OSTK_DATA_LOCAL_CACHE="/var/cache/open-space-toolkit-data" 69 | ENV OSTK_DATA_LOCAL_CACHE="${OSTK_DATA_LOCAL_CACHE}" 70 | ENV OSTK_PHYSICS_DATA_LOCAL_REPOSITORY="${OSTK_DATA_LOCAL_CACHE}/data" 71 | 72 | RUN git clone --branch v1 --single-branch --depth=1 https://github.com/open-space-collective/open-space-toolkit-data.git ${OSTK_DATA_LOCAL_CACHE} && chmod -R g+w ${OSTK_DATA_LOCAL_CACHE} 73 | 74 | COPY --from=python-builder /usr/local/lib/python${PYTHON_TEST_VERSION}/site-packages/ostk /usr/local/lib/python${PYTHON_TEST_VERSION}/site-packages/ostk 75 | 76 | ENTRYPOINT ["ipython"] 77 | -------------------------------------------------------------------------------- /docs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-space-collective/open-space-toolkit-simulation/081ae82a446a6c935201c3d739bce36edb14ae46/docs/.gitkeep -------------------------------------------------------------------------------- /docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | SET (DOCUMENTATION_TARGET "docs") 4 | 5 | SET (DOXYFILE_IN "${PROJECT_SOURCE_DIR}/docs/doxygen/Doxyfile.in") 6 | SET (DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile") 7 | 8 | FILE (GLOB MARKDOWN_DOC "${PROJECT_SOURCE_DIR}/docs/*.md") 9 | LIST (APPEND MARKDOWN_DOC "${PROJECT_SOURCE_DIR}/README.md") 10 | LIST (APPEND MARKDOWN_DOC "${PROJECT_SOURCE_DIR}/CONTRIBUTING.md") 11 | 12 | CONFIGURE_FILE (${DOXYFILE_IN} ${DOXYFILE} @ONLY) 13 | 14 | FILE (COPY ${MARKDOWN_DOC} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) 15 | FILE (COPY "${PROJECT_SOURCE_DIR}/docs/doxygen" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) 16 | 17 | FIND_PACKAGE ("Doxygen" QUIET) 18 | 19 | IF (NOT DOXYGEN_FOUND) 20 | 21 | ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/thirdparty/doxygen") 22 | 23 | SET (DOXYGEN_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/doxygen/source/bin/doxygen") 24 | 25 | ADD_CUSTOM_TARGET (${DOCUMENTATION_TARGET} ALL 26 | COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE} 27 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 28 | DEPENDS "doxygen" ${DOXYFILE} ${MARKDOWN_DOC} 29 | COMMENT "Generating API documentation with Doxygen" 30 | VERBATIM) 31 | 32 | ELSE () 33 | 34 | ADD_CUSTOM_TARGET (${DOCUMENTATION_TARGET} ALL 35 | COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE} 36 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 37 | DEPENDS ${DOXYFILE} ${MARKDOWN_DOC} 38 | COMMENT "Generating API documentation with Doxygen" 39 | VERBATIM) 40 | 41 | ENDIF () 42 | 43 | INSTALL (DIRECTORY "${DOCS_OUTPUT_PATH}/html/" DESTINATION ${INSTALL_DOC} COMPONENT "documentation") 44 | -------------------------------------------------------------------------------- /docs/Tutorial.md: -------------------------------------------------------------------------------- 1 | Tutorial 2 | ======== 3 | 4 | Below are examples illustrating a few common use-cases. 5 | 6 | [TOC] 7 | 8 | # Setup {#Setup} 9 | 10 | *To be completed...* 11 | 12 | # Examples {#Examples} 13 | 14 | *To be completed...* -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # 2 | # python_example documentation build configuration file, created by 3 | # sphinx-quickstart on Fri Feb 26 00:29:33 2016. 4 | # 5 | # This file is execfile()d with the current directory set to its 6 | # containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | from ostk.simulation import OpenSpaceToolkitSimulationPy 15 | 16 | # -- General configuration ------------------------------------------------ 17 | 18 | # If your documentation needs a minimal Sphinx version, state it here. 19 | needs_sphinx = "7.2" 20 | 21 | # Add any Sphinx extension module names here, as strings. They can be 22 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 23 | # ones. 24 | extensions = [ 25 | "sphinx.ext.autodoc", 26 | "sphinx.ext.intersphinx", 27 | "sphinx.ext.autosummary", 28 | "sphinx.ext.napoleon", 29 | "sphinx_math_dollar", 30 | "sphinx_design", 31 | "breathe", 32 | "myst_nb", 33 | ] 34 | 35 | 36 | # Add any paths that contain templates here, relative to this directory. 37 | templates_path = ["templates"] 38 | 39 | # The suffix(es) of source filenames. 40 | # You can specify multiple suffix as a list of string: 41 | source_suffix = [".rst", ".md"] 42 | 43 | add_module_names = False 44 | 45 | # The master toctree document. 46 | master_doc = "index" 47 | 48 | # General information about the project. 49 | project = "Open Space Toolkit Simulation" 50 | copyright = "2024, Lucas Bremond" 51 | author = "Lucas Bremond" 52 | 53 | # The version info for the project you're documenting, acts as replacement for 54 | # |version| and |release|, also used in various other places throughout the 55 | # built documents. 56 | # 57 | # The short X.Y version. 58 | version = OpenSpaceToolkitSimulationPy.__version__ 59 | # The full version, including alpha/beta/rc tags. 60 | release = OpenSpaceToolkitSimulationPy.__version__ 61 | 62 | # The language for content autogenerated by Sphinx. Refer to documentation 63 | # for a list of supported languages. 64 | # 65 | # This is also used if you do content translation via gettext catalogs. 66 | # Usually you set "language" from the command line for these cases. 67 | language = "english" 68 | 69 | # List of patterns, relative to source directory, that match files and 70 | # directories to ignore when looking for source files. 71 | exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".ipynb_checkpoints"] 72 | 73 | # If true, `todo` and `todoList` produce output, else they produce nothing. 74 | todo_include_todos = False 75 | 76 | python_maximum_signature_line_length = 88 77 | 78 | # -- Autodoc configuration ------------------------------------------------ 79 | 80 | autosummary_generate = True # Turn on sphinx.ext.autosummary 81 | # autodoc_typehints = "description" # Add type hints to __init__ params 82 | autodoc_member_order = "bysource" # Order members by source order 83 | html_show_sourcelink = ( 84 | False # Remove 'view source code' from top of page (for html, not python) 85 | ) 86 | autodoc_inherit_docstrings = True # If no docstring, inherit from base class 87 | set_type_checking_flag = True # Enable 'expensive' imports for sphinx_autodoc_typehints 88 | autoclass_content = "both" # Include both class docstring and __init__ 89 | 90 | 91 | def skip_member(app, what, name, obj, skip, options): 92 | if name in { 93 | "OpenSpaceToolkitCorePy", 94 | "OpenSpaceToolkitIOPy", 95 | "OpenSpaceToolkitMathematicsPy", 96 | "URL", 97 | "ip", 98 | "test", 99 | }: 100 | return True 101 | 102 | 103 | def setup(app): 104 | app.connect("autodoc-skip-member", skip_member) 105 | 106 | 107 | # -- Options for HTML output ---------------------------------------------- 108 | 109 | # The theme to use for HTML and HTML Help pages. See the documentation for 110 | # a list of builtin themes. 111 | html_theme = "sphinx_material" 112 | 113 | # Theme options are theme-specific and customize the look and feel of a theme 114 | # further. For a list of options available for each theme, see the 115 | # documentation. 116 | html_theme_options = { 117 | "base_url": "https://open-space-collective.github.io/open-space-toolkit-simulation/html/index.html", 118 | "repo_url": "https://github.com/open-space-collective/open-space-toolkit-simulation", 119 | "repo_name": "Open Space Toolkit Simulation", 120 | "html_minify": True, 121 | "css_minify": True, 122 | "nav_title": "Open Space Toolkit Simulation", 123 | "logo_icon": "🛰", 124 | "color_primary": "indigo", 125 | "color_accent": "blue", 126 | "globaltoc_depth": 2, 127 | "globaltoc_collapse": True, 128 | } 129 | 130 | html_sidebars = {"**": ["globaltoc.html", "localtoc.html", "searchbox.html"]} 131 | 132 | # The name for this set of Sphinx documents. If None, it defaults to 133 | # " v documentation". 134 | html_title = "Open Space Toolkit Simulation" 135 | 136 | # The name of an image file (relative to this directory) to place at the top 137 | # of the sidebar. 138 | # html_logo = None 139 | 140 | # The name of an image file (within the static path) to use as favicon of the 141 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 142 | # pixels large. 143 | # html_favicon = None 144 | 145 | # Add any paths that contain custom static files (such as style sheets) here, 146 | # relative to this directory. They are copied after the builtin static files, 147 | # so a file named "default.css" will overwrite the builtin "default.css". 148 | # html_static_path = ["_static"] 149 | 150 | # Output file base name for HTML help builder. 151 | htmlhelp_basename = "ostk_simulation_doc" 152 | 153 | 154 | # -- Options for manual page output --------------------------------------- 155 | 156 | # One entry per manual page. List of tuples 157 | # (source start file, name, description, authors, manual section). 158 | man_pages = [ 159 | ( 160 | master_doc, 161 | "Open Space Toolkit Simulation", 162 | "Open Space Toolkit Simulation Documentation", 163 | [author], 164 | 1, 165 | ) 166 | ] 167 | 168 | 169 | # Example configuration for intersphinx: refer to the Python standard library. 170 | intersphinx_mapping = { 171 | "python": ("https://docs.python.org/3", None), 172 | "numpy": ("https://numpy.org/doc/stable/", None), 173 | "ostk.core": ( 174 | "https://open-space-collective.github.io/open-space-toolkit-core/_build/html/", 175 | None, 176 | ), 177 | "ostk.mathematics": ( 178 | "https://open-space-collective.github.io/open-space-toolkit-mathematics/_build/html/", 179 | None, 180 | ), 181 | "ostk.physics": ( 182 | "https://open-space-collective.github.io/open-space-toolkit-physics/_build/html/", 183 | None, 184 | ), 185 | "ostk.simulation": ( 186 | "https://open-space-collective.github.io/open-space-toolkit-simulation/_build/html/", 187 | None, 188 | ), 189 | } 190 | 191 | 192 | def autodoc_process_docstring(app, what, name, obj, options, lines): 193 | for i in range(len(lines)): 194 | lines[i] = lines[i].replace("np.", "numpy.") 195 | # lines[i] = lines[i].replace("np.", "~numpy.") # For shorter links 196 | lines[i] = lines[i].replace("F.", "torch.nn.functional.") 197 | lines[i] = lines[i].replace("List[", "~typing.List[") 198 | 199 | 200 | def setup(app): 201 | app.connect("autodoc-process-docstring", autodoc_process_docstring) 202 | 203 | 204 | # -- Breathe configuration ------------------------------------------------- 205 | highlight_language = "c++" 206 | 207 | breathe_projects = {"C++ Sphinx Doxygen Breathe": "xml/"} 208 | breathe_default_project = "C++ Sphinx Doxygen Breathe" 209 | breathe_default_members = ("members", "undoc-members") 210 | 211 | # -- MyST NB configuration ------------------------------------------------- 212 | nb_execution_cache_path = "notebooks" 213 | nb_execution_timeout = 60 214 | myst_footnote_transition = False 215 | -------------------------------------------------------------------------------- /docs/cpp.rst: -------------------------------------------------------------------------------- 1 | C++ API Documentation 2 | ===================== 3 | 4 | .. toctree:: 5 | :glob: 6 | :maxdepth: 1 7 | 8 | cpp_rst/class/* -------------------------------------------------------------------------------- /docs/doxygen/html/DoxygenLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /docs/doxygen/html/doxygenextra.css: -------------------------------------------------------------------------------- 1 | body code { 2 | margin: 0; 3 | border: 1px solid #ddd; 4 | background-color: #f8f8f8; 5 | border-radius: 3px; 6 | padding: 0; 7 | } 8 | 9 | a { 10 | color: #4183c4; 11 | } 12 | 13 | a.el { 14 | font-weight: normal; 15 | } 16 | 17 | body, table, div, p, dl { 18 | color: #333333; 19 | font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; 20 | font-size: 15px; 21 | font-style: normal; 22 | font-variant: normal; 23 | font-weight: normal; 24 | line-height: 25.5px; 25 | } 26 | 27 | body { 28 | background-color: #eee; 29 | } 30 | 31 | div.header { 32 | background-image: none; 33 | background-color: white; 34 | margin: 0px; 35 | border: 0px; 36 | } 37 | 38 | div.headertitle { 39 | width: 858px; 40 | margin: 30px; 41 | padding: 0px; 42 | } 43 | 44 | div.toc { 45 | background-color: #f8f8f8; 46 | border-color: #ddd; 47 | margin-right: 10px; 48 | margin-left: 20px; 49 | } 50 | div.toc h3 { 51 | color: #333333; 52 | font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; 53 | font-size: 18px; 54 | font-style: normal; 55 | font-variant: normal; 56 | font-weight: normal; 57 | } 58 | div.toc li { 59 | color: #333333; 60 | font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; 61 | font-size: 12px; 62 | font-style: normal; 63 | font-variant: normal; 64 | font-weight: normal; 65 | } 66 | 67 | .title { 68 | font-size: 2.5em; 69 | line-height: 63.75px; 70 | border-bottom: 1px solid #ddd; 71 | margin-bottom: 15px; 72 | margin-left: 0px; 73 | margin-right: 0px; 74 | margin-top: 0px; 75 | } 76 | 77 | .summary { 78 | float: none !important; 79 | width: auto !important; 80 | padding-top: 10px; 81 | padding-right: 10px !important; 82 | } 83 | 84 | .summary + .headertitle .title { 85 | font-size: 1.5em; 86 | line-height: 2.0em; 87 | } 88 | 89 | body h1 { 90 | font-size: 2em; 91 | line-height: 1.7; 92 | border-bottom: 1px solid #eee; 93 | margin: 1em 0 15px; 94 | padding: 0; 95 | overflow: hidden; 96 | } 97 | 98 | body h2 { 99 | font-size: 1.5em; 100 | line-height: 1.7; 101 | margin: 1em 0 15px; 102 | padding: 0; 103 | } 104 | 105 | pre.fragment { 106 | font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; 107 | font-size: 13px; 108 | font-style: normal; 109 | font-variant: normal; 110 | font-weight: normal; 111 | line-height: 19px; 112 | } 113 | 114 | table.doxtable th { 115 | background-color: #f8f8f8; 116 | color: #333333; 117 | font-size: 15px; 118 | } 119 | 120 | table.doxtable td, table.doxtable th { 121 | border: 1px solid #ddd; 122 | } 123 | 124 | #doc-content { 125 | background-color: #fff; 126 | /* width: 918px; */ 127 | height: auto !important; 128 | margin-left: 270px !important; 129 | } 130 | 131 | div.contents { 132 | /* width: 858px; */ 133 | margin: 30px; 134 | } 135 | 136 | div.line { 137 | font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; 138 | font-size: 13px; 139 | font-style: normal; 140 | font-variant: normal; 141 | font-weight: normal; 142 | line-height: 19px; 143 | } 144 | 145 | div.image 146 | { 147 | text-align: left; 148 | display: inline-block; 149 | } 150 | 151 | tt, code, pre { 152 | font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; 153 | font-size: 12px; 154 | } 155 | 156 | div.fragment { 157 | background-color: #f8f8f8; 158 | border: 1px solid #ddd; 159 | font-size: 13px; 160 | line-height: 19px; 161 | overflow: auto; 162 | padding: 6px 10px; 163 | border-radius: 3px; 164 | } 165 | 166 | #topbanner { 167 | position: fixed; 168 | margin: 15px; 169 | z-index: 101; 170 | } 171 | 172 | #projectname 173 | { 174 | font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; 175 | font-size: 38px; 176 | font-weight: bold; 177 | line-height: 63.75px; 178 | margin: 0px; 179 | padding: 2px 0px; 180 | } 181 | 182 | #projectbrief 183 | { 184 | font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; 185 | font-size: 16px; 186 | line-height: 22.4px; 187 | margin: 0px 0px 13px 0px; 188 | padding: 2px; 189 | } 190 | 191 | /* side bar and search */ 192 | 193 | #side-nav 194 | { 195 | padding: 10px 0px 20px 20px; 196 | border-top: 60px solid #2980b9; 197 | background-color: #343131; 198 | width: 250px !important; 199 | height: 100% !important; 200 | position: fixed; 201 | } 202 | 203 | #nav-tree 204 | { 205 | background-color: transparent; 206 | background-image: none; 207 | height: 100% !important; 208 | } 209 | 210 | #nav-tree .label 211 | { 212 | font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; 213 | line-height: 25.5px; 214 | font-size: 15px; 215 | } 216 | 217 | #nav-tree 218 | { 219 | color: #b3b3b3; 220 | } 221 | 222 | #nav-tree .selected { 223 | background-image: none; 224 | } 225 | 226 | #nav-tree a 227 | { 228 | color: #b3b3b3; 229 | } 230 | 231 | #github 232 | { 233 | position: fixed; 234 | left: auto; 235 | right: auto; 236 | width: 250px; 237 | } 238 | 239 | #MSearchBox 240 | { 241 | margin: 20px; 242 | left: 40px; 243 | right: auto; 244 | position: fixed; 245 | width: 180px; 246 | } 247 | 248 | #MSearchField 249 | { 250 | width: 121px; 251 | } 252 | 253 | #MSearchResultsWindow 254 | { 255 | left: 45px !important; 256 | } 257 | 258 | #nav-sync 259 | { 260 | display: none; 261 | } 262 | 263 | .ui-resizable .ui-resizable-handle 264 | { 265 | width: 0px; 266 | } 267 | 268 | #nav-path 269 | { 270 | display: none; 271 | } 272 | 273 | /* external link icon */ 274 | div.contents a[href ^= "http"]:after { 275 | content: " " url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAVklEQVR4Xn3PgQkAMQhDUXfqTu7kTtkpd5RA8AInfArtQ2iRXFWT2QedAfttj2FsPIOE1eCOlEuoWWjgzYaB/IkeGOrxXhqB+uA9Bfcm0lAZuh+YIeAD+cAqSz4kCMUAAAAASUVORK5CYII=); 276 | } 277 | 278 | .githublogo { 279 | content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0NzoxNiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RERCMUIwOUY4NkNFMTFFM0FBNTJFRTMzNTJEMUJDNDYiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RERCMUIwOUU4NkNFMTFFM0FBNTJFRTMzNTJEMUJDNDYiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkU1MTc4QTJBOTlBMDExRTI5QTE1QkMxMDQ2QTg5MDREIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkU1MTc4QTJCOTlBMDExRTI5QTE1QkMxMDQ2QTg5MDREIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+jUqS1wAAApVJREFUeNq0l89rE1EQx3e3gVJoSPzZeNEWPKgHoa0HBak0iHiy/4C3WvDmoZ56qJ7txVsPQu8qlqqHIhRKJZceesmhioQEfxTEtsoSpdJg1u/ABJ7Pmc1m8zLwgWTmzcw3L+/te+tHUeQltONgCkyCi2AEDHLsJ6iBMlgHL8FeoqokoA2j4CloRMmtwTmj7erHBXPgCWhG6a3JNXKdCiDl1cidVbXZkJoXQRi5t5BrxwoY71FzU8S4JuAIqFkJ2+BFSlEh525b/hr3+k/AklDkNsf6wTT4yv46KIMNpsy+iMdMc47HNWxbsgVcUn7FmLAzzoFAWDsBx+wVP6bUpp5ewI+DOeUx0Wd9D8F70BTGNjkWtqnhmT1JQAHcUgZd8Lo3rQb1LAT8eJVUfgGvHQigGp+V2Z0iAUUl8QH47kAA1XioxIo+bRN8OG8F/oBjwv+Z1nJgX5jpdzQDw0LCjsPmrcW7I/iHScCAEDj03FtD8A0EyuChHgg4KTlJQF3wZ7WELppnBX+dBFSVpJsOBWi1qiRgSwnOgoyD5hmuJdkWCVhTgnTvW3AgYIFrSbZGh0UW/Io5Vp+DQoK7o80pztWMemZbgxeNwCNwDbw1fIfgGZjhU6xPaJgBV8BdsMw5cbZoHsenwYFxkZzl83xTSKTiviCAfCsJLysH3POfC8m8NegyGAGfLP/VmGmfSChgXroR0RSWjEFv2J/nG84cuKFMf4sTCZqXuJd4KaXFVjEG3+tw4eXbNK/YC9oXXs3O8NY8y99L4BXY5cvLY/Bb2VZ58EOJVcB18DHJq9lRsKr8inyKGVjlmh29mtHs3AHfuhCwy1vXT/Nu2GKQt+UHsGdctyX6eQyNvc+5sfX9Dl7Pe2J/BRgAl2CpwmrsHR0AAAAASUVORK5CYII=); 280 | } -------------------------------------------------------------------------------- /docs/doxygen/html/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/doxygen/html/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | $projectname: Documentation 9 | $title: Documentation 10 | 11 | 12 | 13 | $treeview 14 | $search 15 | $mathjax 16 | 17 | $extrastylesheet 18 | 19 | 20 |
21 |
22 | $searchbox 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Redirecting... 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | ```{include} ../README.md 2 | :relative-docs: ./ 3 | :relative-images: 4 | ``` 5 | 6 | ```{toctree} 7 | :maxdepth: 1 8 | :hidden: 9 | 10 | cpp 11 | python 12 | notebook 13 | ``` -------------------------------------------------------------------------------- /docs/python.rst: -------------------------------------------------------------------------------- 1 | Python API Documentation 2 | ======================== 3 | 4 | .. autosummary:: 5 | :toctree: _autosummary 6 | :template: custom-module-template.rst 7 | :recursive: 8 | 9 | ostk.simulation 10 | ostk.simulation.component 11 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | sphinx~=7.2 4 | breathe~=4.35 5 | myst-parser~=2.0 6 | sphinx-math-dollar~=1.2 7 | sphinx-design~=0.5 8 | sphinx-material~=0.0 9 | kaleido~=0.2 10 | myst-nb~=1.0 11 | -------------------------------------------------------------------------------- /docs/templates/custom-class-template.rst: -------------------------------------------------------------------------------- 1 | {{ fullname | escape | underline}} 2 | 3 | .. currentmodule:: {{ module }} 4 | 5 | .. autoclass:: {{ objname }} 6 | :members: 7 | :show-inheritance: 8 | :inherited-members: 9 | :special-members: __call__, __add__, __mul__ 10 | 11 | {% block methods %} 12 | {% if methods %} 13 | .. rubric:: {{ _('Methods') }} 14 | 15 | .. autosummary:: 16 | :nosignatures: 17 | {% for item in methods %} 18 | {%- if not item.startswith('_') %} 19 | ~{{ name }}.{{ item }} 20 | {%- endif -%} 21 | {%- endfor %} 22 | {% endif %} 23 | {% endblock %} 24 | 25 | {% block attributes %} 26 | {% if attributes %} 27 | .. rubric:: {{ _('Attributes') }} 28 | 29 | .. autosummary:: 30 | {% for item in attributes %} 31 | ~{{ name }}.{{ item }} 32 | {%- endfor %} 33 | {% endif %} 34 | {% endblock %} -------------------------------------------------------------------------------- /docs/templates/custom-module-template.rst: -------------------------------------------------------------------------------- 1 | {{ fullname | escape | underline}} 2 | 3 | .. automodule:: {{ fullname }} 4 | 5 | {% block attributes %} 6 | {% if attributes %} 7 | .. rubric:: Module attributes 8 | 9 | .. autosummary:: 10 | :toctree: 11 | {% for item in attributes %} 12 | {{ item }} 13 | {%- endfor %} 14 | {% endif %} 15 | {% endblock %} 16 | 17 | {% block functions %} 18 | {% if functions %} 19 | .. rubric:: {{ _('Functions') }} 20 | 21 | .. autosummary:: 22 | :toctree: 23 | :nosignatures: 24 | {% for item in functions %} 25 | {{ item }} 26 | {%- endfor %} 27 | {% endif %} 28 | {% endblock %} 29 | 30 | {% block classes %} 31 | {% if classes %} 32 | .. rubric:: {{ _('Classes') }} 33 | 34 | .. autosummary:: 35 | :toctree: 36 | :template: custom-class-template.rst 37 | :nosignatures: 38 | {% for item in classes %} 39 | {{ item }} 40 | {%- endfor %} 41 | {% endif %} 42 | {% endblock %} 43 | 44 | {% block exceptions %} 45 | {% if exceptions %} 46 | .. rubric:: {{ _('Exceptions') }} 47 | 48 | .. autosummary:: 49 | :toctree: 50 | {% for item in exceptions %} 51 | {{ item }} 52 | {%- endfor %} 53 | {% endif %} 54 | {% endblock %} -------------------------------------------------------------------------------- /include/OpenSpaceToolkit/Simulation/Component.hpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #ifndef __OpenSpaceToolkit_Simulation_Component__ 4 | #define __OpenSpaceToolkit_Simulation_Component__ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | namespace ostk 20 | { 21 | namespace simulation 22 | { 23 | 24 | using ostk::core::container::Array; 25 | using ostk::core::container::Map; 26 | using ostk::core::type::Shared; 27 | using ostk::core::type::String; 28 | using ostk::core::type::Unique; 29 | using ostk::core::type::Weak; 30 | 31 | using ostk::mathematics::geometry::d3::transformation::rotation::Quaternion; 32 | 33 | using ostk::physics::coordinate::Frame; 34 | 35 | using ostk::simulation::component::Geometry; 36 | using ostk::simulation::component::GeometryConfiguration; 37 | using ostk::simulation::component::State; 38 | using ostk::simulation::utility::ComponentHolder; 39 | 40 | #define DEFAULT_COMPONENT_TYPE Component::Type::Undefined 41 | #define DEFAULT_TAGS Array::Empty() 42 | #define DEFAULT_ORIENTATION Quaternion::Unit() 43 | #define DEFAULT_GEOMETRIES Array::Empty() 44 | #define DEFAULT_COMPONENTS Array::Empty() 45 | 46 | class Simulator; 47 | struct ComponentConfiguration; 48 | 49 | /// @brief Component 50 | 51 | class Component : public Entity, public ComponentHolder, public std::enable_shared_from_this 52 | { 53 | public: 54 | enum class Type 55 | { 56 | 57 | Undefined, 58 | Assembly, 59 | Controller, 60 | Sensor, 61 | Actuator, 62 | Other 63 | 64 | }; 65 | 66 | Component( 67 | const String& anId, 68 | const String& aName, 69 | const Component::Type& aType, 70 | const Array& aTagArray, 71 | const Array>& aGeometryArray, 72 | const Array>& aComponentArray, 73 | const Shared& aParentComponentSPtr, 74 | const Shared& aFrameSPtr, 75 | const Shared& aSimulatorSPtr 76 | ); 77 | 78 | Component(const Component& aComponent); 79 | 80 | virtual ~Component(); 81 | 82 | virtual Component* clone() const; 83 | 84 | friend std::ostream& operator<<(std::ostream& anOutputStream, const Component& aComponent); 85 | 86 | bool isDefined() const; 87 | 88 | const Shared& accessFrame() const; 89 | 90 | const Geometry& accessGeometryWithName(const String& aName) const; 91 | 92 | const Simulator& accessSimulator() const; 93 | 94 | Component::Type getType() const; 95 | 96 | Array getTags() const; 97 | 98 | Array> getGeometries() const; 99 | 100 | void setParent(const Shared& aComponentSPtr); 101 | 102 | void addGeometry(const Shared& aGeometrySPtr); 103 | 104 | void addComponent(const Shared& aComponentSPtr); 105 | 106 | static Component Undefined(); 107 | 108 | static Shared Configure( 109 | const ComponentConfiguration& aComponentConfiguration, const Shared& aParentComponentSPtr 110 | ); 111 | 112 | static String StringFromType(const Component::Type& aType); 113 | 114 | static Shared GenerateFrame( 115 | const String& aName, const Quaternion& aQuaternion, const Shared& aParentFrameSPtr 116 | ); 117 | 118 | protected: 119 | /// @brief Print component 120 | /// 121 | /// @param [in] anOutputStream An output stream 122 | /// @param [in] (optional) displayDecorators If true, display decorators 123 | 124 | virtual void print(std::ostream& anOutputStream, bool displayDecorators = true) const; 125 | 126 | private: 127 | Component::Type type_; 128 | Array tags_; 129 | Array> geometries_; // Array of Geometries defined in Component Frame 130 | 131 | Weak parentWPtr_; 132 | Shared frameSPtr_; 133 | Shared simulatorSPtr_; 134 | }; 135 | 136 | struct ComponentConfiguration 137 | { 138 | const String id; 139 | const String name; 140 | const Component::Type type = DEFAULT_COMPONENT_TYPE; 141 | const Array tags = DEFAULT_TAGS; 142 | const Quaternion orientation = DEFAULT_ORIENTATION; 143 | const Array geometries = DEFAULT_GEOMETRIES; 144 | const Array components = DEFAULT_COMPONENTS; 145 | }; 146 | 147 | } // namespace simulation 148 | } // namespace ostk 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /include/OpenSpaceToolkit/Simulation/Component/Geometry.hpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #ifndef __OpenSpaceToolkit_Simulation_Component_Geometry__ 4 | #define __OpenSpaceToolkit_Simulation_Component_Geometry__ 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace ostk 15 | { 16 | namespace simulation 17 | { 18 | 19 | class Component; 20 | 21 | namespace component 22 | { 23 | 24 | using ostk::core::type::Shared; 25 | using ostk::core::type::String; 26 | using ostk::mathematics::geometry::d3::Object; 27 | using ostk::mathematics::geometry::d3::object::Composite; 28 | 29 | using ostk::physics::coordinate::Frame; 30 | using ObjectGeometry = ostk::physics::environment::object::Geometry; 31 | using ostk::physics::environment::object::Celestial; 32 | 33 | struct GeometryConfiguration; 34 | 35 | /// @brief Component geometry 36 | 37 | class Geometry 38 | { 39 | public: 40 | Geometry(const String& aName, const Composite& aComposite, const Shared& aComponentSPtr); 41 | 42 | /// @brief Copy assignment operator 43 | /// 44 | /// @param [in] aGeometry A geometry 45 | /// @return Reference to geometry 46 | 47 | /// @brief Equal to operator 48 | /// 49 | /// @param [in] aGeometry A geometry 50 | /// @return True if geometries are equal 51 | 52 | bool operator==(const Geometry& aGeometry) const; 53 | 54 | /// @brief Not equal to operator 55 | /// 56 | /// @param [in] aGeometry A geometry 57 | /// @return True if geometries are not equal 58 | 59 | bool operator!=(const Geometry& aGeometry) const; 60 | 61 | /// @brief Output stream operator 62 | /// 63 | /// @param [in] anOutputStream An output stream 64 | /// @param [in] aGeometry A geometry 65 | /// @return A reference to output stream 66 | 67 | friend std::ostream& operator<<(std::ostream& anOutputStream, const Geometry& aGeometry); 68 | 69 | /// @brief Check if geometry is defined 70 | /// 71 | /// @return True if geometry is defined 72 | 73 | bool isDefined() const; 74 | 75 | /// TBI 76 | 77 | const Component& accessComponent() const; 78 | 79 | /// TBI 80 | 81 | String getName() const; 82 | 83 | /// @brief Check if geometry intersects another geometry 84 | /// 85 | /// @param [in] aGeometry A geometry 86 | /// @return True if geometry intersects another geometry 87 | 88 | bool intersects(const ObjectGeometry& aGeometry) const; 89 | 90 | /// @brief Check if geometry intersects a celestial object 91 | /// 92 | /// @param [in] aCelestialObject A celestial object 93 | /// @return True if geometry intersects a celestial object 94 | 95 | bool intersects(const Celestial& aCelestialObject) const; 96 | 97 | /// @brief Check if geometry contains another geometry 98 | /// 99 | /// @param [in] aGeometry A geometry 100 | /// @return True if geometry contains another geometry 101 | 102 | bool contains(const ObjectGeometry& aGeometry) const; 103 | 104 | /// @brief Check if geometry contains a celestial object 105 | /// 106 | /// @param [in] aCelestialObject A celestial object 107 | /// @return True if geometry contains a celestial object 108 | 109 | bool contains(const Celestial& aCelestialObject) const; 110 | 111 | /// @brief Access composite 112 | /// 113 | /// @return Reference to composite 114 | 115 | const Composite& accessComposite() const; 116 | 117 | /// @brief Access frame 118 | /// 119 | /// @return Shared pointer to frame 120 | 121 | Shared accessFrame() const; 122 | 123 | /// @brief Get geometry in frame 124 | /// 125 | /// @return Geometry 126 | 127 | ObjectGeometry getGeometryIn(const Shared& aFrameSPtr) const; 128 | 129 | /// @brief Compute intersection of geometry with another geometry 130 | /// 131 | /// @param [in] aGeometry A geometry 132 | /// @return Intersection of geometry with another geometry 133 | 134 | ObjectGeometry intersectionWith(const ObjectGeometry& aGeometry) const; 135 | 136 | /// @brief Compute intersection of geometry with a celestial object 137 | /// 138 | /// @param [in] aCelestialObject A celestial object 139 | /// @return Intersection of geometry with a celestial object 140 | 141 | ObjectGeometry intersectionWith(const Celestial& aCelestialObject) const; 142 | 143 | static Geometry Undefined(); 144 | 145 | static Shared Configure( 146 | const GeometryConfiguration& aGeometryConfiguration, const Shared& aComponentSPtr 147 | ); 148 | 149 | private: 150 | String name_; 151 | ObjectGeometry geometry_; 152 | Shared componentPtr_; 153 | }; 154 | 155 | struct GeometryConfiguration 156 | { 157 | const String name; 158 | const Composite composite; 159 | }; 160 | 161 | } // namespace component 162 | } // namespace simulation 163 | } // namespace ostk 164 | 165 | #endif 166 | -------------------------------------------------------------------------------- /include/OpenSpaceToolkit/Simulation/Component/State.hpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #ifndef __OpenSpaceToolkit_Simulation_Component_State__ 4 | #define __OpenSpaceToolkit_Simulation_Component_State__ 5 | 6 | namespace ostk 7 | { 8 | namespace simulation 9 | { 10 | namespace component 11 | { 12 | 13 | #define DEFAULT_STATUS State::Status::Disabled 14 | #define DEFAULT_VERBOSE false 15 | 16 | /// @brief Component state 17 | 18 | class State 19 | { 20 | public: 21 | enum class Status 22 | { 23 | 24 | Undefined, 25 | Disabled, 26 | Idle, 27 | Busy, 28 | Error 29 | 30 | }; 31 | 32 | State(const State::Status& aStatus = DEFAULT_STATUS, const bool& isVerbose = DEFAULT_VERBOSE); 33 | 34 | State(const State& aState); 35 | 36 | virtual ~State(); 37 | 38 | virtual State* clone() const; 39 | 40 | State& operator=(const State& aState); 41 | 42 | /// @brief Equal to operator 43 | /// 44 | /// @code 45 | /// State firstState = ... ; 46 | /// State secondState = ... ; 47 | /// firstState == secondState ; // True 48 | /// @endcode 49 | /// 50 | /// @param [in] aState A state 51 | /// @return True if states are equal 52 | 53 | bool operator==(const State& aState) const; 54 | 55 | bool isDefined() const; 56 | 57 | State::Status getStatus() const; 58 | 59 | static State Undefined(); 60 | 61 | private: 62 | State::Status status_; 63 | bool verbose_; 64 | }; 65 | 66 | } // namespace component 67 | } // namespace simulation 68 | } // namespace ostk 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /include/OpenSpaceToolkit/Simulation/Entity.hpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #ifndef __OpenSpaceToolkit_Simulation_Entity__ 4 | #define __OpenSpaceToolkit_Simulation_Entity__ 5 | 6 | #include 7 | 8 | namespace ostk 9 | { 10 | namespace simulation 11 | { 12 | 13 | using ostk::core::type::String; 14 | 15 | /// @brief Entity 16 | 17 | class Entity 18 | { 19 | public: 20 | Entity(const String& aName); 21 | 22 | Entity(const String& anId, const String& aName); 23 | 24 | bool isDefined() const; 25 | 26 | String getId() const; 27 | 28 | String getName() const; 29 | 30 | /// @brief Print entity 31 | /// 32 | /// @param [in] anOutputStream An output stream 33 | /// @param [in] (optional) displayDecorators If true, display decorators 34 | 35 | void print(std::ostream& anOutputStream, bool displayDecorators = true) const; 36 | 37 | static Entity Undefined(); 38 | 39 | private: 40 | String id_; 41 | String name_; 42 | }; 43 | 44 | } // namespace simulation 45 | } // namespace ostk 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/OpenSpaceToolkit/Simulation/Satellite.hpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #ifndef __OpenSpaceToolkit_Simulation_Satellite__ 4 | #define __OpenSpaceToolkit_Simulation_Satellite__ 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | #include 17 | 18 | namespace ostk 19 | { 20 | namespace simulation 21 | { 22 | 23 | using ostk::core::container::Array; 24 | using ostk::core::container::Map; 25 | using ostk::core::type::Shared; 26 | using ostk::core::type::String; 27 | 28 | using ostk::physics::coordinate::Frame; 29 | 30 | using ostk::astrodynamics::flight::Profile; 31 | 32 | using ostk::simulation::Component; 33 | using ostk::simulation::ComponentConfiguration; 34 | 35 | #define DEFAULT_COMPONENTS Array::Empty() 36 | #define DEFAULT_TAGS Array::Empty() 37 | #define DEFAULT_GEOMETRIES Array::Empty() 38 | 39 | class Simulator; 40 | struct SatelliteConfiguration; 41 | 42 | /// @brief Satellite 43 | 44 | class Satellite : public Component 45 | { 46 | public: 47 | Satellite( 48 | const String& anId, 49 | const String& aName, 50 | const Array& aTagArray, 51 | const Array>& aGeometryArray, 52 | const Array>& aComponentArray, 53 | const Shared& aFrameSPtr, 54 | const Shared& aProfileSPtr, 55 | const Shared& aSimulatorSPtr 56 | ); 57 | 58 | Satellite(const Satellite& aSatellite); 59 | 60 | ~Satellite(); 61 | 62 | Satellite* clone() const; 63 | 64 | friend std::ostream& operator<<(std::ostream& anOutputStream, const Satellite& aSatellite); 65 | 66 | bool isDefined() const; 67 | 68 | const Shared accessProfile() const; 69 | 70 | /// @brief Print satellite 71 | /// 72 | /// @param [in] anOutputStream An output stream 73 | /// @param [in] (optional) displayDecorators If true, display decorators 74 | 75 | void print(std::ostream& anOutputStream, bool displayDecorators = true) const; 76 | 77 | static Satellite Undefined(); 78 | 79 | static Shared Configure( 80 | const SatelliteConfiguration& aSatelliteConfiguration, const Shared& aSimulatorSPtr 81 | ); 82 | 83 | static Shared GenerateFrame(const String& aName, const Shared& aProfile); 84 | 85 | private: 86 | Shared profileSPtr_; 87 | }; 88 | 89 | struct SatelliteConfiguration 90 | { 91 | const String id; 92 | const String name; 93 | const Profile profile; 94 | const Array components = DEFAULT_COMPONENTS; 95 | const Array tags = DEFAULT_TAGS; 96 | const Array geometries = DEFAULT_GEOMETRIES; 97 | }; 98 | 99 | } // namespace simulation 100 | } // namespace ostk 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /include/OpenSpaceToolkit/Simulation/Simulator.hpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #ifndef __OpenSpaceToolkit_Simulation_Simulator__ 4 | #define __OpenSpaceToolkit_Simulation_Simulator__ 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | namespace ostk 18 | { 19 | namespace simulation 20 | { 21 | 22 | #define DEFAULT_SATELLITES Array::Empty() 23 | 24 | using ostk::core::container::Array; 25 | using ostk::core::container::Map; 26 | using ostk::core::type::Shared; 27 | using ostk::core::type::String; 28 | 29 | using ostk::physics::Environment; 30 | using ostk::physics::time::Duration; 31 | using ostk::physics::time::Instant; 32 | 33 | using ostk::simulation::Satellite; 34 | 35 | struct SimulatorConfiguration; 36 | 37 | /// @brief Simulator 38 | 39 | class Simulator 40 | { 41 | public: 42 | Simulator(const Environment& anEnvironment, const Array>& aSatelliteArray); 43 | 44 | friend std::ostream& operator<<(std::ostream& anOutputStream, const Simulator& aSimulator); 45 | 46 | bool isDefined() const; 47 | 48 | bool hasSatelliteWithName(const String& aSatelliteName) const; 49 | 50 | const Environment& accessEnvironment() const; 51 | 52 | const Map>& accessSatelliteMap() const; 53 | 54 | const Satellite& accessSatelliteWithName(const String& aSatelliteName) const; 55 | 56 | Instant getInstant() const; 57 | 58 | /// @brief Print simulator 59 | /// 60 | /// @param [in] anOutputStream An output stream 61 | /// @param [in] (optional) displayDecorators If true, display decorators 62 | 63 | void print(std::ostream& anOutputStream, bool displayDecorators = true) const; 64 | 65 | void setInstant(const Instant& anInstant); 66 | 67 | void stepForward(const Duration& aDuration); 68 | 69 | void addSatellite(const Shared& aSatelliteSPtr); 70 | 71 | static Simulator Undefined(); 72 | 73 | static Shared Configure(const SimulatorConfiguration& aSimulatorConfiguration); 74 | 75 | private: 76 | Environment environment_; 77 | Map> satelliteMap_; 78 | }; 79 | 80 | struct SimulatorConfiguration 81 | { 82 | const Environment environment; 83 | const Array satellites = DEFAULT_SATELLITES; 84 | }; 85 | 86 | } // namespace simulation 87 | } // namespace ostk 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /include/OpenSpaceToolkit/Simulation/Utility/ComponentHolder.hpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #ifndef __OpenSpaceToolkit_Simulation_Utilties_ComponentHolder__ 4 | #define __OpenSpaceToolkit_Simulation_Utilties_ComponentHolder__ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace ostk 14 | { 15 | namespace simulation 16 | { 17 | 18 | class Component; 19 | class ComponentConfiguration; 20 | 21 | namespace utility 22 | { 23 | 24 | using ostk::core::container::Array; 25 | using ostk::core::container::Map; 26 | using ostk::core::container::Pair; 27 | using ostk::core::type::Shared; 28 | using ostk::core::type::String; 29 | using ostk::core::type::Unique; 30 | 31 | /// @brief Generic Component holder 32 | 33 | class ComponentHolder 34 | { 35 | public: 36 | ComponentHolder(const Array>& aComponentArray = Array>::Empty()); 37 | 38 | ComponentHolder(const ComponentHolder& aComponentHolder); 39 | 40 | ~ComponentHolder(); 41 | 42 | bool hasComponentWithId(const String& aComponentId) const; 43 | 44 | bool hasComponentWithName(const String& aComponentName) const; 45 | 46 | bool hasComponentAt(const String& aComponentPath) const; 47 | 48 | Array> accessComponents() const; 49 | 50 | const Component& accessComponentWithId(const String& aComponentId) const; 51 | 52 | const Component& accessComponentWithName(const String& aComponentName) const; 53 | 54 | Array> accessComponentsWithTag(const String& aComponentTag) const; 55 | 56 | const Component& accessComponentAt(const String& aComponentPath) const; 57 | 58 | void addComponent(const Shared& aComponentSPtr); 59 | 60 | private: 61 | Map> componentMap_; 62 | }; 63 | 64 | Pair splitComponentPath(const String& aComponentPath); 65 | 66 | } // namespace utility 67 | } // namespace simulation 68 | } // namespace ostk 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /include/OpenSpaceToolkit/Simulation/Utility/Identifier.hpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #ifndef __OpenSpaceToolkit_Simulation_Utilties_Identifier__ 4 | #define __OpenSpaceToolkit_Simulation_Utilties_Identifier__ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace ostk 14 | { 15 | namespace simulation 16 | { 17 | namespace utility 18 | { 19 | 20 | using ostk::core::type::String; 21 | 22 | String generateId(); 23 | 24 | } // namespace utility 25 | } // namespace simulation 26 | } // namespace ostk 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /share/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-space-collective/open-space-toolkit-simulation/081ae82a446a6c935201c3d739bce36edb14ae46/share/.gitkeep -------------------------------------------------------------------------------- /src/OpenSpaceToolkit/Simulation/Component.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | namespace ostk 13 | { 14 | namespace simulation 15 | { 16 | 17 | using ostk::physics::coordinate::frame::Provider; 18 | using ostk::physics::coordinate::Transform; 19 | using DynamicProvider = ostk::physics::coordinate::frame::provider::Dynamic; 20 | 21 | using namespace ostk::simulation::utility; 22 | 23 | Component::Component( 24 | const String& anId, 25 | const String& aName, 26 | const Component::Type& aType, 27 | const Array& aTagArray, 28 | const Array>& aGeometryArray, 29 | const Array>& aComponentArray, 30 | const Shared& aParentComponentSPtr, 31 | const Shared& aFrameSPtr, 32 | const Shared& aSimulatorSPtr 33 | ) 34 | : Entity(anId, aName), 35 | ComponentHolder(aComponentArray), 36 | type_(aType), 37 | tags_(aTagArray), 38 | geometries_(aGeometryArray), 39 | parentWPtr_(aParentComponentSPtr), 40 | frameSPtr_(aFrameSPtr), 41 | simulatorSPtr_(aSimulatorSPtr) 42 | { 43 | } 44 | 45 | Component::Component(const Component& aComponent) 46 | : Entity(aComponent), 47 | ComponentHolder(aComponent), 48 | enable_shared_from_this(aComponent), 49 | type_(aComponent.type_), 50 | tags_(aComponent.tags_), 51 | geometries_(aComponent.geometries_), 52 | parentWPtr_(aComponent.parentWPtr_), 53 | frameSPtr_(aComponent.frameSPtr_), 54 | simulatorSPtr_(aComponent.simulatorSPtr_) 55 | { 56 | } 57 | 58 | Component::~Component() {} 59 | 60 | Component* Component::clone() const 61 | { 62 | return new Component(*this); 63 | } 64 | 65 | std::ostream& operator<<(std::ostream& anOutputStream, const Component& aComponent) 66 | { 67 | aComponent.print(anOutputStream, true); 68 | 69 | return anOutputStream; 70 | } 71 | 72 | bool Component::isDefined() const 73 | { 74 | return Entity::isDefined() && frameSPtr_; 75 | } 76 | 77 | const Shared& Component::accessFrame() const 78 | { 79 | if (!this->isDefined()) 80 | { 81 | throw ostk::core::error::runtime::Undefined("Component"); 82 | } 83 | 84 | return this->frameSPtr_; 85 | } 86 | 87 | const Geometry& Component::accessGeometryWithName(const String& aName) const 88 | { 89 | if (!this->isDefined()) 90 | { 91 | throw ostk::core::error::runtime::Undefined("Component"); 92 | } 93 | 94 | for (const auto& geometryStr : this->geometries_) 95 | { 96 | if (geometryStr->getName() == aName) 97 | { 98 | return *geometryStr; 99 | } 100 | } 101 | 102 | throw ostk::core::error::RuntimeError("No Geometry found with name [{}].", aName); 103 | } 104 | 105 | const Simulator& Component::accessSimulator() const 106 | { 107 | if (!this->isDefined()) 108 | { 109 | throw ostk::core::error::runtime::Undefined("Component"); 110 | } 111 | 112 | if (!simulatorSPtr_) 113 | { 114 | throw ostk::core::error::runtime::Undefined("Simulator"); 115 | } 116 | 117 | return *(this->simulatorSPtr_); 118 | } 119 | 120 | Component::Type Component::getType() const 121 | { 122 | if (!this->isDefined()) 123 | { 124 | throw ostk::core::error::runtime::Undefined("Component"); 125 | } 126 | 127 | return this->type_; 128 | } 129 | 130 | Array Component::getTags() const 131 | { 132 | if (!this->isDefined()) 133 | { 134 | throw ostk::core::error::runtime::Undefined("Component"); 135 | } 136 | 137 | return this->tags_; 138 | } 139 | 140 | Array> Component::getGeometries() const 141 | { 142 | if (!this->isDefined()) 143 | { 144 | throw ostk::core::error::runtime::Undefined("Component"); 145 | } 146 | 147 | return this->geometries_; 148 | } 149 | 150 | void Component::setParent(const Shared& aComponentSPtr) 151 | { 152 | if (!this->isDefined()) 153 | { 154 | throw ostk::core::error::runtime::Undefined("Component"); 155 | } 156 | 157 | this->parentWPtr_ = aComponentSPtr; 158 | } 159 | 160 | void Component::addGeometry(const Shared& aGeometrySPtr) 161 | { 162 | if ((!aGeometrySPtr) || (!aGeometrySPtr->isDefined())) 163 | { 164 | throw ostk::core::error::runtime::Undefined("Geometry"); 165 | } 166 | 167 | this->geometries_.add(aGeometrySPtr); 168 | } 169 | 170 | void Component::addComponent(const Shared& aComponentSPtr) 171 | { 172 | aComponentSPtr->setParent(this->shared_from_this()); 173 | 174 | ComponentHolder::addComponent(aComponentSPtr); 175 | } 176 | 177 | Component Component::Undefined() 178 | { 179 | return { 180 | String::Empty(), 181 | String::Empty(), 182 | Component::Type::Undefined, 183 | Array::Empty(), 184 | Array>::Empty(), 185 | Array>::Empty(), 186 | nullptr, 187 | nullptr, 188 | nullptr 189 | }; 190 | } 191 | 192 | Shared Component::Configure( 193 | const ComponentConfiguration& aComponentConfiguration, const Shared& aParentComponentSPtr 194 | ) 195 | { 196 | if ((!aParentComponentSPtr) || (!aParentComponentSPtr->isDefined())) 197 | { 198 | throw ostk::core::error::runtime::Undefined("Parent component"); 199 | } 200 | 201 | const Shared componentSPtr = std::make_shared( 202 | aComponentConfiguration.id, 203 | aComponentConfiguration.name, 204 | aComponentConfiguration.type, 205 | aComponentConfiguration.tags, 206 | Array>::Empty(), 207 | Array>::Empty(), 208 | aParentComponentSPtr, 209 | Component::GenerateFrame( 210 | String::Format("Component [{}]", aComponentConfiguration.id), 211 | aComponentConfiguration.orientation, 212 | aParentComponentSPtr->accessFrame() 213 | ), 214 | aParentComponentSPtr->simulatorSPtr_ 215 | ); 216 | 217 | for (const auto& geometryConfiguration : aComponentConfiguration.geometries) 218 | { 219 | componentSPtr->addGeometry(Geometry::Configure(geometryConfiguration, componentSPtr)); 220 | } 221 | 222 | for (const auto& componentConfiguration : aComponentConfiguration.components) 223 | { 224 | componentSPtr->addComponent(Component::Configure(componentConfiguration, componentSPtr)); 225 | } 226 | 227 | return componentSPtr; 228 | } 229 | 230 | String Component::StringFromType(const Component::Type& aType) 231 | { 232 | static const Map typeStringMap = { 233 | {Component::Type::Undefined, "Undefined"}, 234 | {Component::Type::Assembly, "Assembly"}, 235 | {Component::Type::Controller, "Controller"}, 236 | {Component::Type::Sensor, "Sensor"}, 237 | {Component::Type::Actuator, "Actuator"}, 238 | {Component::Type::Other, "Other"} 239 | }; 240 | 241 | return typeStringMap.at(aType); 242 | } 243 | 244 | Shared Component::GenerateFrame( 245 | const String& aName, const Quaternion& aQuaternion, const Shared& aParentFrameSPtr 246 | ) 247 | { 248 | using ostk::physics::time::Instant; 249 | 250 | if (Frame::Exists(aName)) 251 | { 252 | Frame::Destruct(aName); 253 | } 254 | 255 | if (aParentFrameSPtr == nullptr) 256 | { 257 | throw ostk::core::error::runtime::Undefined("Frame"); 258 | } 259 | 260 | const Weak frameWPtr = aParentFrameSPtr; 261 | 262 | const Shared transformProviderSPtr = std::make_shared( 263 | [frameWPtr, aQuaternion](const Instant& anInstant) -> Transform 264 | { 265 | if (Shared frameSPtr = frameWPtr.lock()) 266 | { 267 | return Transform::Passive(anInstant, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, aQuaternion, {0.0, 0.0, 0.0}); 268 | } 269 | else 270 | { 271 | throw ostk::core::error::RuntimeError("Cannot get pointer to Profile."); 272 | } 273 | } 274 | ); 275 | 276 | return Frame::Construct(aName, false, aParentFrameSPtr, transformProviderSPtr); 277 | } 278 | 279 | void Component::print(std::ostream& anOutputStream, bool displayDecorators) const 280 | { 281 | displayDecorators ? ostk::core::utils::Print::Header(anOutputStream, "Component") : void(); 282 | 283 | Entity::print(anOutputStream, false); 284 | 285 | ostk::core::utils::Print::Line(anOutputStream) << "Type:" << Component::StringFromType(type_); 286 | 287 | displayDecorators ? ostk::core::utils::Print::Footer(anOutputStream) : void(); 288 | } 289 | 290 | } // namespace simulation 291 | } // namespace ostk 292 | -------------------------------------------------------------------------------- /src/OpenSpaceToolkit/Simulation/Component/Geometry.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | namespace ostk 11 | { 12 | namespace simulation 13 | { 14 | namespace component 15 | { 16 | 17 | Geometry::Geometry(const String& aName, const Composite& aComposite, const Shared& aComponentSPtr) 18 | : name_(aName), 19 | geometry_(ObjectGeometry::Undefined()), 20 | componentPtr_(aComponentSPtr) 21 | { 22 | if (componentPtr_ != nullptr) 23 | { 24 | geometry_ = ObjectGeometry(aComposite, componentPtr_->accessFrame()); 25 | } 26 | } 27 | 28 | bool Geometry::operator==(const Geometry& aGeometry) const 29 | { 30 | if ((!this->isDefined()) || (!aGeometry.isDefined())) 31 | { 32 | return false; 33 | } 34 | 35 | return (this->name_ == aGeometry.name_) && (this->geometry_ == aGeometry.geometry_) && 36 | (this->componentPtr_ == aGeometry.componentPtr_); 37 | } 38 | 39 | std::ostream& operator<<(std::ostream& anOutputStream, const Geometry& aGeometry) 40 | { 41 | // TBI 42 | 43 | (void)aGeometry; 44 | 45 | return anOutputStream; 46 | } 47 | 48 | bool Geometry::isDefined() const 49 | { 50 | return (!this->name_.isEmpty()) && this->geometry_.isDefined() && (this->componentPtr_ != nullptr); 51 | } 52 | 53 | const Component& Geometry::accessComponent() const 54 | { 55 | if (!this->isDefined()) 56 | { 57 | throw ostk::core::error::runtime::Undefined("Geometry"); 58 | } 59 | 60 | return *(this->componentPtr_); 61 | } 62 | 63 | String Geometry::getName() const 64 | { 65 | if (!this->isDefined()) 66 | { 67 | throw ostk::core::error::runtime::Undefined("Geometry"); 68 | } 69 | 70 | return name_; 71 | } 72 | 73 | bool Geometry::intersects(const ObjectGeometry& aGeometry) const 74 | { 75 | using ostk::physics::time::Instant; 76 | 77 | if ((!this->isDefined()) || (!aGeometry.isDefined())) 78 | { 79 | throw ostk::core::error::runtime::Undefined("Geometry"); 80 | } 81 | 82 | const Instant instant = this->accessComponent().accessSimulator().getInstant(); 83 | 84 | // TBM: Why GCRF? 85 | return this->getGeometryIn(Frame::GCRF()).intersects(aGeometry.in(Frame::GCRF(), instant)); 86 | } 87 | 88 | bool Geometry::intersects(const Celestial& aCelestialObject) const 89 | { 90 | return this->intersects(aCelestialObject.accessGeometry()); 91 | } 92 | 93 | bool Geometry::contains(const ObjectGeometry& aGeometry) const 94 | { 95 | using ostk::physics::time::Instant; 96 | 97 | if ((!this->isDefined()) || (!aGeometry.isDefined())) 98 | { 99 | throw ostk::core::error::runtime::Undefined("Geometry"); 100 | } 101 | 102 | const Instant instant = this->accessComponent().accessSimulator().getInstant(); 103 | 104 | // TBM: Why GCRF? 105 | return this->getGeometryIn(Frame::GCRF()).contains(aGeometry.in(Frame::GCRF(), instant)); 106 | } 107 | 108 | bool Geometry::contains(const Celestial& aCelestialObject) const 109 | { 110 | return this->contains(aCelestialObject.accessGeometry()); 111 | } 112 | 113 | const Composite& Geometry::accessComposite() const 114 | { 115 | return this->geometry_.accessComposite(); 116 | } 117 | 118 | Shared Geometry::accessFrame() const 119 | { 120 | return this->geometry_.accessFrame(); 121 | } 122 | 123 | ObjectGeometry Geometry::getGeometryIn(const Shared& aFrameSPtr) const 124 | { 125 | if (!this->isDefined()) 126 | { 127 | throw ostk::core::error::runtime::Undefined("Geometry"); 128 | } 129 | 130 | return this->geometry_.in(aFrameSPtr, this->accessComponent().accessSimulator().getInstant()); 131 | } 132 | 133 | ObjectGeometry Geometry::intersectionWith(const ObjectGeometry& aGeometry) const 134 | { 135 | using ostk::physics::time::Instant; 136 | 137 | if ((!this->isDefined()) || (!aGeometry.isDefined())) 138 | { 139 | throw ostk::core::error::runtime::Undefined("Geometry"); 140 | } 141 | 142 | const Instant instant = this->accessComponent().accessSimulator().getInstant(); 143 | 144 | // TBM: Why GCRF? 145 | return this->getGeometryIn(Frame::GCRF()).intersectionWith(aGeometry.in(Frame::GCRF(), instant)); 146 | } 147 | 148 | ObjectGeometry Geometry::intersectionWith(const Celestial& aCelestialObject) const 149 | { 150 | return this->intersectionWith(aCelestialObject.accessGeometry()); 151 | } 152 | 153 | Geometry Geometry::Undefined() 154 | { 155 | return {String::Empty(), Composite::Undefined(), nullptr}; 156 | } 157 | 158 | Shared Geometry::Configure( 159 | const GeometryConfiguration& aGeometryConfiguration, const Shared& aComponentSPtr 160 | ) 161 | { 162 | if (aComponentSPtr == nullptr) 163 | { 164 | throw ostk::core::error::runtime::Undefined("Component"); 165 | } 166 | 167 | return std::make_shared(aGeometryConfiguration.name, aGeometryConfiguration.composite, aComponentSPtr); 168 | } 169 | 170 | } // namespace component 171 | } // namespace simulation 172 | } // namespace ostk 173 | -------------------------------------------------------------------------------- /src/OpenSpaceToolkit/Simulation/Component/State.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace ostk 9 | { 10 | namespace simulation 11 | { 12 | namespace component 13 | { 14 | 15 | State::State(const State::Status& aStatus, const bool& isVerbose) 16 | : status_(aStatus), 17 | verbose_(isVerbose) 18 | { 19 | } 20 | 21 | State::State(const State& aState) 22 | : status_(aState.status_), 23 | verbose_(aState.verbose_) 24 | { 25 | } 26 | 27 | State::~State() {} 28 | 29 | State* State::clone() const 30 | { 31 | return new State(*this); 32 | } 33 | 34 | State& State::operator=(const State& aState) 35 | { 36 | if (this != &aState) 37 | { 38 | status_ = aState.status_; 39 | verbose_ = aState.verbose_; 40 | } 41 | 42 | return *this; 43 | } 44 | 45 | bool State::operator==(const State& aState) const 46 | { 47 | if ((!this->isDefined()) || (!aState.isDefined())) 48 | { 49 | return false; 50 | } 51 | 52 | return (status_ == aState.status_) && (verbose_ == aState.verbose_); 53 | } 54 | 55 | bool State::isDefined() const 56 | { 57 | return status_ != State::Status::Undefined; 58 | } 59 | 60 | State::Status State::getStatus() const 61 | { 62 | if (!this->isDefined()) 63 | { 64 | throw ostk::core::error::runtime::Undefined("State"); 65 | } 66 | 67 | return status_; 68 | } 69 | 70 | State State::Undefined() 71 | { 72 | return {State::Status::Undefined}; 73 | } 74 | 75 | } // namespace component 76 | } // namespace simulation 77 | } // namespace ostk 78 | -------------------------------------------------------------------------------- /src/OpenSpaceToolkit/Simulation/Entity.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace ostk 10 | { 11 | namespace simulation 12 | { 13 | 14 | using namespace ostk::simulation::utility; 15 | 16 | Entity::Entity(const String& aName) 17 | : id_(utility::generateId()), 18 | name_(aName) 19 | { 20 | } 21 | 22 | Entity::Entity(const String& anId, const String& aName) 23 | : id_(anId), 24 | name_(aName) 25 | { 26 | } 27 | 28 | bool Entity::isDefined() const 29 | { 30 | return (!id_.isEmpty()) && (!name_.isEmpty()); 31 | } 32 | 33 | String Entity::getId() const 34 | { 35 | if (!this->isDefined()) 36 | { 37 | throw ostk::core::error::runtime::Undefined("Entity"); 38 | } 39 | 40 | return id_; 41 | } 42 | 43 | String Entity::getName() const 44 | { 45 | if (!this->isDefined()) 46 | { 47 | throw ostk::core::error::runtime::Undefined("Entity"); 48 | } 49 | 50 | return name_; 51 | } 52 | 53 | Entity Entity::Undefined() 54 | { 55 | return {String::Empty(), String::Empty()}; 56 | } 57 | 58 | void Entity::print(std::ostream& anOutputStream, bool displayDecorators) const 59 | { 60 | displayDecorators ? ostk::core::utils::Print::Header(anOutputStream, "Entity") : void(); 61 | 62 | ostk::core::utils::Print::Line(anOutputStream) << "ID:" << id_; 63 | ostk::core::utils::Print::Line(anOutputStream) << "Name:" << name_; 64 | 65 | displayDecorators ? ostk::core::utils::Print::Footer(anOutputStream) : void(); 66 | } 67 | 68 | } // namespace simulation 69 | } // namespace ostk 70 | -------------------------------------------------------------------------------- /src/OpenSpaceToolkit/Simulation/Satellite.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | namespace ostk 13 | { 14 | namespace simulation 15 | { 16 | 17 | using ostk::physics::coordinate::frame::Provider; 18 | using ostk::physics::coordinate::Transform; 19 | using DynamicProvider = ostk::physics::coordinate::frame::provider::Dynamic; 20 | 21 | using namespace ostk::simulation::utility; 22 | 23 | Satellite::Satellite( 24 | const String& anId, 25 | const String& aName, 26 | const Array& aTagArray, 27 | const Array>& aGeometryArray, 28 | const Array>& aComponentArray, 29 | const Shared& aFrameSPtr, 30 | const Shared& aProfileSPtr, 31 | const Shared& aSimulatorSPtr 32 | ) 33 | : Component( 34 | anId, 35 | aName, 36 | Component::Type::Assembly, 37 | aTagArray, 38 | aGeometryArray, 39 | aComponentArray, 40 | nullptr, 41 | aFrameSPtr, 42 | aSimulatorSPtr 43 | ), 44 | profileSPtr_(aProfileSPtr) 45 | { 46 | } 47 | 48 | Satellite::Satellite(const Satellite& aSatellite) 49 | : Component(aSatellite), 50 | profileSPtr_(aSatellite.profileSPtr_) 51 | { 52 | } 53 | 54 | Satellite::~Satellite() {} 55 | 56 | Satellite* Satellite::clone() const 57 | { 58 | return new Satellite(*this); 59 | } 60 | 61 | std::ostream& operator<<(std::ostream& anOutputStream, const Satellite& aSatellite) 62 | { 63 | aSatellite.print(anOutputStream, true); 64 | 65 | return anOutputStream; 66 | } 67 | 68 | bool Satellite::isDefined() const 69 | { 70 | return Entity::isDefined(); 71 | } 72 | 73 | const Shared Satellite::accessProfile() const 74 | { 75 | if (!this->isDefined()) 76 | { 77 | throw ostk::core::error::runtime::Undefined("Satellite"); 78 | } 79 | 80 | return this->profileSPtr_; 81 | } 82 | 83 | void Satellite::print(std::ostream& anOutputStream, bool displayDecorators) const 84 | { 85 | displayDecorators ? ostk::core::utils::Print::Header(anOutputStream, "Satellite") : void(); 86 | 87 | Entity::print(anOutputStream, false); 88 | 89 | displayDecorators ? ostk::core::utils::Print::Footer(anOutputStream) : void(); 90 | } 91 | 92 | Satellite Satellite::Undefined() 93 | { 94 | return { 95 | String::Empty(), 96 | String::Empty(), 97 | Array::Empty(), 98 | Array>::Empty(), 99 | Array>::Empty(), 100 | nullptr, 101 | nullptr, 102 | nullptr 103 | }; 104 | } 105 | 106 | Shared Satellite::Configure( 107 | const SatelliteConfiguration& aSatelliteConfiguration, const Shared& aSimulatorSPtr 108 | ) 109 | { 110 | const Shared profileSPtr = std::make_shared(aSatelliteConfiguration.profile); 111 | 112 | const Shared satelliteSPtr = std::make_shared( 113 | aSatelliteConfiguration.id, 114 | aSatelliteConfiguration.name, 115 | aSatelliteConfiguration.tags, 116 | Array>::Empty(), 117 | Array>::Empty(), 118 | Satellite::GenerateFrame(String::Format("Satellite [{}]", aSatelliteConfiguration.id), profileSPtr), 119 | profileSPtr, 120 | aSimulatorSPtr 121 | ); 122 | 123 | for (const auto& geometryConfiguration : aSatelliteConfiguration.geometries) 124 | { 125 | satelliteSPtr->addGeometry(Geometry::Configure(geometryConfiguration, satelliteSPtr)); 126 | } 127 | 128 | for (const auto& componentConfiguration : aSatelliteConfiguration.components) 129 | { 130 | satelliteSPtr->addComponent(Component::Configure(componentConfiguration, satelliteSPtr)); 131 | } 132 | 133 | return satelliteSPtr; 134 | } 135 | 136 | Shared Satellite::GenerateFrame(const String& aName, const Shared& aProfileSPtr) 137 | { 138 | using ostk::physics::time::Instant; 139 | 140 | if (Frame::Exists(aName)) 141 | { 142 | Frame::Destruct(aName); 143 | } 144 | 145 | const Weak profileWPtr = aProfileSPtr; 146 | 147 | const Shared transformProviderSPtr = std::make_shared( 148 | [profileWPtr](const Instant& anInstant) -> Transform 149 | { 150 | if (Shared profileSPtr = profileWPtr.lock()) 151 | { 152 | const auto& state = profileSPtr->getStateAt(anInstant).inFrame(Frame::GCRF()); 153 | 154 | return Transform::Passive( 155 | anInstant, 156 | -state.getPosition().getCoordinates(), 157 | -state.getVelocity().getCoordinates(), // TBM: Random expression, didn't test this at all 158 | state.getAttitude(), 159 | -state.getAngularVelocity() // TBM: Random expression, didn't test this at all 160 | ); 161 | } 162 | else 163 | { 164 | throw ostk::core::error::RuntimeError("Cannot get pointer to Profile."); 165 | } 166 | } 167 | ); 168 | 169 | return Frame::Construct(aName, false, Frame::GCRF(), transformProviderSPtr); 170 | } 171 | 172 | } // namespace simulation 173 | } // namespace ostk 174 | -------------------------------------------------------------------------------- /src/OpenSpaceToolkit/Simulation/Simulator.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace ostk 9 | { 10 | namespace simulation 11 | { 12 | 13 | Simulator::Simulator(const Environment& anEnvironment, const Array>& aSatelliteArray) 14 | : environment_(anEnvironment), 15 | satelliteMap_() 16 | { 17 | for (const auto& satelliteSPtr : aSatelliteArray) 18 | { 19 | this->satelliteMap_.insert({satelliteSPtr->getName(), satelliteSPtr}); 20 | } 21 | } 22 | 23 | std::ostream& operator<<(std::ostream& anOutputStream, const Simulator& aSimulator) 24 | { 25 | aSimulator.print(anOutputStream, true); 26 | 27 | return anOutputStream; 28 | } 29 | 30 | bool Simulator::isDefined() const 31 | { 32 | return this->environment_.isDefined(); 33 | } 34 | 35 | bool Simulator::hasSatelliteWithName(const String& aSatelliteName) const 36 | { 37 | if (aSatelliteName.isEmpty()) 38 | { 39 | throw ostk::core::error::runtime::Undefined("Satellite name"); 40 | } 41 | 42 | if (!this->isDefined()) 43 | { 44 | throw ostk::core::error::runtime::Undefined("Simulator"); 45 | } 46 | 47 | return this->satelliteMap_.find(aSatelliteName) != this->satelliteMap_.end(); 48 | } 49 | 50 | const Environment& Simulator::accessEnvironment() const 51 | { 52 | if (!this->isDefined()) 53 | { 54 | throw ostk::core::error::runtime::Undefined("Simulator"); 55 | } 56 | 57 | return this->environment_; 58 | } 59 | 60 | const Map>& Simulator::accessSatelliteMap() const 61 | { 62 | if (!this->isDefined()) 63 | { 64 | throw ostk::core::error::runtime::Undefined("Simulator"); 65 | } 66 | 67 | return this->satelliteMap_; 68 | } 69 | 70 | const Satellite& Simulator::accessSatelliteWithName(const String& aSatelliteName) const 71 | { 72 | if (aSatelliteName.isEmpty()) 73 | { 74 | throw ostk::core::error::runtime::Undefined("Satellite name"); 75 | } 76 | 77 | if (!this->isDefined()) 78 | { 79 | throw ostk::core::error::runtime::Undefined("Simulator"); 80 | } 81 | 82 | const auto satelliteIt = this->satelliteMap_.find(aSatelliteName); 83 | 84 | if (satelliteIt == this->satelliteMap_.end()) 85 | { 86 | throw ostk::core::error::RuntimeError("No Satellite found with name [{}].", aSatelliteName); 87 | } 88 | 89 | return *(satelliteIt->second); 90 | } 91 | 92 | Instant Simulator::getInstant() const 93 | { 94 | if (!this->isDefined()) 95 | { 96 | throw ostk::core::error::runtime::Undefined("Simulator"); 97 | } 98 | 99 | return this->environment_.getInstant(); 100 | } 101 | 102 | void Simulator::print(std::ostream& anOutputStream, bool displayDecorators) const 103 | { 104 | displayDecorators ? ostk::core::utils::Print::Header(anOutputStream, "Simulator") : void(); 105 | 106 | // environment_.print(anOutputStream, true) ; 107 | 108 | displayDecorators ? ostk::core::utils::Print::Footer(anOutputStream) : void(); 109 | } 110 | 111 | void Simulator::setInstant(const Instant& anInstant) 112 | { 113 | if (!this->isDefined()) 114 | { 115 | throw ostk::core::error::runtime::Undefined("Simulator"); 116 | } 117 | 118 | this->environment_.setInstant(anInstant); 119 | } 120 | 121 | void Simulator::stepForward(const Duration& aDuration) 122 | { 123 | if (!this->isDefined()) 124 | { 125 | throw ostk::core::error::runtime::Undefined("Simulator"); 126 | } 127 | 128 | this->setInstant(this->environment_.getInstant() + aDuration); 129 | } 130 | 131 | void Simulator::addSatellite(const Shared& aSatelliteSPtr) 132 | { 133 | if ((!aSatelliteSPtr) || (!aSatelliteSPtr->isDefined())) 134 | { 135 | throw ostk::core::error::runtime::Undefined("Satellite"); 136 | } 137 | 138 | if (!this->isDefined()) 139 | { 140 | throw ostk::core::error::runtime::Undefined("Simulator"); 141 | } 142 | 143 | this->satelliteMap_.insert({aSatelliteSPtr->getName(), aSatelliteSPtr}); 144 | } 145 | 146 | Simulator Simulator::Undefined() 147 | { 148 | return {Environment::Undefined(), {}}; 149 | } 150 | 151 | Shared Simulator::Configure(const SimulatorConfiguration& aSimulatorConfiguration) 152 | { 153 | const Shared simulatorSPtr = 154 | std::make_shared(aSimulatorConfiguration.environment, Array>::Empty()); 155 | 156 | for (const auto& satelliteConfiguration : aSimulatorConfiguration.satellites) 157 | { 158 | simulatorSPtr->addSatellite(Satellite::Configure(satelliteConfiguration, simulatorSPtr)); 159 | } 160 | 161 | return simulatorSPtr; 162 | } 163 | 164 | } // namespace simulation 165 | } // namespace ostk 166 | -------------------------------------------------------------------------------- /src/OpenSpaceToolkit/Simulation/Utility/ComponentHolder.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace ostk 11 | { 12 | namespace simulation 13 | { 14 | namespace utility 15 | { 16 | 17 | ComponentHolder::ComponentHolder(const Array>& aComponentArray) 18 | : componentMap_() 19 | { 20 | for (const auto& componentSPtr : aComponentArray) 21 | { 22 | componentMap_.insert({componentSPtr->getName(), componentSPtr}); 23 | } 24 | } 25 | 26 | ComponentHolder::ComponentHolder(const ComponentHolder& aComponentHolder) 27 | : componentMap_() 28 | { 29 | for (const auto& componentMapIt : aComponentHolder.componentMap_) 30 | { 31 | componentMap_.insert({componentMapIt.first, Shared(componentMapIt.second->clone())}); 32 | } 33 | } 34 | 35 | ComponentHolder::~ComponentHolder() {} 36 | 37 | bool ComponentHolder::hasComponentWithId(const String& aComponentId) const 38 | { 39 | if (aComponentId.isEmpty()) 40 | { 41 | throw ostk::core::error::runtime::Undefined("Component ID"); 42 | } 43 | 44 | for (const auto& componentMapIt : this->componentMap_) 45 | { 46 | if (componentMapIt.second->getId() == aComponentId) 47 | { 48 | return true; 49 | } 50 | } 51 | 52 | return false; 53 | } 54 | 55 | bool ComponentHolder::hasComponentWithName(const String& aComponentName) const 56 | { 57 | if (aComponentName.isEmpty()) 58 | { 59 | throw ostk::core::error::runtime::Undefined("Component name"); 60 | } 61 | 62 | return componentMap_.find(aComponentName) != componentMap_.end(); 63 | } 64 | 65 | bool ComponentHolder::hasComponentAt(const String& aComponentPath) const 66 | { 67 | if (aComponentPath.isEmpty()) 68 | { 69 | throw ostk::core::error::runtime::Undefined("Component path"); 70 | } 71 | 72 | const auto [componentName, subComponentPath] = splitComponentPath(aComponentPath); 73 | 74 | if (!this->hasComponentWithName(componentName)) 75 | { 76 | return false; 77 | } 78 | 79 | return subComponentPath.isEmpty() ? true 80 | : this->accessComponentWithName(componentName).hasComponentAt(subComponentPath); 81 | } 82 | 83 | void ComponentHolder::addComponent(const Shared& aComponentSPtr) 84 | { 85 | if ((!aComponentSPtr) || (!aComponentSPtr->isDefined())) 86 | { 87 | throw ostk::core::error::runtime::Undefined("Component"); 88 | } 89 | 90 | componentMap_.insert({aComponentSPtr->getName(), aComponentSPtr}); 91 | } 92 | 93 | Array> ComponentHolder::accessComponents() const 94 | { 95 | // TBM: Return iterator instead, to avoid computing the Array. 96 | 97 | Array> components = Array>::Empty(); 98 | 99 | for (const auto& componentMapIt : this->componentMap_) 100 | { 101 | components.add(componentMapIt.second); 102 | } 103 | 104 | return components; 105 | } 106 | 107 | const Component& ComponentHolder::accessComponentWithId(const String& aComponentId) const 108 | { 109 | if (aComponentId.isEmpty()) 110 | { 111 | throw ostk::core::error::runtime::Undefined("Component ID"); 112 | } 113 | 114 | for (const auto& componentMapIt : this->componentMap_) 115 | { 116 | if (componentMapIt.second->getId() == aComponentId) 117 | { 118 | return *(componentMapIt.second); 119 | } 120 | } 121 | 122 | throw ostk::core::error::RuntimeError("No Component found with ID [{}].", aComponentId); 123 | } 124 | 125 | const Component& ComponentHolder::accessComponentWithName(const String& aComponentName) const 126 | { 127 | if (aComponentName.isEmpty()) 128 | { 129 | throw ostk::core::error::runtime::Undefined("Component name"); 130 | } 131 | 132 | const auto componentIt = componentMap_.find(aComponentName); 133 | 134 | if (componentIt == componentMap_.end()) 135 | { 136 | throw ostk::core::error::RuntimeError("No Component found with name [{}].", aComponentName); 137 | } 138 | 139 | return *(componentIt->second); 140 | } 141 | 142 | Array> ComponentHolder::accessComponentsWithTag(const String& aComponentTag) const 143 | { 144 | if (aComponentTag.isEmpty()) 145 | { 146 | throw ostk::core::error::runtime::Undefined("Component tag"); 147 | } 148 | 149 | Array> components = Array>::Empty(); 150 | 151 | for (const auto& componentMapIt : this->componentMap_) 152 | { 153 | Array componentTags = componentMapIt.second->getTags(); 154 | 155 | bool tagPresent = 156 | std::find(std::begin(componentTags), std::end(componentTags), aComponentTag) != std::end(componentTags); 157 | 158 | if (tagPresent == true) 159 | { 160 | components.add(componentMapIt.second); 161 | } 162 | } 163 | 164 | return components; 165 | } 166 | 167 | const Component& ComponentHolder::accessComponentAt(const String& aComponentPath) const 168 | { 169 | if (aComponentPath.isEmpty()) 170 | { 171 | throw ostk::core::error::runtime::Undefined("Component path"); 172 | } 173 | 174 | if (!this->hasComponentAt(aComponentPath)) 175 | { 176 | throw ostk::core::error::RuntimeError("No Component found with path [{}].", aComponentPath); 177 | } 178 | 179 | const auto [componentName, subComponentPath] = splitComponentPath(aComponentPath); 180 | 181 | const Component& component = accessComponentWithName(componentName); 182 | 183 | return subComponentPath.isEmpty() ? component : component.accessComponentAt(subComponentPath); 184 | } 185 | 186 | Pair splitComponentPath(const String& aComponentPath) 187 | { 188 | using ostk::core::type::Index; 189 | 190 | if (aComponentPath.getFirst() == '/') 191 | { 192 | return splitComponentPath(aComponentPath.getTail(aComponentPath.getLength() - 1)); 193 | } 194 | 195 | const Index tokenPosition = aComponentPath.find('/'); 196 | 197 | if (tokenPosition == std::string::npos) 198 | { 199 | return {aComponentPath, ""}; 200 | } 201 | 202 | if ((aComponentPath.getLength() - tokenPosition) == 1) 203 | { 204 | return {aComponentPath.getHead(tokenPosition), ""}; 205 | } 206 | 207 | return { 208 | aComponentPath.getHead(tokenPosition), 209 | aComponentPath.getSubstring(tokenPosition + 1, aComponentPath.getLength() - tokenPosition - 1) 210 | }; 211 | } 212 | 213 | } // namespace utility 214 | } // namespace simulation 215 | } // namespace ostk 216 | -------------------------------------------------------------------------------- /src/OpenSpaceToolkit/Simulation/Utility/Identifier.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace ostk 9 | { 10 | namespace simulation 11 | { 12 | namespace utility 13 | { 14 | 15 | String generateId() 16 | { 17 | boost::uuids::random_generator generator; 18 | return boost::uuids::to_string(generator()); 19 | } 20 | 21 | } // namespace utility 22 | } // namespace simulation 23 | } // namespace ostk 24 | -------------------------------------------------------------------------------- /test/Global.test.hpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | namespace ostk 6 | { 7 | namespace simulation 8 | { 9 | namespace test 10 | { 11 | namespace global 12 | { 13 | 14 | extern std::string someGlobalString; 15 | 16 | } 17 | } // namespace test 18 | } // namespace simulation 19 | } // namespace ostk 20 | -------------------------------------------------------------------------------- /test/Main.test.cxx: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | int main(int argc, char** argv) 6 | { 7 | ::testing::InitGoogleTest(&argc, argv); 8 | 9 | ::testing::AddGlobalTestEnvironment(new ostk::simulation::test::Environment(argc >= 2 ? argv[1] : "")); 10 | 11 | return RUN_ALL_TESTS(); 12 | } 13 | -------------------------------------------------------------------------------- /test/OpenSpaceToolkit/Simulation/Component/State.test.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | #include 6 | 7 | // ... 8 | -------------------------------------------------------------------------------- /test/OpenSpaceToolkit/Simulation/Satellite.test.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | using ostk::core::container::Array; 18 | using ostk::core::type::Shared; 19 | using ostk::core::type::String; 20 | 21 | using ostk::physics::environment::object::celestial::Earth; 22 | using ostk::physics::time::Instant; 23 | using ostk::physics::time::Time; 24 | using ostk::physics::unit::Length; 25 | 26 | using ostk::astrodynamics::flight::Profile; 27 | using ostk::astrodynamics::trajectory::Orbit; 28 | 29 | using ostk::simulation::Component; 30 | using ostk::simulation::component::Geometry; 31 | using ostk::simulation::component::GeometryConfiguration; 32 | using ostk::simulation::ComponentConfiguration; 33 | using ostk::simulation::Satellite; 34 | using ostk::simulation::SatelliteConfiguration; 35 | 36 | class OpenSpaceToolkit_Simulation_Satellite : public ::testing::Test 37 | { 38 | protected: 39 | void SetUp() override 40 | { 41 | const Orbit orbit = Orbit::SunSynchronous( 42 | Instant::J2000(), Length::Kilometers(7000.0), Time::Noon(), std::make_shared(Earth::Default()) 43 | ); 44 | 45 | profile_ = Profile::LocalOrbitalFramePointing(orbit, Orbit::FrameType::VVLH); 46 | 47 | this->satellite_ = Satellite( 48 | "87da0b5f-9f65-4c5c-a660-bd254742960b", 49 | "LoftSat-1", 50 | {"a", "b"}, 51 | Array>::Empty(), 52 | Array>::Empty(), 53 | nullptr, 54 | std::make_shared(profile_), 55 | nullptr 56 | ); 57 | } 58 | 59 | Profile profile_ = Profile::Undefined(); 60 | Satellite satellite_ = Satellite::Undefined(); 61 | }; 62 | 63 | TEST_F(OpenSpaceToolkit_Simulation_Satellite, IsDefined) 64 | { 65 | { 66 | EXPECT_TRUE(satellite_.isDefined()); 67 | } 68 | 69 | { 70 | EXPECT_FALSE(Satellite::Undefined().isDefined()); 71 | } 72 | } 73 | 74 | TEST_F(OpenSpaceToolkit_Simulation_Satellite, getId) 75 | { 76 | { 77 | EXPECT_EQ(satellite_.getId(), "87da0b5f-9f65-4c5c-a660-bd254742960b"); 78 | } 79 | 80 | { 81 | EXPECT_ANY_THROW(Satellite::Undefined().getId()); 82 | } 83 | } 84 | 85 | TEST_F(OpenSpaceToolkit_Simulation_Satellite, getName) 86 | { 87 | { 88 | EXPECT_EQ(satellite_.getName(), "LoftSat-1"); 89 | } 90 | 91 | { 92 | EXPECT_ANY_THROW(Satellite::Undefined().getName()); 93 | } 94 | } 95 | 96 | TEST_F(OpenSpaceToolkit_Simulation_Satellite, Undefined) 97 | { 98 | { 99 | EXPECT_FALSE(Satellite::Undefined().isDefined()); 100 | } 101 | } 102 | 103 | TEST_F(OpenSpaceToolkit_Simulation_Satellite, Configure) 104 | { 105 | const SatelliteConfiguration satelliteConfiguration = { 106 | "87da0b5f-9f65-4c5c-a660-bd254742960b", 107 | "LoftSat-1", 108 | profile_, 109 | Array::Empty(), 110 | {"a", "b"}, 111 | Array::Empty(), 112 | }; 113 | 114 | const Shared satellite = Satellite::Configure(satelliteConfiguration, nullptr); 115 | 116 | EXPECT_TRUE(satellite->isDefined()); 117 | } 118 | 119 | TEST_F(OpenSpaceToolkit_Simulation_Satellite, AccessProfile) 120 | { 121 | { 122 | EXPECT_NO_THROW(satellite_.accessProfile()->isDefined()); 123 | } 124 | 125 | { 126 | EXPECT_ANY_THROW(Satellite::Undefined().accessProfile()); 127 | } 128 | } 129 | 130 | // TEST_F (OpenSpaceToolkit_Simulation_Satellite, GenerateFrame) 131 | -------------------------------------------------------------------------------- /test/OpenSpaceToolkit/Simulation/Simulator.test.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | #include 19 | 20 | using ostk::core::container::Array; 21 | using ostk::core::container::Map; 22 | using ostk::core::type::Shared; 23 | using ostk::core::type::String; 24 | 25 | using ostk::mathematics::geometry::d3::object::Composite; 26 | using ostk::mathematics::geometry::d3::object::LineString; 27 | using ostk::mathematics::geometry::d3::object::Point; 28 | using ostk::mathematics::geometry::d3::object::Polygon; 29 | using ostk::mathematics::geometry::d3::object::Pyramid; 30 | using ostk::mathematics::geometry::d3::transformation::rotation::Quaternion; 31 | 32 | using ostk::physics::coordinate::Frame; 33 | using ostk::physics::Environment; 34 | using ostk::physics::time::DateTime; 35 | using ostk::physics::time::Duration; 36 | using ostk::physics::time::Instant; 37 | using ostk::physics::time::Scale; 38 | using ostk::physics::time::Time; 39 | using ostk::physics::unit::Length; 40 | 41 | using ostk::astrodynamics::flight::Profile; 42 | using ostk::astrodynamics::trajectory::Orbit; 43 | 44 | using ostk::simulation::Component; 45 | using ostk::simulation::component::Geometry; 46 | using ostk::simulation::component::State; 47 | using ostk::simulation::Satellite; 48 | using ostk::simulation::SatelliteConfiguration; 49 | using ostk::simulation::Simulator; 50 | using ostk::simulation::SimulatorConfiguration; 51 | 52 | class OpenSpaceToolkit_Simulation_Simulator : public ::testing::Test 53 | { 54 | protected: 55 | const Environment environment_ = Environment::Default(); 56 | 57 | const String satelliteName_ = "LoftSat-1"; 58 | 59 | const Orbit orbit_ = Orbit::SunSynchronous( 60 | Instant::DateTime(DateTime(2020, 1, 1, 0, 0, 0), Scale::UTC), // Epoch 61 | Length::Kilometers(500.0), // Altitude 62 | Time(14, 0, 0), // LTAN 63 | environment_.accessCelestialObjectWithName("Earth") // Celestial object 64 | ); 65 | 66 | const Shared simulatorSPtr_ = Simulator::Configure( 67 | {environment_, 68 | {{"1", 69 | satelliteName_, 70 | Profile::LocalOrbitalFramePointing(orbit_, Orbit::FrameType::VVLH), 71 | {{"2", 72 | "Camera", 73 | Component::Type::Sensor, 74 | {"tag-a", "tag-b"}, 75 | Quaternion::Unit(), 76 | {{"FOV", 77 | Composite {Pyramid { 78 | Polygon { 79 | {{{-0.1, -1.0}, {+0.1, -1.0}, {+0.1, +1.0}, {-0.1, +1.0}}}, 80 | Point {0.0, 0.0, 1.0}, 81 | {1.0, 0.0, 0.0}, 82 | {0.0, 1.0, 0.0} 83 | }, 84 | Point {0.0, 0.0, 0.0} 85 | }}}}}}}}} 86 | ); 87 | }; 88 | 89 | TEST_F(OpenSpaceToolkit_Simulation_Simulator, Constructor) 90 | { 91 | { 92 | const Array> satellites = Array>::Empty(); 93 | 94 | EXPECT_NO_THROW(Simulator simulator = Simulator(environment_, satellites)); 95 | } 96 | } 97 | 98 | TEST_F(OpenSpaceToolkit_Simulation_Simulator, StreamOperator) 99 | { 100 | { 101 | testing::internal::CaptureStdout(); 102 | 103 | EXPECT_NO_THROW(std::cout << *simulatorSPtr_ << std::endl); 104 | 105 | EXPECT_FALSE(testing::internal::GetCapturedStdout().empty()); 106 | } 107 | } 108 | 109 | TEST_F(OpenSpaceToolkit_Simulation_Simulator, IsDefined) 110 | { 111 | { 112 | EXPECT_TRUE(simulatorSPtr_->isDefined()); 113 | } 114 | } 115 | 116 | TEST_F(OpenSpaceToolkit_Simulation_Simulator, HasSatelliteWithName) 117 | { 118 | { 119 | EXPECT_TRUE(simulatorSPtr_->hasSatelliteWithName(satelliteName_)); 120 | } 121 | } 122 | 123 | TEST_F(OpenSpaceToolkit_Simulation_Simulator, AccessEnvironment) 124 | { 125 | { 126 | EXPECT_NO_THROW(simulatorSPtr_->accessEnvironment()); 127 | } 128 | } 129 | 130 | TEST_F(OpenSpaceToolkit_Simulation_Simulator, AccessSatelliteMap) 131 | { 132 | { 133 | EXPECT_THROW(Simulator::Undefined().accessSatelliteMap(), ostk::core::error::runtime::Undefined); 134 | } 135 | 136 | { 137 | EXPECT_EQ(simulatorSPtr_->accessSatelliteMap().size(), 1); 138 | } 139 | } 140 | 141 | TEST_F(OpenSpaceToolkit_Simulation_Simulator, AccessSatelliteWithName) 142 | { 143 | { 144 | EXPECT_EQ(satelliteName_, simulatorSPtr_->accessSatelliteWithName(satelliteName_).getName()); 145 | } 146 | } 147 | 148 | TEST_F(OpenSpaceToolkit_Simulation_Simulator, GetInstant) 149 | { 150 | { 151 | const Instant instant = Instant::DateTime(DateTime(2020, 1, 1, 0, 0, 0), Scale::UTC); 152 | 153 | simulatorSPtr_->setInstant(instant); 154 | 155 | EXPECT_EQ(instant, simulatorSPtr_->getInstant()); 156 | } 157 | } 158 | 159 | TEST_F(OpenSpaceToolkit_Simulation_Simulator, SetInstant) 160 | { 161 | { 162 | const Instant instant = Instant::DateTime(DateTime(2020, 1, 1, 0, 0, 0), Scale::UTC); 163 | 164 | simulatorSPtr_->setInstant(instant); 165 | 166 | EXPECT_EQ(instant, simulatorSPtr_->getInstant()); 167 | } 168 | } 169 | 170 | TEST_F(OpenSpaceToolkit_Simulation_Simulator, StepForward) 171 | { 172 | { 173 | const Instant instant = Instant::DateTime(DateTime(2020, 1, 1, 0, 0, 0), Scale::UTC); 174 | 175 | simulatorSPtr_->setInstant(instant); 176 | 177 | const Duration duration = Duration::Seconds(60.0); 178 | 179 | simulatorSPtr_->stepForward(duration); 180 | 181 | EXPECT_EQ(instant + duration, simulatorSPtr_->getInstant()); 182 | } 183 | } 184 | 185 | TEST_F(OpenSpaceToolkit_Simulation_Simulator, Test_1) 186 | { 187 | { 188 | const Environment environment = Environment::Default(); 189 | 190 | const Orbit orbit = Orbit::SunSynchronous( 191 | Instant::DateTime(DateTime(2020, 1, 1, 0, 0, 0), Scale::UTC), // Epoch 192 | Length::Kilometers(500.0), // Altitude 193 | Time(14, 0, 0), // LTAN 194 | environment.accessCelestialObjectWithName("Earth") // Celestial object 195 | ); 196 | 197 | Shared simulatorSPtr = Simulator::Configure( 198 | {environment, 199 | {{"1", 200 | "LoftSat-1", 201 | Profile::LocalOrbitalFramePointing(orbit, Orbit::FrameType::VVLH), 202 | {{"2", 203 | "Camera", 204 | Component::Type::Sensor, 205 | {"tag-a", "tag-b"}, 206 | Quaternion::Unit(), 207 | {{"FOV", 208 | Composite {Pyramid { 209 | Polygon { 210 | {{{-0.1, -1.0}, {+0.1, -1.0}, {+0.1, +1.0}, {-0.1, +1.0}}}, 211 | Point {0.0, 0.0, 1.0}, 212 | {1.0, 0.0, 0.0}, 213 | {0.0, 1.0, 0.0} 214 | }, 215 | Point {0.0, 0.0, 0.0} 216 | }}}}}}}}} 217 | ); 218 | 219 | const Instant instant = Instant::DateTime(DateTime(2020, 1, 1, 0, 0, 0), Scale::UTC); 220 | 221 | simulatorSPtr->setInstant(instant); 222 | 223 | const auto camera = simulatorSPtr->accessSatelliteWithName("LoftSat-1").accessComponentWithName("Camera"); 224 | 225 | const auto cameraGeometry = camera.accessGeometryWithName("FOV"); 226 | const auto earthGeometry = environment.accessCelestialObjectWithName("Earth")->accessGeometry(); 227 | 228 | EXPECT_TRUE(cameraGeometry.intersects(earthGeometry)); 229 | 230 | EXPECT_EQ(2, cameraGeometry.intersectionWith(earthGeometry).accessComposite().getObjectCount()); 231 | EXPECT_TRUE(cameraGeometry.intersectionWith(earthGeometry).accessComposite().accessObjectAt(0).is() 232 | ); 233 | EXPECT_TRUE(cameraGeometry.intersectionWith(earthGeometry).accessComposite().accessObjectAt(1).is() 234 | ); 235 | } 236 | } 237 | 238 | TEST_F(OpenSpaceToolkit_Simulation_Simulator, Undefined) 239 | { 240 | { 241 | EXPECT_FALSE(Simulator::Undefined().isDefined()); 242 | } 243 | } 244 | 245 | TEST_F(OpenSpaceToolkit_Simulation_Simulator, Configure) 246 | { 247 | { 248 | const Array satelliteConfiguraitons = Array::Empty(); 249 | 250 | EXPECT_NO_THROW(Simulator::Configure(SimulatorConfiguration {environment_, satelliteConfiguraitons})); 251 | } 252 | } 253 | -------------------------------------------------------------------------------- /test/OpenSpaceToolkit/Simulation/Utility/Identifier.test.cpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | #include 6 | 7 | TEST(OpenSpaceToolkit_Simulation_Utilities_Identifier, GenerateId) 8 | { 9 | using ostk::core::type::String; 10 | 11 | using ostk::simulation::utility::generateId; 12 | 13 | { 14 | const String id_1 = generateId(); 15 | const String id_2 = generateId(); 16 | 17 | EXPECT_EQ(id_1.getLength(), 36); 18 | EXPECT_EQ(id_2.getLength(), 36); 19 | 20 | EXPECT_TRUE(id_1 != id_2); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/Setup.test.hpp: -------------------------------------------------------------------------------- 1 | /// Apache License 2.0 2 | 3 | #include 4 | 5 | namespace ostk 6 | { 7 | namespace simulation 8 | { 9 | namespace test 10 | { 11 | 12 | namespace global 13 | { 14 | 15 | std::string someGlobalString; 16 | 17 | } 18 | 19 | class Environment : public testing::Environment 20 | { 21 | public: 22 | Environment(const std::string& aCommandLineArg) 23 | : commandLineArg_(aCommandLineArg) 24 | { 25 | if (commandLineArg_ != "") 26 | { 27 | global::someGlobalString = commandLineArg_; 28 | } 29 | else 30 | { 31 | global::someGlobalString = "World"; 32 | } 33 | } 34 | 35 | virtual ~Environment() {} 36 | 37 | virtual void SetUp() {} 38 | 39 | virtual void TearDown() {} 40 | 41 | private: 42 | std::string commandLineArg_; 43 | }; 44 | 45 | } // namespace test 46 | } // namespace simulation 47 | } // namespace ostk 48 | -------------------------------------------------------------------------------- /thirdparty/clang/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Google 4 | AccessModifierOffset: -1 5 | AlignAfterOpenBracket: BlockIndent 6 | AlignConsecutiveMacros: false 7 | AlignConsecutiveAssignments: false 8 | AlignConsecutiveDeclarations: false 9 | AlignEscapedNewlines: Left 10 | AlignOperands: AlignAfterOperator 11 | AlignTrailingComments: true 12 | AllowAllArgumentsOnNextLine: true 13 | AllowAllConstructorInitializersOnNextLine: true 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AllowShortBlocksOnASingleLine: Never 16 | AllowShortCaseLabelsOnASingleLine: false 17 | AllowShortFunctionsOnASingleLine: Empty 18 | AllowShortLambdasOnASingleLine: false 19 | AllowShortIfStatementsOnASingleLine: Never 20 | AllowShortLoopsOnASingleLine: false 21 | AlwaysBreakAfterDefinitionReturnType: None 22 | AlwaysBreakAfterReturnType: None 23 | AlwaysBreakBeforeMultilineStrings: true 24 | AlwaysBreakTemplateDeclarations: Yes 25 | BinPackArguments: false 26 | BinPackParameters: false 27 | BraceWrapping: 28 | AfterCaseLabel: true 29 | AfterClass: true 30 | AfterControlStatement: true 31 | AfterEnum: true 32 | AfterFunction: true 33 | AfterNamespace: true 34 | AfterObjCDeclaration: true 35 | AfterStruct: true 36 | AfterUnion: true 37 | AfterExternBlock: true 38 | BeforeCatch: true 39 | BeforeElse: true 40 | IndentBraces: false 41 | SplitEmptyFunction: false 42 | SplitEmptyRecord: false 43 | SplitEmptyNamespace: false 44 | BreakBeforeBinaryOperators: None 45 | BreakBeforeBraces: Allman 46 | BreakBeforeInheritanceComma: false 47 | BreakInheritanceList: BeforeColon 48 | BreakBeforeTernaryOperators: true 49 | BreakConstructorInitializersBeforeComma: false 50 | BreakConstructorInitializers: BeforeColon 51 | BreakAfterJavaFieldAnnotations: false 52 | BreakStringLiterals: true 53 | ColumnLimit: 120 54 | CommentPragmas: '^ IWYU pragma:' 55 | CompactNamespaces: false 56 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 57 | ConstructorInitializerIndentWidth: 4 58 | ContinuationIndentWidth: 4 59 | Cpp11BracedListStyle: true 60 | DeriveLineEnding: true 61 | DerivePointerAlignment: true 62 | DisableFormat: false 63 | ExperimentalAutoDetectBinPacking: false 64 | FixNamespaceComments: true 65 | ForEachMacros: 66 | - foreach 67 | - Q_FOREACH 68 | - BOOST_FOREACH 69 | IncludeBlocks: Regroup 70 | IncludeCategories: 71 | # system includes, e.g. or or 72 | - Regex: '^<((linux|sys|net|netinet|arpa|crypt|rpc)\/)?([A-Za-z0-9_-]+\/?)(.h(pp)?)?>' 73 | Priority: 0 74 | SortPriority: 0 75 | # local project (or private) includes, e.g. "Access.hpp" 76 | - Regex: '^"[a-zA-Z0-9_-]+(\/[a-zA-Z0-9_-]+)*\.h(pp)?"' 77 | Priority: 2 78 | SortPriority: 2 79 | - Regex: '^<.*OpenSpaceToolKit\/Core.*\.hpp>' 80 | Priority: 3 81 | SortPriority: 3 82 | - Regex: '^<.*OpenSpaceToolKit\/IO.*\.hpp>' 83 | Priority: 4 84 | SortPriority: 4 85 | - Regex: '^<.*OpenSpaceToolKit\/Mathematics.*\.hpp>' 86 | Priority: 5 87 | SortPriority: 5 88 | - Regex: '^<.*OpenSpaceToolKit\/Physics.*\.hpp>' 89 | Priority: 6 90 | SortPriority: 6 91 | - Regex: '^<.*OpenSpaceToolKit\/Astrodynamics.*\.hpp>' 92 | Priority: 7 93 | SortPriority: 7 94 | # third party headers, e.g. or 95 | - Regex: '^<([a-zA-Z0-9_-]+\/)+[a-zA-Z0-9_-]+\.h(pp)?>' 96 | Priority: 1 97 | SortPriority: 1 98 | IncludeIsMainRegex: '' 99 | IncludeIsMainSourceRegex: '' 100 | IndentAccessModifiers: false 101 | IndentCaseLabels: true 102 | IndentCaseBlocks: false 103 | IndentGotoLabels: true 104 | IndentPPDirectives: None 105 | IndentWidth: 4 106 | IndentWrappedFunctionNames: false 107 | InsertNewlineAtEOF: true 108 | InsertTrailingCommas: Wrapped 109 | JavaScriptQuotes: Leave 110 | JavaScriptWrapImports: true 111 | KeepEmptyLinesAtTheStartOfBlocks: false 112 | MacroBlockBegin: '' 113 | MacroBlockEnd: '' 114 | MaxEmptyLinesToKeep: 1 115 | NamespaceIndentation: None 116 | ObjCBinPackProtocolList: Never 117 | ObjCBlockIndentWidth: 4 118 | ObjCSpaceAfterProperty: false 119 | ObjCSpaceBeforeProtocolList: true 120 | PackConstructorInitializers: Never 121 | PenaltyBreakAssignment: 2 122 | PenaltyBreakBeforeFirstCallParameter: 1 123 | PenaltyBreakComment: 300 124 | PenaltyBreakFirstLessLess: 120 125 | PenaltyBreakString: 1000 126 | PenaltyBreakTemplateDeclaration: 10 127 | PenaltyExcessCharacter: 1000000 128 | PenaltyReturnTypeOnItsOwnLine: 200 129 | PointerAlignment: Left 130 | RawStringFormats: 131 | - Language: Cpp 132 | Delimiters: 133 | - cc 134 | - CC 135 | - cpp 136 | - Cpp 137 | - CPP 138 | - 'c++' 139 | - 'C++' 140 | EnclosingFunctions: 141 | - ParseTextOrDie 142 | CanonicalDelimiter: '' 143 | BasedOnStyle: google 144 | ReferenceAlignment: Pointer 145 | ReflowComments: true 146 | SeparateDefinitionBlocks: Always 147 | SortIncludes: true 148 | SortUsingDeclarations: Lexicographic 149 | SpaceAfterCStyleCast: false 150 | SpaceAfterLogicalNot: false 151 | SpaceAfterTemplateKeyword: true 152 | SpaceBeforeAssignmentOperators: true 153 | SpaceBeforeCpp11BracedList: true 154 | SpaceBeforeCtorInitializerColon: true 155 | SpaceBeforeInheritanceColon: true 156 | SpaceBeforeParens: ControlStatements 157 | SpaceBeforeParensOptions: 158 | AfterControlStatements: true 159 | AfterForeachMacros: true 160 | AfterFunctionDefinitionName: false 161 | AfterFunctionDeclarationName: false 162 | AfterIfMacros: true 163 | AfterOverloadedOperator: false 164 | BeforeNonEmptyParentheses: false 165 | SpaceAroundPointerQualifiers: Default 166 | SpaceBeforeRangeBasedForLoopColon: true 167 | SpaceInEmptyBlock: false 168 | SpaceInEmptyParentheses: false 169 | SpacesBeforeTrailingComments: 2 170 | SpacesInAngles: false 171 | SpacesInConditionalStatement: false 172 | SpacesInContainerLiterals: true 173 | SpacesInCStyleCastParentheses: false 174 | SpacesInLineCommentPrefix: 175 | Minimum: 1 176 | Maximum: -1 177 | SpacesInParentheses: false 178 | SpacesInSquareBrackets: false 179 | SpaceBeforeSquareBrackets: false 180 | BitFieldColonSpacing: Both 181 | Standard: Auto 182 | TabWidth: 8 183 | UseCRLF: false 184 | UseTab: Never 185 | ... 186 | -------------------------------------------------------------------------------- /thirdparty/doxygen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED (VERSION "2.8.8") 2 | 3 | CMAKE_POLICY (SET "CMP0048" NEW) 4 | 5 | PROJECT ("doxygen_builder" VERSION "") 6 | 7 | INCLUDE (ExternalProject) 8 | 9 | ## ============================================================================== 10 | ## 11 | ## Package information 12 | ## 13 | ## ============================================================================== 14 | 15 | set (DOXYGEN_VERSION "1.8.2" ) 16 | set (DOXYGEN_SOURCE_ARCHIVE "doxygen-${DOXYGEN_VERSION}.src.tar.gz" ) 17 | set (DOXYGEN_URL "ftp://ftp.stack.nl/pub/users/dimitri/${DOXYGEN_SOURCE_ARCHIVE}" ) 18 | set (DOXYGEN_SVN "https://doxygen.svn.sourceforge.net/svnroot/doxygen/trunk" ) 19 | set (DOXYGEN_GIT "https://github.com/doxygen/doxygen.git" ) 20 | 21 | ## ============================================================================== 22 | ## 23 | ## Options 24 | ## 25 | ## ============================================================================== 26 | 27 | option (DOXYGEN_FORCE_BUILD "Force build and installation of package?" NO ) 28 | option (DOXYGEN_FROM_REPOS "Install package from repository?" YES ) 29 | 30 | ## ============================================================================== 31 | ## 32 | ## System inspection 33 | ## 34 | ## ============================================================================== 35 | 36 | ## Check if Doxygen is available 37 | 38 | if (NOT DOXYGEN_EXECUTABLE) 39 | find_package ("Doxygen" QUIET) 40 | endif (NOT DOXYGEN_EXECUTABLE) 41 | 42 | ## Check if Doxygen is available in a recent enough version 43 | 44 | ## Extract Doxygen version number - this is not done by the standard module 45 | if (DOXYGEN_EXECUTABLE) 46 | 47 | message (STATUS "Checking whether Doxygen version is ok") 48 | 49 | execute_process( 50 | COMMAND ${DOXYGEN_EXECUTABLE} --version 51 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 52 | RESULT_VARIABLE DOXYGEN_RESULT_VARIABLE 53 | OUTPUT_VARIABLE DOXYGEN_VERSION 54 | ERROR_VARIABLE DOXYGEN_ERROR_VARIABLE 55 | OUTPUT_STRIP_TRAILING_WHITESPACE 56 | ) 57 | 58 | if (DOXYGEN_VERSION) 59 | ## Convert string to list of numbers 60 | string (REGEX REPLACE "\\." ";" DOXYGEN_VERSION_LIST ${DOXYGEN_VERSION}) 61 | ## Retrieve individual elements in the list 62 | list(GET DOXYGEN_VERSION_LIST 0 DOXYGEN_VERSION_MAJOR) 63 | list(GET DOXYGEN_VERSION_LIST 1 DOXYGEN_VERSION_MINOR) 64 | list(GET DOXYGEN_VERSION_LIST 2 DOXYGEN_VERSION_PATCH) 65 | endif (DOXYGEN_VERSION) 66 | 67 | math (EXPR DOXYGEN_VERSION_MAJOR "${DOXYGEN_VERSION_MAJOR}*100") 68 | math (EXPR DOXYGEN_VERSION_MINOR "${DOXYGEN_VERSION_MINOR}*100") 69 | math (EXPR DOXYGEN_VERSION_PATCH "${DOXYGEN_VERSION_PATCH}*100") 70 | 71 | set (DOXYGEN_VERSION_STRING "${DOXYGEN_VERSION_MAJOR}${DOXYGEN_VERSION_MINOR}${DOXYGEN_VERSION_PATCH}") 72 | 73 | if (${DOXYGEN_VERSION_STRING} LESS ${REQUIRED_VERSION_DOXYGEN}) 74 | set (DOXYGEN_FOUND FALSE) 75 | message (STATUS "Checking whether Doxygen version is ok - no") 76 | else () 77 | message (STATUS "Checking whether Doxygen version is ok - yes") 78 | endif() 79 | 80 | endif (DOXYGEN_EXECUTABLE) 81 | 82 | ## ============================================================================== 83 | ## 84 | ## Build instructions 85 | ## 86 | ## ============================================================================== 87 | 88 | if (DOXYGEN_FROM_REPOS) 89 | set (DOXYGEN_FORCE_BUILD TRUE) 90 | endif (DOXYGEN_FROM_REPOS) 91 | 92 | if (NOT DOXYGEN_FOUND OR DOXYGEN_FORCE_BUILD) 93 | 94 | ## Locate source file to build from 95 | 96 | find_file (DOXYGEN_SOURCE ${DOXYGEN_SOURCE_ARCHIVE} 97 | PATHS ${CMAKE_CURRENT_SOURCE_DIR} 98 | ) 99 | 100 | if (NOT DOXYGEN_SOURCE) 101 | set (DOXYGEN_SOURCE ${DOXYGEN_URL}) 102 | endif (NOT DOXYGEN_SOURCE) 103 | 104 | ## Build package from source 105 | 106 | if (DOXYGEN_FROM_REPOS) 107 | 108 | ExternalProject_Add (doxygen 109 | GIT_REPOSITORY ${DOXYGEN_GIT} 110 | PREFIX ${CMAKE_CURRENT_BINARY_DIR} 111 | DOWNLOAD_DIR download 112 | SOURCE_DIR source 113 | CMAKE_ARGS 114 | BUILD_IN_SOURCE 1 115 | INSTALL_COMMAND "" 116 | ) 117 | 118 | else (DOXYGEN_FROM_REPOS) 119 | 120 | ExternalProject_Add (doxygen 121 | PREFIX ${CMAKE_CURRENT_BINARY_DIR} 122 | DOWNLOAD_DIR download 123 | SOURCE_DIR source 124 | URL ${DOXYGEN_SOURCE} 125 | BUILD_IN_SOURCE 1 126 | CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/source/configure --prefix ${CMAKE_INSTALL_PREFIX} 127 | INSTALL_COMMAND ${PORT_INSTALL_COMMAND} make install 128 | ) 129 | 130 | endif (DOXYGEN_FROM_REPOS) 131 | 132 | ## Update top-level project configuration 133 | # ExternalProject_Add_Step (doxygen update_configuration 134 | # COMMAND ${CMAKE_COMMAND} -E remove CMakeCache.txt 135 | # COMMAND ${CMAKE_COMMAND} .. 136 | # COMMENT "Updating top-level configuration ..." 137 | # DEPENDEES install 138 | # WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 139 | # ) 140 | 141 | else (NOT DOXYGEN_FOUND OR DOXYGEN_FORCE_BUILD) 142 | 143 | add_custom_target (doxygen 144 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 145 | COMMENT "[doxygen] Found system-wide installation; skipping rebuild!" 146 | ) 147 | 148 | endif (NOT DOXYGEN_FOUND OR DOXYGEN_FORCE_BUILD) -------------------------------------------------------------------------------- /thirdparty/gtest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION "2.8.8") 2 | 3 | CMAKE_POLICY (SET "CMP0048" NEW) 4 | 5 | PROJECT ("gtest_builder" VERSION "" LANGUAGES "C" "CXX") 6 | 7 | INCLUDE (ExternalProject) 8 | 9 | SET (GTEST_FORCE_SHARED_CRT ON) 10 | SET (GTEST_DISABLE_PTHREADS OFF) 11 | 12 | IF (MINGW) 13 | SET (GTEST_DISABLE_PTHREADS ON) 14 | ENDIF () 15 | 16 | EXTERNALPROJECT_ADD ("googletest" 17 | GIT_REPOSITORY "https://github.com/google/googletest.git" 18 | CMAKE_ARGS 19 | #-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs 20 | #-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs 21 | -DCMAKE_CXX_FLAGS=${MSVC_COMPILER_DEFS} 22 | -Dgtest_force_shared_crt=${GTEST_FORCE_SHARED_CRT} 23 | -Dgtest_disable_pthreads=${GTEST_DISABLE_PTHREADS} 24 | -DBUILD_GTEST=ON 25 | UPDATE_DISCONNECTED 1 26 | PREFIX "${CMAKE_CURRENT_BINARY_DIR}" 27 | # Disable install step 28 | INSTALL_COMMAND "" 29 | ) 30 | 31 | # Specify include dir 32 | 33 | EXTERNALPROJECT_GET_PROPERTY ("googletest" source_dir) 34 | SET (GTEST_INCLUDE_DIRS "${source_dir}/googletest/include" PARENT_SCOPE) 35 | 36 | # Specify MainTest's link libraries 37 | 38 | EXTERNALPROJECT_GET_PROPERTY ("googletest" binary_dir) 39 | SET (GTEST_LIBS_DIR "${binary_dir}/googlemock/gtest" PARENT_SCOPE) -------------------------------------------------------------------------------- /tools/cmake/DocumentationTargets.cmake: -------------------------------------------------------------------------------- 1 | # Michael Aaron Safyan (michaelsafyan@gmail.com). Copyright (C) 2009. Simplified BSD License. 2 | 3 | # 4 | # This CMake package creates a Doxygen documentation target. 5 | # 6 | 7 | FIND_PACKAGE (Doxygen) 8 | IF (DOXYGEN_FOUND) 9 | IF (EXISTS ${PROJECT_SOURCE_DIR}/Doxyfile) 10 | ADD_CUSTOM_TARGET( 11 | doxygen 12 | ${DOXYGEN_EXECUTABLE} Doxyfile 13 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 14 | COMMENT "Generating doxygen project documentation." VERBATIM 15 | ) 16 | ADD_CUSTOM_TARGET( 17 | documentation 18 | ${DOXYGEN_EXECUTABLE} Doxyfile 19 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 20 | COMMENT "Generating doxygen project documentation." VERBATIM 21 | ) 22 | ADD_CUSTOM_TARGET( 23 | docs 24 | ${DOXYGEN_EXECUTABLE} Doxyfile 25 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 26 | COMMENT "Generating doxygen project documentation." VERBATIM 27 | ) 28 | ELSE (EXISTS ${PROJECT_SOURCE_DIR}/Doxyfile) 29 | ADD_CUSTOM_TARGET(doxygen COMMENT "Doxyfile not found. Please generate a doxygen configuration file to use this target." VERBATIM) 30 | ADD_CUSTOM_TARGET(documentation COMMENT "Doxyfile not found. Please generate a doxygen configuration file to use this target." VERBATIM) 31 | ADD_CUSTOM_TARGET(docs COMMENT "Doxyfile not found. Please generate a doxygen configuration file to use this target." VERBATIM) 32 | ENDIF (EXISTS ${PROJECT_SOURCE_DIR}/Doxyfile) 33 | ELSE (DOXYGEN_FOUND) 34 | ADD_CUSTOM_TARGET(doxygen COMMENT "Doxygen not found. Please install doxygen to use this target." VERBATIM) 35 | ADD_CUSTOM_TARGET(documentation COMMENT "Doxygen not found. Please install doxygen to use this target." VERBATIM) 36 | ADD_CUSTOM_TARGET(docs COMMENT "Doxygen not found. Please install doxygen to use this target." VERBATIM) 37 | ENDIF (DOXYGEN_FOUND) 38 | -------------------------------------------------------------------------------- /tools/cmake/FindNLopt.cmake: -------------------------------------------------------------------------------- 1 | # Find NLopt 2 | 3 | # This sets the following variables: 4 | # NLopt_FOUND 5 | # NLopt_INCLUDE_DIRS 6 | # NLopt_LIBRARIES 7 | # NLOPT_DEFINITIONS 8 | # NLOPT_VERSION 9 | 10 | find_package(PkgConfig QUIET) 11 | 12 | # Check to see if pkgconfig is installed. 13 | pkg_check_modules(PC_NLopt nlopt QUIET) 14 | 15 | # Definitions 16 | set(NLopt_DEFINITIONS ${PC_NLopt_CFLAGS_OTHER}) 17 | 18 | # Include directories 19 | find_path(NLopt_INCLUDE_DIRS 20 | NAMES nlopt.h 21 | HINTS ${PC_NLopt_INCLUDEDIR} 22 | PATHS "${CMAKE_INSTALL_PREFIX}/include") 23 | 24 | # Libraries 25 | find_library(NLopt_LIBRARIES 26 | NAMES nlopt nlopt_cxx 27 | HINTS ${PC_NLopt_LIBDIR}) 28 | 29 | # Version 30 | set(NLopt_VERSION ${PC_NLopt_VERSION}) 31 | 32 | # Set (NAME)_FOUND if all the variables and the version are satisfied. 33 | include(FindPackageHandleStandardArgs) 34 | find_package_handle_standard_args(NLopt 35 | FAIL_MESSAGE DEFAULT_MSG 36 | REQUIRED_VARS NLopt_INCLUDE_DIRS NLopt_LIBRARIES 37 | VERSION_VAR NLopt_VERSION) 38 | -------------------------------------------------------------------------------- /tools/cmake/FindSGP4.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find SGP4 library 2 | 3 | # SGP4_FOUND - System has SGP4 library 4 | # SGP4_INCLUDE_DIRS - The SGP4 library include directories 5 | # SGP4_LIBRARIES - The libraries needed to use SGP4 library 6 | # SGP4_DEFINITIONS - Compiler switches required for using SGP4 library 7 | 8 | SET (SGP4_ROOT_DIR ${SGP4_ROOT_DIR} "/usr/local") 9 | 10 | FIND_PATH (SGP4_INCLUDE_DIR "sgp4/SGP4.h" PATHS ${SGP4_ROOT_DIR} PATH_SUFFIXES "include" NO_DEFAULT_PATH) 11 | 12 | FIND_LIBRARY (SGP4_LIBRARY NAMES "libsgp4.a" PATHS ${SGP4_ROOT_DIR} PATH_SUFFIXES "lib" NO_DEFAULT_PATH) 13 | 14 | SET (SGP4_LIBRARIES ${SGP4_LIBRARY}) 15 | SET (SGP4_INCLUDE_DIRS ${SGP4_INCLUDE_DIR}) 16 | 17 | # MESSAGE (STATUS "SGP4_ROOT_DIR = ${SGP4_ROOT_DIR}") 18 | # MESSAGE (STATUS "SGP4_INCLUDE_DIR = ${SGP4_INCLUDE_DIR}") 19 | # MESSAGE (STATUS "SGP4_LIBRARY = ${SGP4_LIBRARY}") 20 | 21 | INCLUDE (FindPackageHandleStandardArgs) 22 | FIND_PACKAGE_HANDLE_STANDARD_ARGS (SGP4 DEFAULT_MSG SGP4_LIBRARY SGP4_INCLUDE_DIR) 23 | 24 | MARK_AS_ADVANCED (SGP4_INCLUDE_DIR SGP4_LIBRARY) 25 | -------------------------------------------------------------------------------- /tools/cmake/GetGitRevisionDescription.cmake: -------------------------------------------------------------------------------- 1 | # - Returns a version string from Git 2 | # 3 | # These functions force a re-configure on each git commit so that you can 4 | # trust the values of the variables in your build system. 5 | # 6 | # get_git_head_revision( [ ...]) 7 | # 8 | # Returns the refspec and sha hash of the current head revision 9 | # 10 | # git_describe( [ ...]) 11 | # 12 | # Returns the results of git describe on the source tree, and adjusting 13 | # the output so that it tests false if an error occurs. 14 | # 15 | # git_get_exact_tag( [ ...]) 16 | # 17 | # Returns the results of git describe --exact-match on the source tree, 18 | # and adjusting the output so that it tests false if there was no exact 19 | # matching tag. 20 | # 21 | # Requires CMake 2.6 or newer (uses the 'function' command) 22 | # 23 | # Original Author: 24 | # 2009-2010 Ryan Pavlik 25 | # http://academic.cleardefinition.com 26 | # Iowa State University HCI Graduate Program/VRAC 27 | # 28 | # Copyright Iowa State University 2009-2010. 29 | # Distributed under the Boost Software License, Version 1.0. 30 | # (See accompanying file LICENSE_1_0.txt or copy at 31 | # http://www.boost.org/LICENSE_1_0.txt) 32 | 33 | if(__get_git_revision_description) 34 | return() 35 | endif() 36 | set(__get_git_revision_description YES) 37 | 38 | # We must run the following at "include" time, not at function call time, 39 | # to find the path to this module rather than the path to a calling list file 40 | get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) 41 | 42 | function(get_git_head_revision _refspecvar _hashvar) 43 | set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 44 | set(GIT_DIR "${GIT_PARENT_DIR}/.git") 45 | while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories 46 | set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") 47 | get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) 48 | if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) 49 | # We have reached the root directory, we are not in git 50 | set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) 51 | set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) 52 | return() 53 | endif() 54 | set(GIT_DIR "${GIT_PARENT_DIR}/.git") 55 | endwhile() 56 | # check if this is a submodule 57 | if(NOT IS_DIRECTORY ${GIT_DIR}) 58 | file(READ ${GIT_DIR} submodule) 59 | string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) 60 | get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) 61 | get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) 62 | endif() 63 | set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") 64 | if(NOT EXISTS "${GIT_DATA}") 65 | file(MAKE_DIRECTORY "${GIT_DATA}") 66 | endif() 67 | 68 | if(NOT EXISTS "${GIT_DIR}/HEAD") 69 | return() 70 | endif() 71 | set(HEAD_FILE "${GIT_DATA}/HEAD") 72 | configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) 73 | 74 | configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" 75 | "${GIT_DATA}/grabRef.cmake" 76 | @ONLY) 77 | include("${GIT_DATA}/grabRef.cmake") 78 | 79 | set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) 80 | set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) 81 | endfunction() 82 | 83 | function(git_describe _var) 84 | if(NOT GIT_FOUND) 85 | find_package(Git QUIET) 86 | endif() 87 | get_git_head_revision(refspec hash) 88 | if(NOT GIT_FOUND) 89 | set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) 90 | return() 91 | endif() 92 | if(NOT hash) 93 | set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) 94 | return() 95 | endif() 96 | 97 | # TODO sanitize 98 | #if((${ARGN}" MATCHES "&&") OR 99 | # (ARGN MATCHES "||") OR 100 | # (ARGN MATCHES "\\;")) 101 | # message("Please report the following error to the project!") 102 | # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") 103 | #endif() 104 | 105 | #message(STATUS "Arguments to execute_process: ${ARGN}") 106 | 107 | execute_process(COMMAND 108 | "${GIT_EXECUTABLE}" 109 | describe 110 | ${hash} 111 | ${ARGN} 112 | WORKING_DIRECTORY 113 | "${CMAKE_CURRENT_SOURCE_DIR}" 114 | RESULT_VARIABLE 115 | res 116 | OUTPUT_VARIABLE 117 | out 118 | ERROR_QUIET 119 | OUTPUT_STRIP_TRAILING_WHITESPACE) 120 | if(NOT res EQUAL 0) 121 | set(out "${out}-${res}-NOTFOUND") 122 | endif() 123 | 124 | set(${_var} "${out}" PARENT_SCOPE) 125 | endfunction() 126 | 127 | function(git_get_exact_tag _var) 128 | git_describe(out --exact-match ${ARGN}) 129 | set(${_var} "${out}" PARENT_SCOPE) 130 | endfunction() 131 | -------------------------------------------------------------------------------- /tools/cmake/GetGitRevisionDescription.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Internal file for GetGitRevisionDescription.cmake 3 | # 4 | # Requires CMake 2.6 or newer (uses the 'function' command) 5 | # 6 | # Original Author: 7 | # 2009-2010 Ryan Pavlik 8 | # http://academic.cleardefinition.com 9 | # Iowa State University HCI Graduate Program/VRAC 10 | # 11 | # Copyright Iowa State University 2009-2010. 12 | # Distributed under the Boost Software License, Version 1.0. 13 | # (See accompanying file LICENSE_1_0.txt or copy at 14 | # http://www.boost.org/LICENSE_1_0.txt) 15 | 16 | set(HEAD_HASH) 17 | 18 | file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) 19 | 20 | string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) 21 | if(HEAD_CONTENTS MATCHES "ref") 22 | # named branch 23 | string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") 24 | if(EXISTS "@GIT_DIR@/${HEAD_REF}") 25 | configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 26 | else() 27 | configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) 28 | file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) 29 | if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") 30 | set(HEAD_HASH "${CMAKE_MATCH_1}") 31 | endif() 32 | endif() 33 | else() 34 | # detached HEAD 35 | configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) 36 | endif() 37 | 38 | if(NOT HEAD_HASH) 39 | file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) 40 | string(STRIP "${HEAD_HASH}" HEAD_HASH) 41 | endif() 42 | -------------------------------------------------------------------------------- /tools/cmake/OpenSpaceToolkitSimulationConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | SET (OpenSpaceToolkitSimulation_ROOT_DIR ${OpenSpaceToolkitSimulation_ROOT_DIR} @CMAKE_INSTALL_PREFIX@) 4 | 5 | FIND_PATH (OpenSpaceToolkitSimulation_INCLUDE_DIR "OpenSpaceToolkit/Simulation/Satellite.hpp" PATHS ${OpenSpaceToolkitSimulation_ROOT_DIR} PATH_SUFFIXES "include" NO_DEFAULT_PATH) 6 | FIND_LIBRARY (OpenSpaceToolkitSimulation_LIBRARY NAMES "libopen-space-toolkit-simulation.so" PATHS ${OpenSpaceToolkitSimulation_ROOT_DIR} PATH_SUFFIXES "lib" NO_DEFAULT_PATH) 7 | 8 | # MESSAGE (STATUS "OpenSpaceToolkitSimulation_ROOT_DIR = ${OpenSpaceToolkitSimulation_ROOT_DIR}") 9 | # MESSAGE (STATUS "OpenSpaceToolkitSimulation_INCLUDE_DIR = ${OpenSpaceToolkitSimulation_INCLUDE_DIR}") 10 | # MESSAGE (STATUS "OpenSpaceToolkitSimulation_LIBRARY = ${OpenSpaceToolkitSimulation_LIBRARY}") 11 | # MESSAGE (STATUS "OpenSpaceToolkitSimulation_FIND_VERSION = ${OpenSpaceToolkitSimulation_FIND_VERSION}") 12 | 13 | IF (OpenSpaceToolkitSimulation_INCLUDE_DIR) 14 | 15 | SET (OpenSpaceToolkitSimulation_INCLUDE_DIRS ${OpenSpaceToolkitSimulation_INCLUDE_DIR} ${OpenSpaceToolkitSimulation_INCLUDE_DIR}/OpenSpaceToolkit/Simulation) 16 | SET (OpenSpaceToolkitSimulation_LIBRARIES ${OpenSpaceToolkitSimulation_LIBRARY}) 17 | 18 | SET (OpenSpaceToolkitSimulation_FOUND TRUE) 19 | 20 | ENDIF () 21 | -------------------------------------------------------------------------------- /tools/cmake/OpenSpaceToolkitSimulationConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | SET (PACKAGE_VERSION "@PROJECT_VERSION@") 4 | SET (PACKAGE_VERSION_MAJOR "@PROJECT_VERSION_MAJOR@") 5 | SET (PACKAGE_VERSION_MINOR "@PROJECT_VERSION_MINOR@") 6 | SET (PACKAGE_VERSION_PATCH "@PROJECT_VERSION_PATCH@") 7 | 8 | IF (NOT PACKAGE_FIND_NAME STREQUAL "@PROJECT_NAME@") 9 | 10 | # Check package name (in particular, because of the way cmake finds 11 | # package config files, the capitalization could easily be "wrong"). 12 | # This is necessary to ensure that the automatically generated 13 | # variables, e.g., _FOUND, are consistently spelled. 14 | 15 | SET (REASON "package = @PROJECT_NAME@, NOT ${PACKAGE_FIND_NAME}") 16 | SET (PACKAGE_VERSION_UNSUITABLE TRUE) 17 | 18 | ELSEIF (NOT (APPLE OR (NOT DEFINED CMAKE_SIZEOF_VOID_P) OR CMAKE_SIZEOF_VOID_P EQUAL @CMAKE_SIZEOF_VOID_P@)) 19 | 20 | # Reject if there's a 32-bit/64-bit mismatch (not necessary with Apple 21 | # since a multi-architecture library is built for that platform). 22 | 23 | SET (REASON "sizeof(*void) = @CMAKE_SIZEOF_VOID_P@") 24 | SET (PACKAGE_VERSION_UNSUITABLE TRUE) 25 | 26 | ELSEIF (MSVC AND NOT MSVC_VERSION STREQUAL "@MSVC_VERSION@") 27 | 28 | # Reject if there's a mismatch in MSVC compiler versions 29 | 30 | SET (REASON "_MSC_VER = @MSVC_VERSION@") 31 | SET (PACKAGE_VERSION_UNSUITABLE TRUE) 32 | 33 | ELSEIF (NOT CMAKE_CROSSCOMPILING STREQUAL "@CMAKE_CROSSCOMPILING@") 34 | 35 | # Reject if there's a mismatch in ${CMAKE_CROSSCOMPILING} 36 | 37 | SET (REASON "cross-compiling = @CMAKE_CROSSCOMPILING@") 38 | SET (PACKAGE_VERSION_UNSUITABLE TRUE) 39 | 40 | ELSEIF (CMAKE_CROSSCOMPILING AND NOT (CMAKE_SYSTEM_NAME STREQUAL "@CMAKE_SYSTEM_NAME@" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "@CMAKE_SYSTEM_PROCESSOR@")) 41 | 42 | # Reject if cross-compiling and there's a mismatch in the target system 43 | 44 | SET (REASON "target = @CMAKE_SYSTEM_NAME@-@CMAKE_SYSTEM_PROCESSOR@") 45 | SET (PACKAGE_VERSION_UNSUITABLE TRUE) 46 | 47 | ELSEIF (PACKAGE_FIND_VERSION) 48 | 49 | IF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) 50 | 51 | SET (PACKAGE_VERSION_EXACT TRUE) 52 | 53 | ELSEIF (PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION AND PACKAGE_FIND_VERSION_MAJOR EQUAL PACKAGE_VERSION_MAJOR) 54 | 55 | SET (PACKAGE_VERSION_COMPATIBLE TRUE) 56 | 57 | ENDIF () 58 | 59 | ENDIF () 60 | 61 | # If unsuitable, append the reason to the package version so that it's visible to the user. 62 | 63 | IF (PACKAGE_VERSION_UNSUITABLE) 64 | 65 | SET (PACKAGE_VERSION "${PACKAGE_VERSION} (${REASON})") 66 | 67 | ENDIF () 68 | -------------------------------------------------------------------------------- /tools/cmake/UninstallTarget.cmake.in: -------------------------------------------------------------------------------- 1 | # Apache License 2.0 2 | 3 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 5 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 6 | 7 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 8 | string(REGEX REPLACE "\n" ";" files "${files}") 9 | foreach(file ${files}) 10 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 11 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 12 | exec_program( 13 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 14 | OUTPUT_VARIABLE rm_out 15 | RETURN_VALUE rm_retval 16 | ) 17 | if(NOT "${rm_retval}" STREQUAL 0) 18 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 19 | endif(NOT "${rm_retval}" STREQUAL 0) 20 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 21 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 22 | endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 23 | endforeach(file) 24 | -------------------------------------------------------------------------------- /tools/development/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Apache License 2.0 4 | 5 | # Check input arguments 6 | 7 | if [[ -z ${docker_development_image_repository} ]]; then 8 | echo "Variable [docker_development_image_repository] is undefined." 9 | exit 1 10 | fi 11 | 12 | if [[ -z ${docker_image_version} ]]; then 13 | echo "Variable [docker_image_version] is undefined." 14 | exit 1 15 | fi 16 | 17 | project_directory=$(git rev-parse --show-toplevel) 18 | project_name="simulation" 19 | 20 | # Initialize variables 21 | 22 | options=() 23 | command="" 24 | deps="" 25 | 26 | # Setup linked mode 27 | 28 | if [[ ! -z ${1} ]] && [[ ${1} == "--link" ]]; then 29 | 30 | for link in "${@:2}" 31 | 32 | do 33 | 34 | # Extract last part of the path 35 | 36 | dep=$(basename ${link}) 37 | 38 | deps+=" ${dep}" 39 | 40 | # Log the linking step 41 | 42 | echo "Linking with ${dep} at ${link}..." 43 | 44 | # Open Space Toolkit ▸ Dep 45 | 46 | project_name=$(echo ${dep} | cut -d "-" -f 4) 47 | 48 | if [ ${project_name} = "io" ]; then 49 | project_name_capitalized="IO" 50 | else 51 | project_name_capitalized=${project_name^} 52 | fi 53 | 54 | options+=( "-v" ) 55 | options+=( "${link}:/mnt/${dep}:ro" ) 56 | 57 | command="${command} \ 58 | rm -rf /usr/local/include/OpenSpaceToolkit/${project_name_capitalized}; \ 59 | rm -f /usr/local/lib/lib${dep}.so*; \ 60 | cp -as /mnt/${dep}/include/OpenSpaceToolkit/${project_name_capitalized} /usr/local/include/OpenSpaceToolkit/${project_name_capitalized}; \ 61 | cp -as /mnt/${dep}/src/OpenSpaceToolkit/${project_name_capitalized}/* /usr/local/include/OpenSpaceToolkit/${project_name_capitalized}/; \ 62 | ln -s /mnt/${dep}/lib/lib${dep}.so /usr/local/lib/; \ 63 | ln -s /mnt/${dep}/lib/lib${dep}.so.* /usr/local/lib/; \ 64 | cp -as /mnt/${dep}/build/bindings/python/dist/* /usr/local/share;" 65 | 66 | done 67 | 68 | command="${command} /bin/bash" 69 | 70 | fi 71 | 72 | # Run Docker container 73 | 74 | docker run \ 75 | -it \ 76 | --rm \ 77 | --name=open-space-toolkit-${project_name}-dev \ 78 | "${options[@]}" \ 79 | --volume="${project_directory}:/app:delegated" \ 80 | --env="deps=${deps}" \ 81 | --workdir="/app/build" \ 82 | ${docker_development_image_repository}:${docker_image_version} \ 83 | /bin/bash -c "${command}" 84 | -------------------------------------------------------------------------------- /tutorials/cpp/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-space-collective/open-space-toolkit-simulation/081ae82a446a6c935201c3d739bce36edb14ae46/tutorials/cpp/.gitkeep -------------------------------------------------------------------------------- /tutorials/python/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-space-collective/open-space-toolkit-simulation/081ae82a446a6c935201c3d739bce36edb14ae46/tutorials/python/.gitkeep --------------------------------------------------------------------------------