rvd-railbench 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rvd_railbench-0.4.1/.clang-format +5 -0
- rvd_railbench-0.4.1/.clang-tidy +3 -0
- rvd_railbench-0.4.1/.gitattributes +3 -0
- rvd_railbench-0.4.1/.gitignore +19 -0
- rvd_railbench-0.4.1/CMakeLists.txt +155 -0
- rvd_railbench-0.4.1/CMakePresets.json +69 -0
- rvd_railbench-0.4.1/LICENSE +202 -0
- rvd_railbench-0.4.1/PKG-INFO +10 -0
- rvd_railbench-0.4.1/apps/rail_main.cpp +33 -0
- rvd_railbench-0.4.1/apps/rail_replay.cpp +17 -0
- rvd_railbench-0.4.1/configs/pfcr_dqp.ini +6 -0
- rvd_railbench-0.4.1/configs/rail.ini +18 -0
- rvd_railbench-0.4.1/configs/simulation.ini +13 -0
- rvd_railbench-0.4.1/include/pfcr/pfcr_controller.hpp +84 -0
- rvd_railbench-0.4.1/include/pfcr/pfcr_params.hpp +34 -0
- rvd_railbench-0.4.1/include/rvd/artifact.hpp +9 -0
- rvd_railbench-0.4.1/include/rvd/config.hpp +34 -0
- rvd_railbench-0.4.1/include/rvd/controller.hpp +28 -0
- rvd_railbench-0.4.1/include/rvd/experiment.hpp +31 -0
- rvd_railbench-0.4.1/include/rvd/frames.hpp +23 -0
- rvd_railbench-0.4.1/include/rvd/hardware.hpp +41 -0
- rvd_railbench-0.4.1/include/rvd/observations.hpp +41 -0
- rvd_railbench-0.4.1/include/rvd/pfcr_adapter.hpp +21 -0
- rvd_railbench-0.4.1/include/rvd/rail_io.hpp +52 -0
- rvd_railbench-0.4.1/include/rvd/runtime.hpp +38 -0
- rvd_railbench-0.4.1/include/rvd/safety.hpp +31 -0
- rvd_railbench-0.4.1/include/rvd/simulation.hpp +38 -0
- rvd_railbench-0.4.1/include/rvd/telemetry.hpp +13 -0
- rvd_railbench-0.4.1/include/rvd/time.hpp +33 -0
- rvd_railbench-0.4.1/policies/E_PFCR-DQP_s41_step5120000/manifest.json +22 -0
- rvd_railbench-0.4.1/policies/E_PFCR-DQP_s41_step5120000/pfcr_policy.onnx +0 -0
- rvd_railbench-0.4.1/policies/E_PFCR-DQP_s41_step5120000/pfcr_policy_weights.bin +0 -0
- rvd_railbench-0.4.1/pyproject.toml +49 -0
- rvd_railbench-0.4.1/src/control/pfcr_adapter.cpp +63 -0
- rvd_railbench-0.4.1/src/core/artifact.cpp +91 -0
- rvd_railbench-0.4.1/src/pfcr_controller.cpp +453 -0
- rvd_railbench-0.4.1/src/policy_builtin.cpp +138 -0
- rvd_railbench-0.4.1/src/policy_onnx.cpp +78 -0
- rvd_railbench-0.4.1/src/runtime/config.cpp +236 -0
- rvd_railbench-0.4.1/src/runtime/experiment.cpp +150 -0
- rvd_railbench-0.4.1/src/runtime/options.cpp +98 -0
- rvd_railbench-0.4.1/src/runtime/replay.cpp +103 -0
- rvd_railbench-0.4.1/src/runtime/runtime.cpp +247 -0
- rvd_railbench-0.4.1/src/runtime/safety.cpp +138 -0
- rvd_railbench-0.4.1/src/runtime/telemetry.cpp +45 -0
- rvd_railbench-0.4.1/src/simulation/rail_simulator.cpp +99 -0
- rvd_railbench-0.4.1/tui/pyproject.toml +31 -0
- rvd_railbench-0.4.1/tui/runtime.json.in +7 -0
- rvd_railbench-0.4.1/tui/rvdlab/__init__.py +1 -0
- rvd_railbench-0.4.1/tui/rvdlab/__main__.py +63 -0
- rvd_railbench-0.4.1/tui/rvdlab/app.py +63 -0
- rvd_railbench-0.4.1/tui/rvdlab/config.py +281 -0
- rvd_railbench-0.4.1/tui/rvdlab/experiments.py +93 -0
- rvd_railbench-0.4.1/tui/rvdlab/logo.py +11 -0
- rvd_railbench-0.4.1/tui/rvdlab/plot.py +132 -0
- rvd_railbench-0.4.1/tui/rvdlab/profiles.py +91 -0
- rvd_railbench-0.4.1/tui/rvdlab/project.py +321 -0
- rvd_railbench-0.4.1/tui/rvdlab/rvdlab.tcss +411 -0
- rvd_railbench-0.4.1/tui/rvdlab/screens/__init__.py +10 -0
- rvd_railbench-0.4.1/tui/rvdlab/screens/base.py +55 -0
- rvd_railbench-0.4.1/tui/rvdlab/screens/home.py +123 -0
- rvd_railbench-0.4.1/tui/rvdlab/screens/manager.py +128 -0
- rvd_railbench-0.4.1/tui/rvdlab/screens/motion.py +106 -0
- rvd_railbench-0.4.1/tui/rvdlab/screens/overview.py +129 -0
- rvd_railbench-0.4.1/tui/rvdlab/screens/rendezvous.py +316 -0
- rvd_railbench-0.4.1/tui/rvdlab/screens/sensors.py +116 -0
- rvd_railbench-0.4.1/tui/rvdlab/screens/setup.py +345 -0
- rvd_railbench-0.4.1/tui/rvdlab/sweep.py +162 -0
- rvd_railbench-0.4.1/tui/rvdlab/telemetry.py +240 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.16)
|
|
2
|
+
project(rvd_railbench VERSION 0.4.1 LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
5
|
+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
|
6
|
+
endif()
|
|
7
|
+
include(CTest)
|
|
8
|
+
option(RVD_SIMULATION_ONLY "Disable physical hardware execution" ON)
|
|
9
|
+
option(RVD_WINDOWS_TIMER "Request 1 ms Windows timer resolution" ON)
|
|
10
|
+
set(ONNXRUNTIME_ROOT "" CACHE PATH "ONNX Runtime package root (include/, lib/)")
|
|
11
|
+
set(_ort_default OFF)
|
|
12
|
+
if(ONNXRUNTIME_ROOT)
|
|
13
|
+
set(_ort_default ON)
|
|
14
|
+
endif()
|
|
15
|
+
option(RVD_ENABLE_ONNX "Enable optional ONNX Runtime backend" ${_ort_default})
|
|
16
|
+
if(NOT RVD_SIMULATION_ONLY)
|
|
17
|
+
message(FATAL_ERROR "Hardware drivers and interlocks are not implemented; use RVD_SIMULATION_ONLY=ON")
|
|
18
|
+
endif()
|
|
19
|
+
|
|
20
|
+
add_library(rvd_build_options INTERFACE)
|
|
21
|
+
target_compile_features(rvd_build_options INTERFACE cxx_std_17)
|
|
22
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
23
|
+
# Keep the original arithmetic order, including in downstream controller adapters.
|
|
24
|
+
if(MSVC)
|
|
25
|
+
target_compile_options(rvd_build_options INTERFACE /fp:precise /W4 /utf-8)
|
|
26
|
+
else()
|
|
27
|
+
target_compile_options(rvd_build_options INTERFACE -fno-fast-math -ffp-contract=off -Wall -Wextra -Wpedantic)
|
|
28
|
+
endif()
|
|
29
|
+
|
|
30
|
+
add_library(pfcr_core src/pfcr_controller.cpp src/policy_builtin.cpp src/policy_onnx.cpp)
|
|
31
|
+
add_library(rvd::pfcr ALIAS pfcr_core)
|
|
32
|
+
target_include_directories(pfcr_core PUBLIC include)
|
|
33
|
+
target_link_libraries(pfcr_core PUBLIC rvd_build_options)
|
|
34
|
+
if(RVD_ENABLE_ONNX)
|
|
35
|
+
find_path(ONNXRUNTIME_INCLUDE onnxruntime_cxx_api.h PATHS "${ONNXRUNTIME_ROOT}/include" NO_DEFAULT_PATH)
|
|
36
|
+
find_library(ONNXRUNTIME_LIB onnxruntime PATHS "${ONNXRUNTIME_ROOT}/lib" NO_DEFAULT_PATH)
|
|
37
|
+
if(NOT ONNXRUNTIME_INCLUDE OR NOT ONNXRUNTIME_LIB)
|
|
38
|
+
message(FATAL_ERROR "RVD_ENABLE_ONNX requires ONNXRUNTIME_ROOT with headers and library")
|
|
39
|
+
endif()
|
|
40
|
+
add_library(rvd_onnx UNKNOWN IMPORTED)
|
|
41
|
+
set_target_properties(rvd_onnx PROPERTIES IMPORTED_LOCATION "${ONNXRUNTIME_LIB}"
|
|
42
|
+
INTERFACE_INCLUDE_DIRECTORIES "${ONNXRUNTIME_INCLUDE}")
|
|
43
|
+
target_compile_definitions(pfcr_core PUBLIC PFCR_WITH_ONNXRUNTIME)
|
|
44
|
+
target_link_libraries(pfcr_core PUBLIC rvd_onnx)
|
|
45
|
+
endif()
|
|
46
|
+
|
|
47
|
+
add_library(rvd_runtime
|
|
48
|
+
src/core/artifact.cpp
|
|
49
|
+
src/control/pfcr_adapter.cpp
|
|
50
|
+
src/simulation/rail_simulator.cpp
|
|
51
|
+
src/runtime/runtime.cpp
|
|
52
|
+
src/runtime/experiment.cpp
|
|
53
|
+
src/runtime/replay.cpp
|
|
54
|
+
src/runtime/safety.cpp
|
|
55
|
+
src/runtime/config.cpp
|
|
56
|
+
src/runtime/options.cpp
|
|
57
|
+
src/runtime/telemetry.cpp
|
|
58
|
+
)
|
|
59
|
+
add_library(rvd::runtime ALIAS rvd_runtime)
|
|
60
|
+
find_package(Git QUIET)
|
|
61
|
+
set(RVD_GIT_COMMIT "unknown")
|
|
62
|
+
set(RVD_GIT_DIRTY "unknown")
|
|
63
|
+
if(GIT_FOUND)
|
|
64
|
+
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
65
|
+
OUTPUT_VARIABLE _git_commit OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET RESULT_VARIABLE _git_status)
|
|
66
|
+
if(_git_status EQUAL 0)
|
|
67
|
+
set(RVD_GIT_COMMIT "${_git_commit}")
|
|
68
|
+
endif()
|
|
69
|
+
execute_process(COMMAND ${GIT_EXECUTABLE} status --porcelain WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
70
|
+
OUTPUT_VARIABLE _git_changes OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
|
71
|
+
if(NOT _git_status EQUAL 0)
|
|
72
|
+
set(RVD_GIT_DIRTY "unknown")
|
|
73
|
+
elseif(_git_changes)
|
|
74
|
+
set(RVD_GIT_DIRTY "true")
|
|
75
|
+
else()
|
|
76
|
+
set(RVD_GIT_DIRTY "false")
|
|
77
|
+
endif()
|
|
78
|
+
endif()
|
|
79
|
+
target_compile_definitions(rvd_runtime PRIVATE RVD_GIT_COMMIT="${RVD_GIT_COMMIT}" RVD_GIT_DIRTY="${RVD_GIT_DIRTY}")
|
|
80
|
+
add_executable(rail_replay apps/rail_replay.cpp)
|
|
81
|
+
target_link_libraries(rail_replay PRIVATE rvd_runtime)
|
|
82
|
+
target_link_libraries(rvd_runtime PUBLIC pfcr_core)
|
|
83
|
+
add_executable(rail_main apps/rail_main.cpp)
|
|
84
|
+
target_link_libraries(rail_main PRIVATE rvd_runtime)
|
|
85
|
+
if(WIN32 AND RVD_WINDOWS_TIMER)
|
|
86
|
+
target_compile_definitions(rail_main PRIVATE RVD_WINDOWS_TIMER)
|
|
87
|
+
target_link_libraries(rail_main PRIVATE winmm)
|
|
88
|
+
endif()
|
|
89
|
+
|
|
90
|
+
# Python wheel (scikit-build-core): simulator, policy artifacts and configurations under rvdlab/runtime.
|
|
91
|
+
if(SKBUILD)
|
|
92
|
+
if(MINGW)
|
|
93
|
+
target_link_options(rail_main PRIVATE -static)
|
|
94
|
+
target_link_options(rail_replay PRIVATE -static)
|
|
95
|
+
endif()
|
|
96
|
+
install(TARGETS rail_main rail_replay RUNTIME DESTINATION bin)
|
|
97
|
+
install(DIRECTORY configs/ DESTINATION configs)
|
|
98
|
+
install(DIRECTORY policies/ DESTINATION policies)
|
|
99
|
+
if(RVD_SIMULATION_ONLY)
|
|
100
|
+
set(RVD_RUNTIME_SIMULATION_ONLY true)
|
|
101
|
+
else()
|
|
102
|
+
set(RVD_RUNTIME_SIMULATION_ONLY false)
|
|
103
|
+
endif()
|
|
104
|
+
set(RVD_RUNTIME_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
|
|
105
|
+
if(NOT RVD_RUNTIME_BUILD_TYPE)
|
|
106
|
+
set(RVD_RUNTIME_BUILD_TYPE Release) # multi-config generators: wheels are built with --config Release
|
|
107
|
+
endif()
|
|
108
|
+
configure_file(tui/runtime.json.in runtime.json @ONLY)
|
|
109
|
+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/runtime.json" DESTINATION .)
|
|
110
|
+
endif()
|
|
111
|
+
|
|
112
|
+
if(BUILD_TESTING)
|
|
113
|
+
add_executable(golden_test tests/golden_test.cpp)
|
|
114
|
+
target_link_libraries(golden_test PRIVATE pfcr_core)
|
|
115
|
+
add_test(NAME golden_builtin COMMAND golden_test ${CMAKE_CURRENT_SOURCE_DIR})
|
|
116
|
+
set_tests_properties(golden_builtin PROPERTIES LABELS "regression" TIMEOUT 120)
|
|
117
|
+
if(RVD_ENABLE_ONNX)
|
|
118
|
+
add_test(NAME golden_onnx COMMAND golden_test ${CMAKE_CURRENT_SOURCE_DIR} --onnx)
|
|
119
|
+
set_tests_properties(golden_onnx PROPERTIES LABELS "regression;onnx" TIMEOUT 120)
|
|
120
|
+
endif()
|
|
121
|
+
endif()
|
|
122
|
+
|
|
123
|
+
if(BUILD_TESTING)
|
|
124
|
+
function(rvd_test name category source)
|
|
125
|
+
add_executable(${name} ${source})
|
|
126
|
+
target_link_libraries(${name} PRIVATE rvd_runtime)
|
|
127
|
+
target_include_directories(${name} PRIVATE tests)
|
|
128
|
+
add_test(NAME ${name} COMMAND ${name} ${CMAKE_CURRENT_SOURCE_DIR})
|
|
129
|
+
set_tests_properties(${name} PROPERTIES LABELS "${category}" TIMEOUT 120)
|
|
130
|
+
endfunction()
|
|
131
|
+
find_package(Python3 3.9 COMPONENTS Interpreter REQUIRED)
|
|
132
|
+
add_test(NAME protected_inputs COMMAND ${Python3_EXECUTABLE}
|
|
133
|
+
${CMAKE_CURRENT_SOURCE_DIR}/tests/regression/protected_inputs_test.py ${CMAKE_CURRENT_SOURCE_DIR})
|
|
134
|
+
set_tests_properties(protected_inputs PROPERTIES LABELS "regression" TIMEOUT 30)
|
|
135
|
+
add_test(NAME runtime_integration COMMAND ${Python3_EXECUTABLE}
|
|
136
|
+
${CMAKE_CURRENT_SOURCE_DIR}/tests/integration/runtime_test.py
|
|
137
|
+
$<TARGET_FILE:rail_main> $<TARGET_FILE:rail_replay> ${CMAKE_CURRENT_SOURCE_DIR} ${RVD_ENABLE_ONNX})
|
|
138
|
+
set_tests_properties(runtime_integration PROPERTIES LABELS "integration;faults;regression" TIMEOUT 120)
|
|
139
|
+
rvd_test(safety_time_test faults tests/faults/safety_time_test.cpp)
|
|
140
|
+
rvd_test(simulation_test "unit;faults" tests/faults/simulation_test.cpp)
|
|
141
|
+
rvd_test(controller_artifact_test unit tests/unit/controller_artifact_test.cpp)
|
|
142
|
+
rvd_test(frames_config_test unit tests/unit/frames_config_test.cpp)
|
|
143
|
+
endif()
|
|
144
|
+
|
|
145
|
+
if(RVD_ENABLE_ONNX AND WIN32)
|
|
146
|
+
file(GLOB ORT_DLLS "${ONNXRUNTIME_ROOT}/lib/*.dll")
|
|
147
|
+
foreach(t rail_main rail_replay golden_test safety_time_test simulation_test controller_artifact_test frames_config_test)
|
|
148
|
+
if(TARGET ${t})
|
|
149
|
+
foreach(dll ${ORT_DLLS})
|
|
150
|
+
add_custom_command(TARGET ${t} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
151
|
+
"${dll}" $<TARGET_FILE_DIR:${t}>)
|
|
152
|
+
endforeach()
|
|
153
|
+
endif()
|
|
154
|
+
endforeach()
|
|
155
|
+
endif()
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"cmakeMinimumRequired": {
|
|
4
|
+
"major": 3,
|
|
5
|
+
"minor": 21,
|
|
6
|
+
"patch": 0
|
|
7
|
+
},
|
|
8
|
+
"configurePresets": [
|
|
9
|
+
{
|
|
10
|
+
"name": "dev",
|
|
11
|
+
"displayName": "C++17 simulation development",
|
|
12
|
+
"generator": "Ninja",
|
|
13
|
+
"binaryDir": "${sourceDir}/build/dev",
|
|
14
|
+
"cacheVariables": {
|
|
15
|
+
"CMAKE_BUILD_TYPE": "Debug",
|
|
16
|
+
"BUILD_TESTING": "ON",
|
|
17
|
+
"RVD_SIMULATION_ONLY": "ON",
|
|
18
|
+
"RVD_ENABLE_ONNX": "OFF"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "release",
|
|
23
|
+
"inherits": "dev",
|
|
24
|
+
"binaryDir": "${sourceDir}/build/release",
|
|
25
|
+
"cacheVariables": {
|
|
26
|
+
"CMAKE_BUILD_TYPE": "Release"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "minimal",
|
|
31
|
+
"inherits": "release",
|
|
32
|
+
"binaryDir": "${sourceDir}/build/minimal",
|
|
33
|
+
"cacheVariables": {
|
|
34
|
+
"BUILD_TESTING": "OFF",
|
|
35
|
+
"RVD_WINDOWS_TIMER": "OFF"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"buildPresets": [
|
|
40
|
+
{
|
|
41
|
+
"name": "dev",
|
|
42
|
+
"configurePreset": "dev"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "release",
|
|
46
|
+
"configurePreset": "release"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "minimal",
|
|
50
|
+
"configurePreset": "minimal"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"testPresets": [
|
|
54
|
+
{
|
|
55
|
+
"name": "dev",
|
|
56
|
+
"configurePreset": "dev",
|
|
57
|
+
"output": {
|
|
58
|
+
"outputOnFailure": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "release",
|
|
63
|
+
"configurePreset": "release",
|
|
64
|
+
"output": {
|
|
65
|
+
"outputOnFailure": true
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rvd-railbench
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: Rail-based ground testbed for spacecraft rendezvous and docking, with the RVDLAB terminal interface
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Project-URL: Repository, https://github.com/Strtus/rvd-railbench
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: textual>=8.2
|
|
10
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#include <cstdio>
|
|
2
|
+
#include <stdexcept>
|
|
3
|
+
|
|
4
|
+
#include "rvd/runtime.hpp"
|
|
5
|
+
#if defined(_WIN32) && defined(RVD_WINDOWS_TIMER)
|
|
6
|
+
#ifndef NOMINMAX
|
|
7
|
+
#define NOMINMAX
|
|
8
|
+
#endif
|
|
9
|
+
#ifndef WIN32_LEAN_AND_MEAN
|
|
10
|
+
#define WIN32_LEAN_AND_MEAN
|
|
11
|
+
#endif
|
|
12
|
+
// clang-format off: Windows types must precede the multimedia declarations.
|
|
13
|
+
#include <windows.h>
|
|
14
|
+
#include <timeapi.h>
|
|
15
|
+
// clang-format on
|
|
16
|
+
struct TimerResolution {
|
|
17
|
+
TimerResolution() { timeBeginPeriod(1); }
|
|
18
|
+
~TimerResolution() { timeEndPeriod(1); }
|
|
19
|
+
};
|
|
20
|
+
#endif
|
|
21
|
+
int main(int argc, char** argv) {
|
|
22
|
+
#if defined(_WIN32) && defined(RVD_WINDOWS_TIMER)
|
|
23
|
+
TimerResolution timer;
|
|
24
|
+
#endif
|
|
25
|
+
try {
|
|
26
|
+
const auto opt = rvd::parse_options(argc, argv);
|
|
27
|
+
return rvd::run(opt);
|
|
28
|
+
} catch (const std::exception& e) {
|
|
29
|
+
if (std::string(e.what()) == "help") return 0;
|
|
30
|
+
std::fprintf(stderr, "fatal: %s\n", e.what());
|
|
31
|
+
return 2;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#include <cstdio>
|
|
2
|
+
|
|
3
|
+
#include "rvd/experiment.hpp"
|
|
4
|
+
int main(int argc, char** argv) {
|
|
5
|
+
if (argc < 2 || argc > 3) {
|
|
6
|
+
std::fprintf(stderr, "usage: rail_replay EXPERIMENT_DIR [MODEL_DIR]\n");
|
|
7
|
+
return 2;
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const auto r = rvd::replay(argv[1], argc == 3 ? argv[2] : rvd::find_model_dir());
|
|
11
|
+
std::printf("replayed %d controller inputs, maximum output error %.17g\n", r.steps, r.max_error);
|
|
12
|
+
return 0;
|
|
13
|
+
} catch (const std::exception& e) {
|
|
14
|
+
std::fprintf(stderr, "replay failed: %s\n", e.what());
|
|
15
|
+
return 2;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# SI units. These are simulation operating limits, not verified hardware ratings.
|
|
2
|
+
[rail]
|
|
3
|
+
minimum_m = 0,-0.5,-0.5
|
|
4
|
+
maximum_m = 20,0.5,0.5
|
|
5
|
+
velocity_m_s = 0.5,0.2,0.2
|
|
6
|
+
acceleration_m_s2 = 0.5,0.2,0.2
|
|
7
|
+
measurement_age_s = 0.2
|
|
8
|
+
measurement_late_s = 0.3
|
|
9
|
+
clock_skew_s = 0.005
|
|
10
|
+
sample_jitter_s = 0.2
|
|
11
|
+
communication_timeout_s = 0.3
|
|
12
|
+
tracking_error_m = 0.05
|
|
13
|
+
compensate_latency = false
|
|
14
|
+
[mapping]
|
|
15
|
+
axis = 0,1,2
|
|
16
|
+
sign = 1,1,1
|
|
17
|
+
scale = 1,0.1,0.1
|
|
18
|
+
target_m = 0,0,0
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Observation -> policy -> CBF-QP + backup guard -> thruster model -> CWH step (dt = 1 s).
|
|
2
|
+
// Hill frame: x radial (docking port on +x), y along-track, z cross-track. SI units.
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#include <array>
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <string>
|
|
8
|
+
|
|
9
|
+
#include "pfcr/pfcr_params.hpp"
|
|
10
|
+
|
|
11
|
+
namespace pfcr {
|
|
12
|
+
|
|
13
|
+
using Vec3 = std::array<double, 3>;
|
|
14
|
+
using Vec6 = std::array<double, 6>;
|
|
15
|
+
using Obs = std::array<float, params::kObsDim>;
|
|
16
|
+
using Action = std::array<float, 3>;
|
|
17
|
+
|
|
18
|
+
class Policy {
|
|
19
|
+
public:
|
|
20
|
+
virtual ~Policy() = default;
|
|
21
|
+
// raw observation -> deterministic action in [-1, 1]^3
|
|
22
|
+
virtual Action act(const Obs& obs) = 0;
|
|
23
|
+
virtual std::string name() const = 0;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
std::unique_ptr<Policy> make_builtin_policy(const std::string& weights_bin_path);
|
|
27
|
+
#ifdef PFCR_WITH_ONNXRUNTIME
|
|
28
|
+
std::unique_ptr<Policy> make_onnx_policy(const std::string& onnx_path);
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
struct ObsStats {
|
|
32
|
+
std::array<double, params::kObsDim> mean{};
|
|
33
|
+
std::array<double, params::kObsDim> std{};
|
|
34
|
+
bool load(const std::string& weights_bin_path);
|
|
35
|
+
double max_abs_z(const Obs& obs, int* index = nullptr) const;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
struct ActuatorEmulation {
|
|
39
|
+
double tau = 0.0; // first-order lag [s]
|
|
40
|
+
Vec3 scale{1.0, 1.0, 1.0}; // per-axis thrust scale
|
|
41
|
+
double deadzone = 0.0; // [N]
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
enum class Status { Run, Docked, Abort };
|
|
45
|
+
enum class VelocitySource { Model, Measured, FiniteDifference };
|
|
46
|
+
const char* status_name(Status s);
|
|
47
|
+
|
|
48
|
+
struct StepResult {
|
|
49
|
+
Status status = Status::Run;
|
|
50
|
+
std::string reason;
|
|
51
|
+
int k = 0;
|
|
52
|
+
double t = 0.0; // [s]
|
|
53
|
+
Vec6 state{}; // state used this step
|
|
54
|
+
Obs obs{};
|
|
55
|
+
Action action{};
|
|
56
|
+
Vec3 u_des{}, u_act{}, u_real{}; // [N]
|
|
57
|
+
Vec6 next_state{}; // reference for t + dt
|
|
58
|
+
bool backup_active = false;
|
|
59
|
+
bool intervened = false;
|
|
60
|
+
double dist = 0.0, speed = 0.0, min_margin = 0.0;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
class Controller {
|
|
64
|
+
public:
|
|
65
|
+
Controller(std::unique_ptr<Policy> policy, ActuatorEmulation actuator = {},
|
|
66
|
+
VelocitySource velocity_source = VelocitySource::Model, double tracking_tol_m = 0.10);
|
|
67
|
+
~Controller();
|
|
68
|
+
Controller(const Controller&) = delete;
|
|
69
|
+
Controller& operator=(const Controller&) = delete;
|
|
70
|
+
|
|
71
|
+
void reset(const Vec6& state0);
|
|
72
|
+
// once per control period; vel_measured only for VelocitySource::Measured
|
|
73
|
+
StepResult step(const Vec3& pos_measured, const Vec3* vel_measured = nullptr);
|
|
74
|
+
|
|
75
|
+
bool running() const;
|
|
76
|
+
const Vec6& predicted_state() const;
|
|
77
|
+
const Policy& policy() const;
|
|
78
|
+
|
|
79
|
+
private:
|
|
80
|
+
struct Impl;
|
|
81
|
+
std::unique_ptr<Impl> impl_;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace pfcr
|