hyperray 0.0.1__py3-none-any.whl

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.
Files changed (788) hide show
  1. hyperdrone/__init__.py +53 -0
  2. hyperdrone/_cuda/__init__.py +76 -0
  3. hyperdrone/_dlpack.py +30 -0
  4. hyperdrone/_jit/__init__.py +131 -0
  5. hyperdrone/_jit/_build.py +113 -0
  6. hyperdrone/_jit/_lock.py +23 -0
  7. hyperdrone/_jit/_patches.py +99 -0
  8. hyperdrone/_jit/_toolchain.py +17 -0
  9. hyperdrone/_jit/_workspace.py +94 -0
  10. hyperdrone/_native/cmake/hyperdrone_jit.cmake +65 -0
  11. hyperdrone/_native/common/bindings.h +39 -0
  12. hyperdrone/_native/common/cuda_staging.h +80 -0
  13. hyperdrone/_native/common/jit_host.h +69 -0
  14. hyperdrone/_native/common/models.h +24 -0
  15. hyperdrone/_native/common/verbosity.h +52 -0
  16. hyperdrone/_native/dynamics/CMakeLists.txt +63 -0
  17. hyperdrone/_native/dynamics/host.cpp +188 -0
  18. hyperdrone/_native/dynamics/iface.h +71 -0
  19. hyperdrone/_native/dynamics/impl.cpp +638 -0
  20. hyperdrone/_native/env/CMakeLists.txt +98 -0
  21. hyperdrone/_native/env/environment.cpp +190 -0
  22. hyperdrone/_native/env/environment.h +282 -0
  23. hyperdrone/_native/env/impl.cpp +779 -0
  24. hyperdrone/_native/env/rotorcraft_bindings.cpp +53 -0
  25. hyperdrone/_native/render/CMakeLists.txt +96 -0
  26. hyperdrone/_native/render/renderer.cpp +973 -0
  27. hyperdrone/_native/render/rig_bindings.h +152 -0
  28. hyperdrone/_native/render/scene_bindings.cpp +515 -0
  29. hyperdrone/_outputs.py +32 -0
  30. hyperdrone/_parameters.py +36 -0
  31. hyperdrone/_vendor/rl-tools/CMakeLists.txt +207 -0
  32. hyperdrone/_vendor/rl-tools/LICENSE +21 -0
  33. hyperdrone/_vendor/rl-tools/cmake/autodetect/all.cmake +34 -0
  34. hyperdrone/_vendor/rl-tools/cmake/autodetect/git-diff.cmake +100 -0
  35. hyperdrone/_vendor/rl-tools/cmake/autodetect/git-hash.cmake +24 -0
  36. hyperdrone/_vendor/rl-tools/cmake/autodetect/summary.cmake +65 -0
  37. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier0-compiler.cmake +18 -0
  38. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier1-blas.cmake +51 -0
  39. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier2-json-hdf5-zlib.cmake +82 -0
  40. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier3-tensorboard.cmake +25 -0
  41. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier4-cuda.cmake +42 -0
  42. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier5-cli11.cmake +24 -0
  43. hyperdrone/_vendor/rl-tools/cmake/dependencies/assimp.cmake +19 -0
  44. hyperdrone/_vendor/rl-tools/cmake/legacy_flags.cmake +33 -0
  45. hyperdrone/_vendor/rl-tools/cmake/optional/assimp.cmake +30 -0
  46. hyperdrone/_vendor/rl-tools/cmake/optional/googletest.cmake +20 -0
  47. hyperdrone/_vendor/rl-tools/cmake/optional/metal.cmake +25 -0
  48. hyperdrone/_vendor/rl-tools/cmake/optional/mujoco.cmake +89 -0
  49. hyperdrone/_vendor/rl-tools/cmake/optional/optix.cmake +25 -0
  50. hyperdrone/_vendor/rl-tools/cmake/optional/raytracing.cmake +105 -0
  51. hyperdrone/_vendor/rl-tools/cmake/optional/raytracing_generic.cmake +2 -0
  52. hyperdrone/_vendor/rl-tools/cmake/optional/vulkan.cmake +4 -0
  53. hyperdrone/_vendor/rl-tools/cmake/optional/webgpu.cmake +24 -0
  54. hyperdrone/_vendor/rl-tools/cmake/scripts/embed_text.cmake +7 -0
  55. hyperdrone/_vendor/rl-tools/cmake/scripts/generate-git-snapshot.cmake +138 -0
  56. hyperdrone/_vendor/rl-tools/include/conta/conta.h +1480 -0
  57. hyperdrone/_vendor/rl-tools/include/metra/metra.h +381 -0
  58. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/matrix.h +143 -0
  59. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_arm.h +33 -0
  60. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu.h +314 -0
  61. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_accelerate.h +37 -0
  62. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_blas.h +67 -0
  63. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_mkl.h +38 -0
  64. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_openblas.h +34 -0
  65. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cuda.h +289 -0
  66. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_dummy.h +20 -0
  67. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_esp32.h +29 -0
  68. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_generic.h +944 -0
  69. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_wasm32.h +13 -0
  70. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/persist_code.h +136 -0
  71. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_arm.h +1 -0
  72. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu.h +94 -0
  73. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_accelerate.h +25 -0
  74. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_blas.h +115 -0
  75. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_mkl.h +25 -0
  76. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_openblas.h +25 -0
  77. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cuda.h +713 -0
  78. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_generic.h +1356 -0
  79. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/persist_code.h +130 -0
  80. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/tensor.h +490 -0
  81. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/arm.h +91 -0
  82. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu.h +210 -0
  83. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_accelerate.h +23 -0
  84. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_blas.h +21 -0
  85. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_emscripten.h +20 -0
  86. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_mkl.h +45 -0
  87. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_openblas.h +56 -0
  88. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_tensorboard.h +34 -0
  89. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cuda.h +464 -0
  90. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cuda_streams.h +23 -0
  91. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/devices.h +105 -0
  92. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/dummy.h +55 -0
  93. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/esp32.h +85 -0
  94. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/generic.h +0 -0
  95. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/wasm32.h +59 -0
  96. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/model.h +218 -0
  97. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/operations_generic.h +769 -0
  98. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/persist.h +278 -0
  99. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/policy_adapter.h +100 -0
  100. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/policy_adapter_persist.h +52 -0
  101. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/tensor_operations_generic.h +55 -0
  102. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/c_backend.h +117 -0
  103. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/c_interface.h +36 -0
  104. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/l2f.h +98 -0
  105. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/operations_dyn.h +18 -0
  106. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/operations_generic.h +268 -0
  107. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/debugging_pool/c_backend.h +31 -0
  108. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/debugging_pool/c_interface.h +12 -0
  109. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/c_backend.h +98 -0
  110. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/c_interface.h +50 -0
  111. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/executor.h +133 -0
  112. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/helper.h +109 -0
  113. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/operations_generic.h +219 -0
  114. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_arduino.h +117 -0
  115. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_arm.h +56 -0
  116. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_cpu.h +57 -0
  117. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_cpu_tensorboard.h +151 -0
  118. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_cuda.h +65 -0
  119. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_dummy.h +45 -0
  120. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_wasm32.h +56 -0
  121. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_arm.h +98 -0
  122. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_cpu.h +138 -0
  123. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_cuda.h +380 -0
  124. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_dummy.h +93 -0
  125. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_esp32.h +92 -0
  126. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_generic.h +295 -0
  127. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_wasm32.h +230 -0
  128. hyperdrone/_vendor/rl-tools/include/rl_tools/mode/mode.h +98 -0
  129. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/activation_functions.h +113 -0
  130. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/capability/capability.h +61 -0
  131. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/capability/persist_code.h +31 -0
  132. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/group.h +99 -0
  133. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/layer.h +122 -0
  134. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/operations_cuda.h +64 -0
  135. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/operations_generic.h +186 -0
  136. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/persist.h +33 -0
  137. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/layer.h +300 -0
  138. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/operations_cpu_mkl.h +590 -0
  139. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/operations_cuda.h +809 -0
  140. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/operations_generic.h +1219 -0
  141. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/persist.h +99 -0
  142. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/persist_code.h +170 -0
  143. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/layer.h +145 -0
  144. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_arm/dsp.h +63 -0
  145. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_arm/opt.h +173 -0
  146. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu.h +13 -0
  147. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_accelerate.h +66 -0
  148. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_blas.h +282 -0
  149. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_mkl.h +66 -0
  150. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_openblas.h +65 -0
  151. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cuda.h +519 -0
  152. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_dummy.h +8 -0
  153. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_esp32/dsp.h +58 -0
  154. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_esp32/opt.h +167 -0
  155. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_generic.h +429 -0
  156. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/persist.h +62 -0
  157. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/persist_code.h +178 -0
  158. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/persist_common.h +59 -0
  159. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/layer.h +188 -0
  160. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/operations_cuda.h +356 -0
  161. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/operations_generic.h +536 -0
  162. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/persist.h +32 -0
  163. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/embedding/layer.h +119 -0
  164. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/embedding/operations_generic.h +223 -0
  165. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/embedding/persist.h +46 -0
  166. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/layer.h +121 -0
  167. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/operations_generic.h +154 -0
  168. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/persist.h +44 -0
  169. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/persist_code.h +106 -0
  170. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/helper_operations_cuda.h +602 -0
  171. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/helper_operations_generic.h +251 -0
  172. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/layer.h +206 -0
  173. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/operations_generic.h +889 -0
  174. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/persist.h +75 -0
  175. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/persist_code.h +199 -0
  176. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/layers.h +3 -0
  177. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/layer.h +143 -0
  178. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/operations_cuda.h +80 -0
  179. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/operations_generic.h +216 -0
  180. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/persist.h +39 -0
  181. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu.h +1 -0
  182. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_accelerate.h +1 -0
  183. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_blas.h +1 -0
  184. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_mkl.h +3 -0
  185. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_openblas.h +1 -0
  186. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cuda.h +9 -0
  187. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_dummy.h +1 -0
  188. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_generic.h +3 -0
  189. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/layer.h +223 -0
  190. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/operations_cuda.h +138 -0
  191. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/operations_generic.h +446 -0
  192. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/persist.h +70 -0
  193. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/layer.h +154 -0
  194. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/operations_cuda.h +119 -0
  195. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/operations_generic.h +502 -0
  196. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/persist.h +50 -0
  197. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/persist_code.h +173 -0
  198. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/layer.h +116 -0
  199. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/operations_cuda.h +156 -0
  200. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/operations_generic.h +295 -0
  201. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/persist.h +83 -0
  202. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/persist_code.h +163 -0
  203. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/layer.h +123 -0
  204. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/operations_generic.h +272 -0
  205. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/persist.h +17 -0
  206. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/persist_code.h +164 -0
  207. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/layer.h +122 -0
  208. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/operations_cuda.h +55 -0
  209. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/operations_generic.h +160 -0
  210. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/persist.h +47 -0
  211. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/persist_code.h +106 -0
  212. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/upsample2d/layer.h +132 -0
  213. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/upsample2d/operations_cuda.h +141 -0
  214. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/upsample2d/operations_generic.h +230 -0
  215. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/categorical_cross_entropy/operations_generic.h +102 -0
  216. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/mse/operations_cuda.h +97 -0
  217. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/mse/operations_generic.h +101 -0
  218. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/operations_generic.h +2 -0
  219. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/nn.h +14 -0
  220. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu.h +1 -0
  221. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_accelerate.h +1 -0
  222. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_blas.h +1 -0
  223. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_mkl.h +1 -0
  224. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_mux.h +16 -0
  225. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_openblas.h +1 -0
  226. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cuda.h +2 -0
  227. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_dummy.h +1 -0
  228. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_generic.h +15 -0
  229. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/adam.h +121 -0
  230. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/operations_cuda.h +98 -0
  231. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/operations_generic.h +150 -0
  232. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/persist.h +39 -0
  233. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/persist_code.h +80 -0
  234. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/operations_cuda.h +85 -0
  235. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/operations_generic.h +109 -0
  236. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/persist.h +25 -0
  237. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/lamb/instance/operations_generic.h +107 -0
  238. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/lamb/lamb.h +40 -0
  239. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/lamb/operations_generic.h +68 -0
  240. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/optimizers.h +3 -0
  241. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/operations_cuda.h +85 -0
  242. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/operations_generic.h +140 -0
  243. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/persist.h +37 -0
  244. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/persist_code.h +72 -0
  245. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/operations_cuda.h +49 -0
  246. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/operations_generic.h +50 -0
  247. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/sgd.h +92 -0
  248. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/update.h +54 -0
  249. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/operations_cuda.h +0 -0
  250. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/operations_generic.h +98 -0
  251. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/parameters.h +79 -0
  252. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/persist.h +34 -0
  253. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/persist_code.h +136 -0
  254. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/persist.h +2 -0
  255. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/persist_code.h +27 -0
  256. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/behaviors/skip_parameter_gradients.h +65 -0
  257. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/group/README.md +107 -0
  258. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/group/model.h +19 -0
  259. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/group/persist_code.h +77 -0
  260. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/network.h +174 -0
  261. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/operations_cuda.h +10 -0
  262. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/operations_dummy.h +8 -0
  263. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/operations_generic.h +407 -0
  264. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/persist.h +56 -0
  265. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/persist_code.h +137 -0
  266. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/network.h +55 -0
  267. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/operations_generic.h +86 -0
  268. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/persist.h +43 -0
  269. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/persist_code.h +142 -0
  270. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/models.h +3 -0
  271. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/model.h +148 -0
  272. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/operations_generic.h +288 -0
  273. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/persist.h +25 -0
  274. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/persist_code.h +71 -0
  275. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_cpu.h +0 -0
  276. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_cuda.h +1 -0
  277. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_dummy.h +1 -0
  278. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_generic.h +4 -0
  279. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/model.h +290 -0
  280. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/operations_cuda.h +174 -0
  281. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/operations_generic.h +623 -0
  282. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/persist.h +80 -0
  283. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/persist_code.h +200 -0
  284. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/persist.h +1 -0
  285. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/persist_code.h +1 -0
  286. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/random_uniform/model.h +43 -0
  287. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/random_uniform/operations_generic.h +73 -0
  288. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/resnet/resnet.h +97 -0
  289. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/model.h +270 -0
  290. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/operations_generic.h +625 -0
  291. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/persist.h +99 -0
  292. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/persist_code.h +115 -0
  293. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/bf16.h +28 -0
  294. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/categories.h +22 -0
  295. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/persist_code.h +54 -0
  296. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/policy.h +48 -0
  297. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm/group_1.h +18 -0
  298. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm/group_2.h +14 -0
  299. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm/group_3.h +14 -0
  300. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm.h +19 -0
  301. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu/group_1.h +17 -0
  302. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu/group_2.h +12 -0
  303. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu/group_3.h +15 -0
  304. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu.h +19 -0
  305. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate/group_1.h +16 -0
  306. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate/group_2.h +12 -0
  307. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate/group_3.h +15 -0
  308. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate.h +19 -0
  309. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl/group_1.h +17 -0
  310. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl/group_2.h +12 -0
  311. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl/group_3.h +15 -0
  312. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl.h +18 -0
  313. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mux.h +158 -0
  314. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas/group_1.h +16 -0
  315. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas/group_2.h +12 -0
  316. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas/group_3.h +15 -0
  317. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas.h +18 -0
  318. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard/group_1.h +16 -0
  319. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard/group_2.h +12 -0
  320. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard/group_3.h +15 -0
  321. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard.h +19 -0
  322. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda/group_1.h +18 -0
  323. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda/group_2.h +12 -0
  324. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda/group_3.h +12 -0
  325. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda.h +19 -0
  326. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy/group_1.h +15 -0
  327. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy/group_2.h +12 -0
  328. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy/group_3.h +12 -0
  329. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy.h +19 -0
  330. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32/group_1.h +16 -0
  331. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32/group_2.h +12 -0
  332. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32/group_3.h +13 -0
  333. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32.h +19 -0
  334. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32/group_1.h +15 -0
  335. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32/group_2.h +12 -0
  336. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32/group_3.h +12 -0
  337. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32.h +19 -0
  338. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/hdf5/hdf5.h +54 -0
  339. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/hdf5/operations_cpu.h +419 -0
  340. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/io.h +55 -0
  341. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/operations_cpu.h +58 -0
  342. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/operations_generic.h +620 -0
  343. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/operations_posix.h +63 -0
  344. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/tar.h +74 -0
  345. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/code.h +38 -0
  346. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_arm.h +39 -0
  347. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_cpu.h +81 -0
  348. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_cuda.h +172 -0
  349. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_dummy.h +72 -0
  350. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_esp32.h +45 -0
  351. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_generic.h +133 -0
  352. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_generic_array.h +73 -0
  353. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_wasm32.h +57 -0
  354. hyperdrone/_vendor/rl-tools/include/rl_tools/random/persist.h +77 -0
  355. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/camera.h +105 -0
  356. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/annotations/cache.h +26 -0
  357. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/annotations/free_space.h +60 -0
  358. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/annotations/operations_cpu.h +411 -0
  359. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/glb/glb.h +25 -0
  360. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/glb/operations_cpu.h +1288 -0
  361. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/operations_cpu.h +136 -0
  362. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/catalog.h +232 -0
  363. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/conversion.h +33 -0
  364. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/operations_cpu.h +123 -0
  365. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/procthor.h +39 -0
  366. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/generic/operations_cpu.h +717 -0
  367. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/generic/operations_generic.h +1283 -0
  368. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/metal/context.h +193 -0
  369. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/metal/device_source.h +17 -0
  370. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/metal/operations_cpu.h +1123 -0
  371. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/device.h +207 -0
  372. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/device_impl.h +1043 -0
  373. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/operations_cuda.h +1747 -0
  374. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/overlay_accel.h +64 -0
  375. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/specialization.h +37 -0
  376. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/vulkan/context.h +251 -0
  377. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/vulkan/device_source.h +48 -0
  378. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/vulkan/operations_cpu.h +2067 -0
  379. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/bvh_sah.h +182 -0
  380. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/context.h +280 -0
  381. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/device_source.h +17 -0
  382. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/operations_cpu.h +1405 -0
  383. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/operations_cpu_common.h +948 -0
  384. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/operations_cpu_mux.h +32 -0
  385. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/operations_cpu_post.h +96 -0
  386. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/renderer.h +484 -0
  387. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/save_cpu.h +314 -0
  388. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/scene.h +44 -0
  389. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/transforms_generic.h +25 -0
  390. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/types.h +45 -0
  391. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/rig/operations_cpu.h +119 -0
  392. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/rig/operations_generic.h +121 -0
  393. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/rig/rig.h +70 -0
  394. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/scene.h +132 -0
  395. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/segmentation_cpu.h +145 -0
  396. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/transforms.h +204 -0
  397. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/types.h +76 -0
  398. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/algorithms.h +6 -0
  399. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/operations_cpu.h +1 -0
  400. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/operations_cpu_mkl.h +1 -0
  401. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/operations_generic.h +1 -0
  402. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/config.h +243 -0
  403. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/operations_cuda.h +9 -0
  404. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/operations_generic.h +205 -0
  405. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/persist.h +109 -0
  406. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/state.h +51 -0
  407. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/mixed_imitation.h +63 -0
  408. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/operations_cuda.h +190 -0
  409. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/operations_generic.h +332 -0
  410. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/operations_generic_mixed_imitation.h +81 -0
  411. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/persist.h +28 -0
  412. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/ppo.h +105 -0
  413. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/approximators_gru.h +84 -0
  414. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/approximators_mlp.h +61 -0
  415. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/config.h +106 -0
  416. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/operations_generic.h +193 -0
  417. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/state.h +52 -0
  418. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu.h +9 -0
  419. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu_accelerate.h +2 -0
  420. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu_mkl.h +2 -0
  421. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu_mux.h +9 -0
  422. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cuda.h +131 -0
  423. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_generic.h +580 -0
  424. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/sac.h +151 -0
  425. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/approximators_gru.h +72 -0
  426. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/approximators_mlp.h +54 -0
  427. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/config.h +107 -0
  428. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/operations_generic.h +174 -0
  429. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/state.h +46 -0
  430. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu.h +9 -0
  431. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu_accelerate.h +2 -0
  432. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu_mkl.h +2 -0
  433. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu_mux.h +9 -0
  434. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cuda.h +117 -0
  435. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_generic.h +359 -0
  436. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/td3.h +141 -0
  437. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/components.h +4 -0
  438. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/off_policy_runner.h +225 -0
  439. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cpu.h +95 -0
  440. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cpu_accelerate.h +21 -0
  441. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cpu_mkl.h +21 -0
  442. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cuda.h +237 -0
  443. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_generic.h +498 -0
  444. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_generic_per_env.h +112 -0
  445. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/collection.h +57 -0
  446. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/on_policy_runner.h +122 -0
  447. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu.h +2 -0
  448. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu_accelerate.h +8 -0
  449. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu_mkl.h +8 -0
  450. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu_mux.h +12 -0
  451. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cuda.h +183 -0
  452. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_generic.h +366 -0
  453. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_generic_common.h +74 -0
  454. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/persist.h +47 -0
  455. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_cpu.h +2 -0
  456. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_cpu_accelerate.h +1 -0
  457. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_cpu_mkl.h +1 -0
  458. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_generic.h +2 -0
  459. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/operations_cpu.h +9 -0
  460. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/operations_generic.h +123 -0
  461. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/persist.h +57 -0
  462. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/replay_buffer.h +93 -0
  463. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/running_normalizer/operations_generic.h +76 -0
  464. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/running_normalizer/persist.h +31 -0
  465. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/running_normalizer/running_normalizer.h +33 -0
  466. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/operations_generic.h +58 -0
  467. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/scale_observations/operations_generic.h +28 -0
  468. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/scale_observations/wrapper.h +26 -0
  469. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/wrappers.h +29 -0
  470. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/acrobot/acrobot.h +88 -0
  471. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/acrobot/operations_cpu.h +152 -0
  472. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/acrobot/operations_generic.h +202 -0
  473. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/environment.h +40 -0
  474. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/operations_cuda.h +204 -0
  475. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/operations_generic.h +106 -0
  476. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/operations_generic_common.h +26 -0
  477. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/persist.h +33 -0
  478. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/car.h +119 -0
  479. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/operations_cpu.h +110 -0
  480. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/operations_generic.h +206 -0
  481. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/operations_json.h +59 -0
  482. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/track.h +23 -0
  483. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/ui.h +189 -0
  484. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/environments.h +28 -0
  485. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/flag/environment.h +87 -0
  486. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/flag/operations_cpu.h +212 -0
  487. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/flag/operations_generic.h +215 -0
  488. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/observation.h +75 -0
  489. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/operations_cpu.h +1063 -0
  490. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/operations_cuda.h +564 -0
  491. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/pose.h +253 -0
  492. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/presets.h +154 -0
  493. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/raptor/operations_cpu.h +26 -0
  494. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/raptor/operations_generic.h +91 -0
  495. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/raptor/raptor.h +71 -0
  496. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/rig/operations_cpu.h +190 -0
  497. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/rig/operations_generic.h +32 -0
  498. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/rig/rig.h +25 -0
  499. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/capture_cpu.h +86 -0
  500. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/capture_cuda.h +69 -0
  501. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/capture_optix.h +163 -0
  502. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cpu.h +223 -0
  503. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cpu_spectator.h +194 -0
  504. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cuda.h +1 -0
  505. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cuda_spectator.h +109 -0
  506. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/spectator.h +82 -0
  507. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/spy.h +107 -0
  508. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/ui.h +30 -0
  509. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/moving_gate/moving_gate.h +103 -0
  510. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/moving_gate/operations_cpu.h +279 -0
  511. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/moving_gate/operations_cuda.h +242 -0
  512. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/operations_cpu.h +322 -0
  513. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/operations_cuda.h +312 -0
  514. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/operations_generic_position_hold.h +128 -0
  515. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/position_hold.h +22 -0
  516. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/target_frame.h +92 -0
  517. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/baseline.h +46 -0
  518. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/calibration.h +62 -0
  519. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/metrics.h +101 -0
  520. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/operations_cpu.h +374 -0
  521. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/visual_inertial_localization.h +126 -0
  522. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/world.h +333 -0
  523. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/inertial_velocity.h +27 -0
  524. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/metrics.h +266 -0
  525. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/multirotor.h +1138 -0
  526. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_cpu.h +2252 -0
  527. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/05_state_is_nan.h +148 -0
  528. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/10_sample_initial_parameters.h +228 -0
  529. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/20_initial_state.h +208 -0
  530. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/30_sample_initial_state.h +300 -0
  531. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/35_get_desired_state.h +63 -0
  532. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/40_observe.h +637 -0
  533. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/50_state_algebra.h +57 -0
  534. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/60_dynamics.h +134 -0
  535. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/70_post_integration.h +368 -0
  536. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/80_abs_diff.h +312 -0
  537. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic.h +367 -0
  538. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic_inertial_velocity.h +44 -0
  539. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_helper_generic.h +43 -0
  540. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_multitask_generic.h +70 -0
  541. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_multitask_generic_forward.h +24 -0
  542. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/default.h +209 -0
  543. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/arpl.h +112 -0
  544. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/crazyflie.h +127 -0
  545. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/crazyflie_openmv.h +119 -0
  546. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/flightmare.h +111 -0
  547. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/fs.h +113 -0
  548. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/mrs.h +110 -0
  549. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/soft.h +117 -0
  550. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/soft_rigid.h +118 -0
  551. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/x500.h +88 -0
  552. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/x500_real.h +88 -0
  553. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/x500_sim.h +114 -0
  554. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/init/default.h +56 -0
  555. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/registry.h +96 -0
  556. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/default.h +64 -0
  557. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/reward_functions.h +1 -0
  558. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/squared/operations_generic.h +202 -0
  559. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/squared/squared.h +52 -0
  560. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/termination/default.h +33 -0
  561. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/trajectories/lissajous.h +72 -0
  562. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/trajectories/trajectory.h +78 -0
  563. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/persist.h +21 -0
  564. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/persist_code.h +53 -0
  565. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/quaternion_helper.h +103 -0
  566. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/ui.h +180 -0
  567. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/memory/environment.h +69 -0
  568. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/memory/operations_cpu.h +46 -0
  569. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/memory/operations_generic.h +78 -0
  570. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/README.MD +5 -0
  571. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/ant.h +77 -0
  572. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/model.h +415 -0
  573. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/operations_cpu.h +162 -0
  574. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/persist.h +86 -0
  575. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/ui.h +141 -0
  576. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/mujoco.h +1 -0
  577. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/bottleneck/bottleneck.h +113 -0
  578. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/bottleneck/operations_cpu.h +289 -0
  579. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/bottleneck/operations_generic.h +495 -0
  580. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/environments.h +16 -0
  581. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/observation.h +37 -0
  582. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/operations_cpu.h +2 -0
  583. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/operations_generic.h +33 -0
  584. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/operations_cpu.h +146 -0
  585. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/operations_generic.h +262 -0
  586. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/pendulum.h +197 -0
  587. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/ui.h +97 -0
  588. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/ui_xeus.h +124 -0
  589. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/reacher/operations_cpu.h +426 -0
  590. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/reacher/operations_generic.h +424 -0
  591. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/reacher/reacher.h +137 -0
  592. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/loop.h +15 -0
  593. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/config.h +28 -0
  594. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/operations_cpu.h +233 -0
  595. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/persist.h +30 -0
  596. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/state.h +21 -0
  597. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/config.h +25 -0
  598. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/operations_generic.h +47 -0
  599. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/persist.h +20 -0
  600. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/state.h +17 -0
  601. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/config.h +47 -0
  602. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/operations_generic.h +106 -0
  603. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/persist.h +40 -0
  604. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/state.h +36 -0
  605. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/config.h +22 -0
  606. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/operations_cpu.h +44 -0
  607. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/persist.h +20 -0
  608. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/state.h +26 -0
  609. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/config.h +37 -0
  610. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/operations_cpu.h +113 -0
  611. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/persist.h +20 -0
  612. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/state.h +24 -0
  613. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/config.h +43 -0
  614. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/operations_cpu.h +190 -0
  615. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/persist.h +30 -0
  616. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/state.h +37 -0
  617. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/steps.h +4 -0
  618. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/config.h +27 -0
  619. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/operations_cpu.h +52 -0
  620. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/persist.h +20 -0
  621. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/state.h +25 -0
  622. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/operations_generic.h +3 -0
  623. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/rl.h +5 -0
  624. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/evaluation/evaluation.h +106 -0
  625. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/evaluation/operations_cpu.h +48 -0
  626. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/evaluation/operations_generic.h +275 -0
  627. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/validation.h +269 -0
  628. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/validation_analysis.h +85 -0
  629. hyperdrone/_vendor/rl-tools/include/rl_tools/rl_tools.h +80 -0
  630. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/client.h +50 -0
  631. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/operations_boost.h +92 -0
  632. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/operations_cpu.h +174 -0
  633. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/operations_websocket.h +208 -0
  634. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/server.h +448 -0
  635. hyperdrone/_vendor/rl-tools/include/rl_tools/universe.h +4 -0
  636. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/declarations_cpu.h +13 -0
  637. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/declarations_cpu_emscripten.h +15 -0
  638. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_arm.h +29 -0
  639. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_cpu.h +24 -0
  640. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_cpu_emscripten.h +28 -0
  641. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_cuda.h +33 -0
  642. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_dummy.h +18 -0
  643. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_esp32.h +20 -0
  644. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_generic.h +19 -0
  645. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_wasm32.h +18 -0
  646. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/env/operations_cpu.h +16 -0
  647. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/env/operations_generic.h +14 -0
  648. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/extrack/extrack.h +129 -0
  649. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/extrack/operations_cpu.h +588 -0
  650. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/integrators.h +103 -0
  651. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/memcpy.h +16 -0
  652. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/tuple/operations_generic.h +48 -0
  653. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/tuple/tuple.h +147 -0
  654. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/typing.h +122 -0
  655. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/vector_operations.h +172 -0
  656. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/polyak/operations_cuda.h +53 -0
  657. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/polyak/operations_generic.h +93 -0
  658. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/string/operations_generic.h +201 -0
  659. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/zlib/operations_cpu.h +45 -0
  660. hyperdrone/_vendor/rl-tools/include/rl_tools/version.h +28 -0
  661. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/CMakeLists.txt +15 -0
  662. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/README.md +214 -0
  663. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/CMakeLists.txt +11 -0
  664. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/generic/CMakeLists.txt +17 -0
  665. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/generic/freestanding_check.cpp +134 -0
  666. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/metal/CMakeLists.txt +31 -0
  667. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/metal/device.metal +912 -0
  668. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/metal/metal_cpp_impl.cpp +6 -0
  669. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/optix/CMakeLists.txt +51 -0
  670. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/optix/device.cu +1 -0
  671. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/optix/overlay_accel.cu +308 -0
  672. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/vulkan/CMakeLists.txt +37 -0
  673. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/vulkan/device.comp +970 -0
  674. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/vulkan/device_spirv.cpp +44 -0
  675. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/webgpu/CMakeLists.txt +31 -0
  676. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/webgpu/device.wgsl +1381 -0
  677. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/CMakeLists.txt +129 -0
  678. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/README.md +131 -0
  679. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/benchmark.cpp +180 -0
  680. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/benchmark_dynamic.cpp +491 -0
  681. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/download_paper_scene.py +74 -0
  682. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/CMakeLists.txt +104 -0
  683. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/Info.plist +36 -0
  684. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/Sources/BenchmarkApp.swift +172 -0
  685. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/benchmark.h +10 -0
  686. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/benchmark.mm +46 -0
  687. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/build.sh +17 -0
  688. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/rig.cpp +119 -0
  689. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix.cpp +1382 -0
  690. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix.h +5 -0
  691. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_config.h.in +25 -0
  692. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_identity.cmake +11 -0
  693. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_main.cpp +5 -0
  694. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics.cu +125 -0
  695. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics.h +58 -0
  696. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics_contract.h +179 -0
  697. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics_cpu.cpp +77 -0
  698. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/camera_orbit.h +51 -0
  699. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/CMakeLists.txt +199 -0
  700. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/antialiasing.cpp +214 -0
  701. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/drone.cpp +320 -0
  702. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/drone_device.cu +359 -0
  703. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/environment/environment.h +96 -0
  704. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/environment/operations_cpu.h +263 -0
  705. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/example.cpp +273 -0
  706. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/fixed_pose.cpp +221 -0
  707. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/flow.cpp +120 -0
  708. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/interactive.cpp +1015 -0
  709. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/make_drone_glb.py +172 -0
  710. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/minimal.cpp +82 -0
  711. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/minimal_overlay.cpp +137 -0
  712. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/motion_blur.cpp +232 -0
  713. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/render_pose_trace.cpp +1829 -0
  714. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/render_pose_trace_motion_blur.cpp +647 -0
  715. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/CMakeLists.txt +147 -0
  716. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/README.md +15 -0
  717. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/job.sbatch +28 -0
  718. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model.h +260 -0
  719. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_config.h +24 -0
  720. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_forward_cuda.h +397 -0
  721. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_operations.h +418 -0
  722. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_persist.h +45 -0
  723. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_student.h +70 -0
  724. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/scene.cpp +222 -0
  725. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/scene.h +68 -0
  726. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/.gitignore +4 -0
  727. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/CMakeLists.txt +4 -0
  728. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Info.plist +24 -0
  729. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Info_ios.plist +36 -0
  730. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/CameraManager.swift +120 -0
  731. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/ContentView.swift +703 -0
  732. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/DatasetRecorder.swift +285 -0
  733. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/YawPredictorApp.swift +25 -0
  734. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/YawPredictor.entitlements +8 -0
  735. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/build.sh +66 -0
  736. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/build_ios.sh +133 -0
  737. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/generate.sh +6 -0
  738. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/h5_to_tar.cpp +82 -0
  739. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/inference.cpp +166 -0
  740. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/inference.h +26 -0
  741. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/project.yml +30 -0
  742. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/test_tar_vs_hdf5.cpp +173 -0
  743. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_cuda.cu +699 -0
  744. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_dataset_overlay.cpp +475 -0
  745. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_distill_cuda.cu +995 -0
  746. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_eval.cu +457 -0
  747. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_real_world_eval.cpp +660 -0
  748. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_viewer.cu +443 -0
  749. hyperdrone/_vendor/rl-tools/src/rl/environments/hyperdrone/spy/CMakeLists.txt +63 -0
  750. hyperdrone/_vendor/rl-tools/src/rl/environments/hyperdrone/spy/example.cpp +101 -0
  751. hyperdrone/_vendor/rl-tools/src/rl/environments/hyperdrone/spy/ui.cpp +380 -0
  752. hyperdrone/dynamics/__init__.py +5 -0
  753. hyperdrone/dynamics/_component.py +31 -0
  754. hyperdrone/dynamics/_config.py +46 -0
  755. hyperdrone/dynamics/_sim.py +166 -0
  756. hyperdrone/env/__init__.py +23 -0
  757. hyperdrone/env/_multi_environment.py +566 -0
  758. hyperdrone/env/_rotorcraft.py +29 -0
  759. hyperdrone/env/_spy.py +39 -0
  760. hyperdrone/examples/.gitignore +3 -0
  761. hyperdrone/examples/Benchmark.ipynb +113 -0
  762. hyperdrone/examples/HyperDrone.ipynb +589 -0
  763. hyperdrone/examples/Orbiter.ipynb +496 -0
  764. hyperdrone/examples/Renderer.ipynb +218 -0
  765. hyperdrone/examples/__init__.py +16 -0
  766. hyperdrone/examples/articulation.py +55 -0
  767. hyperdrone/examples/benchmark.py +236 -0
  768. hyperdrone/examples/benchmark_minimal.py +65 -0
  769. hyperdrone/examples/data.py +71 -0
  770. hyperdrone/examples/drone_flythrough.py +169 -0
  771. hyperdrone/examples/hyperdrone_videos/my_world_preview.h +17 -0
  772. hyperdrone/examples/my_world.h +17 -0
  773. hyperdrone/examples/render_procthor.py +40 -0
  774. hyperdrone/examples/shots.py +108 -0
  775. hyperdrone/examples/spy.py +40 -0
  776. hyperdrone/examples/visual_inertial_localization.py +158 -0
  777. hyperdrone/gym/__init__.py +67 -0
  778. hyperdrone/render/__init__.py +57 -0
  779. hyperdrone/render/_component.py +51 -0
  780. hyperdrone/render/_config.py +76 -0
  781. hyperdrone/render/_renderer.py +498 -0
  782. hyperdrone/render/_rig.py +136 -0
  783. hyperdrone/render/_sampling.py +69 -0
  784. hyperdrone/render/_scene.py +38 -0
  785. hyperdrone/render/datasets.py +15 -0
  786. hyperray-0.0.1.dist-info/METADATA +519 -0
  787. hyperray-0.0.1.dist-info/RECORD +788 -0
  788. hyperray-0.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,2252 @@
1
+ #include "../../../version.h"
2
+ #if (defined(RL_TOOLS_DISABLE_INCLUDE_GUARDS) || !defined(RL_TOOLS_RL_ENVIRONMENTS_L2F_OPERATIONS_CPU_H)) && (RL_TOOLS_USE_THIS_VERSION == 1)
3
+ #pragma once
4
+ #define RL_TOOLS_RL_ENVIRONMENTS_L2F_OPERATIONS_CPU_H
5
+ #include "operations_generic.h"
6
+
7
+ #ifdef RL_TOOLS_ENABLE_JSON
8
+ #include <nlohmann/json.hpp>
9
+ #endif
10
+
11
+ #include <random>
12
+ #include <string>
13
+ // Why no JSON library? introduces a dependency and increases the compile time (massively in case of e.g. nlohmann::json)
14
+ RL_TOOLS_NAMESPACE_WRAPPER_START
15
+ namespace rl_tools{
16
+ namespace rl::environments::l2f::obs_helper{
17
+ template <typename DEVICE, typename ENV, typename OBS>
18
+ auto dispatch(DEVICE& device, const ENV& env, const OBS& obs, bool first = true);
19
+ }
20
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
21
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::LastComponent<OBS_SPEC>& obs, bool first = true){
22
+ return "";
23
+ }
24
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
25
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::Multiplex<OBS_SPEC>& obs, bool first = true){
26
+ using OBSERVATION = rl::environments::l2f::observation::Multiplex<OBS_SPEC>;
27
+ std::string output;
28
+ if constexpr(OBS_SPEC::ENABLE){
29
+ output += rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::CURRENT_COMPONENT{}, first);
30
+ first = false;
31
+ }
32
+ output += rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, first);
33
+ return output;
34
+ }
35
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
36
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::Position<OBS_SPEC>& obs, bool first = true){
37
+ using OBSERVATION = rl::environments::l2f::observation::Position<OBS_SPEC>;
38
+ return std::string(first ? "" : ".") + "Position" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
39
+ }
40
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
41
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::OrientationQuaternion<OBS_SPEC>& obs, bool first = true){
42
+ using OBSERVATION = rl::environments::l2f::observation::OrientationQuaternion<OBS_SPEC>;
43
+ return std::string(first ? "" : ".") + "OrientationQuaternion" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
44
+ }
45
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
46
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::OrientationRotationMatrix<OBS_SPEC>& obs, bool first = true){
47
+ using OBSERVATION = rl::environments::l2f::observation::OrientationRotationMatrix<OBS_SPEC>;
48
+ return std::string(first ? "" : ".") + "OrientationRotationMatrix" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
49
+ }
50
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
51
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::OrientationWorldZ<OBS_SPEC>& obs, bool first = true){
52
+ using OBSERVATION = rl::environments::l2f::observation::OrientationWorldZ<OBS_SPEC>;
53
+ return std::string(first ? "" : ".") + "OrientationWorldZ" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
54
+ }
55
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
56
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::OrientationMahonyWorldZ<OBS_SPEC>& obs, bool first = true){
57
+ using OBSERVATION = rl::environments::l2f::observation::OrientationMahonyWorldZ<OBS_SPEC>;
58
+ return std::string(first ? "" : ".") + "OrientationMahonyWorldZ" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
59
+ }
60
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
61
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::LinearVelocity<OBS_SPEC>& obs, bool first = true){
62
+ using OBSERVATION = rl::environments::l2f::observation::LinearVelocity<OBS_SPEC>;
63
+ return std::string(first ? "" : ".") + "LinearVelocity" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
64
+ }
65
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
66
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::AngularVelocity<OBS_SPEC>& obs, bool first = true){
67
+ using OBSERVATION = rl::environments::l2f::observation::AngularVelocity<OBS_SPEC>;
68
+ return std::string(first ? "" : ".") + "AngularVelocity" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
69
+ }
70
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
71
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::LinearAccelerationBodyFrame<OBS_SPEC>& obs, bool first = true){
72
+ using OBSERVATION = rl::environments::l2f::observation::LinearAccelerationBodyFrame<OBS_SPEC>;
73
+ return std::string(first ? "" : ".") + "LinearAccelerationBodyFrame" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
74
+ }
75
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
76
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::LinearAccelerationBodyFrameHistory<OBS_SPEC>& obs, bool first = true){
77
+ using OBSERVATION = rl::environments::l2f::observation::LinearAccelerationBodyFrameHistory<OBS_SPEC>;
78
+ return std::string(first ? "" : ".") + "LinearAccelerationBodyFrameHistory(" + std::to_string(OBSERVATION::HISTORY_LENGTH) + ")" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
79
+ }
80
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
81
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::LinearVelocityBodyFrame<OBS_SPEC>& obs, bool first = true){
82
+ using OBSERVATION = rl::environments::l2f::observation::LinearVelocityBodyFrame<OBS_SPEC>;
83
+ return std::string(first ? "" : ".") + "LinearVelocityBodyFrame" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
84
+ }
85
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
86
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::Magnetometer<OBS_SPEC>& obs, bool first = true){
87
+ using OBSERVATION = rl::environments::l2f::observation::Magnetometer<OBS_SPEC>;
88
+ return std::string(first ? "" : ".") + "Magnetometer" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
89
+ }
90
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
91
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::AngularVelocityDelayed<OBS_SPEC>& obs, bool first = true){
92
+ using OBSERVATION = rl::environments::l2f::observation::AngularVelocityDelayed<OBS_SPEC>;
93
+ return std::string(first ? "" : ".") + "AngularVelocityDelayed(" + std::to_string(OBS_SPEC::DELAY) + ")" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
94
+ }
95
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
96
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::PoseIntegral<OBS_SPEC>& obs, bool first = true){
97
+ using OBSERVATION = rl::environments::l2f::observation::PoseIntegral<OBS_SPEC>;
98
+ return std::string(first ? "" : ".") + "PoseIntegral" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
99
+ }
100
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
101
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::RotorSpeeds<OBS_SPEC>& obs, bool first = true){
102
+ using OBSERVATION = rl::environments::l2f::observation::RotorSpeeds<OBS_SPEC>;
103
+ return std::string(first ? "" : ".") + "RotorSpeeds" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
104
+ }
105
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
106
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::ActionHistory<OBS_SPEC>& obs, bool first = true){
107
+ using OBSERVATION = rl::environments::l2f::observation::ActionHistory<OBS_SPEC>;
108
+ return std::string(first ? "" : ".") + "ActionHistory(" + std::to_string(OBSERVATION::HISTORY_LENGTH) + ")" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
109
+ }
110
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
111
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::RandomForce<OBS_SPEC>& obs, bool first = true){
112
+ using OBSERVATION = rl::environments::l2f::observation::RandomForce<OBS_SPEC>;
113
+ return std::string(first ? "" : ".") + "RandomForce" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
114
+ }
115
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
116
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::ParametersMotorPosition<OBS_SPEC>& obs, bool first = true){
117
+ using OBSERVATION = rl::environments::l2f::observation::ParametersMotorPosition<OBS_SPEC>;
118
+ return std::string(first ? "" : ".") + "ParametersMotorPosition" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
119
+ }
120
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
121
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::ParametersThrustCurves<OBS_SPEC>& obs, bool first = true){
122
+ using OBSERVATION = rl::environments::l2f::observation::ParametersThrustCurves<OBS_SPEC>;
123
+ return std::string(first ? "" : ".") + "ParametersThrustCurves" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
124
+ }
125
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
126
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::ParametersMass<OBS_SPEC>& obs, bool first = true){
127
+ using OBSERVATION = rl::environments::l2f::observation::ParametersMass<OBS_SPEC>;
128
+ return std::string(first ? "" : ".") + "ParametersMass" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
129
+ }
130
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
131
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::ParametersInertia<OBS_SPEC>& obs, bool first = true){
132
+ using OBSERVATION = rl::environments::l2f::observation::ParametersInertia<OBS_SPEC>;
133
+ return std::string(first ? "" : ".") + "ParametersInertia" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
134
+ }
135
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
136
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::TrajectoryTrackingPosition<OBS_SPEC>& obs, bool first = true){
137
+ using OBSERVATION = rl::environments::l2f::observation::TrajectoryTrackingPosition<OBS_SPEC>;
138
+ return std::string(first ? "" : ".") + "TrajectoryTrackingPosition" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
139
+ }
140
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
141
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::TrajectoryTrackingLinearVelocity<OBS_SPEC>& obs, bool first = true){
142
+ using OBSERVATION = rl::environments::l2f::observation::TrajectoryTrackingLinearVelocity<OBS_SPEC>;
143
+ return std::string(first ? "" : ".") + "TrajectoryTrackingLinearVelocity" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
144
+ }
145
+ template <typename DEVICE, typename SPEC, typename OBS_SPEC>
146
+ std::string string(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::observation::TrajectoryTrackingLookahead<OBS_SPEC>& obs, bool first = true){
147
+ using OBSERVATION = rl::environments::l2f::observation::TrajectoryTrackingLookahead<OBS_SPEC>;
148
+ return std::string(first ? "" : ".") + "TrajectoryTrackingLookahead(" + std::to_string(OBS_SPEC::N_STEPS) + ", " + std::to_string(OBS_SPEC::INTERVAL) + ")" + rl::environments::l2f::obs_helper::dispatch(device, env, typename OBSERVATION::NEXT_COMPONENT{}, false);
149
+ }
150
+ namespace rl::environments::l2f::obs_helper{
151
+ template <typename DEVICE, typename ENV, typename OBS>
152
+ auto dispatch(DEVICE& device, const ENV& env, const OBS& obs, bool first){
153
+ return string(device, env, obs, first);
154
+ }
155
+ }
156
+ template <typename DEVICE, typename SPEC>
157
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env){
158
+ using ENVIRONMENT = rl::environments::Multirotor<SPEC>;
159
+ std::string json_string = "{";
160
+ json_string += "\"name\": \"l2f\",";
161
+ json_string += "\"observation\": \"";
162
+ json_string += rl_tools::string(device, env, typename ENVIRONMENT::Observation{});
163
+ json_string += "\"}";
164
+ return json_string;
165
+ }
166
+ namespace rl::environments::l2f::detail{
167
+ template <typename FloatT>
168
+ inline std::string lossless_to_string(FloatT v){
169
+ // round-trip-safe textual representation; max_digits10 guarantees
170
+ // re-parsing yields exactly the same FloatT value. Integral values keep a decimal
171
+ // point so JSON readers parse them as floating point (otherwise -0 loses its sign).
172
+ char buf[64];
173
+ constexpr int digits = std::numeric_limits<FloatT>::max_digits10;
174
+ std::snprintf(buf, sizeof(buf), "%.*g", digits, (double)v);
175
+ std::string result(buf);
176
+ if(result.find_first_of(".eEin") == std::string::npos){
177
+ result += ".0";
178
+ }
179
+ return result;
180
+ }
181
+ }
182
+ // chain components nest in any order: every chain overload is visible to every other
183
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
184
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersBase<PARAM_SPEC>& parameters, bool top_level=true);
185
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
186
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersDisturbances<PARAM_SPEC>& parameters, bool top_level=true);
187
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
188
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersIMU<PARAM_SPEC>& parameters, bool top_level=true);
189
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
190
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersCTBRController<PARAM_SPEC>& parameters, bool top_level=true);
191
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
192
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersDomainRandomization<PARAM_SPEC>& parameters, bool top_level=true);
193
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
194
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersTrajectory<PARAM_SPEC>& parameters, bool top_level=true);
195
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
196
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersObservationDelay<PARAM_SPEC>& parameters, bool top_level=true);
197
+ template <typename DEVICE, typename SPEC, typename T_T, typename T_TI, T_TI N>
198
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::Dynamics<T_T, T_TI, N>& parameters){
199
+ using T = typename SPEC::T;
200
+ using TI = typename DEVICE::index_t;
201
+
202
+ std::string json_string = "{";
203
+ json_string += "\"rotor_positions\": [";
204
+ for (TI i = 0; i < N; i++){
205
+ json_string += "[" + rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_positions[i][0]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_positions[i][1]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_positions[i][2]) + "]";
206
+ if (i < N - 1) {
207
+ json_string += ", ";
208
+ }
209
+ }
210
+ json_string += "], ";
211
+
212
+ json_string += "\"rotor_thrust_directions\": [";
213
+ for (TI i = 0; i < N; i++){
214
+ json_string += "[" + rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_thrust_directions[i][0]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_thrust_directions[i][1]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_thrust_directions[i][2]) + "]";
215
+ if (i < N - 1) {
216
+ json_string += ", ";
217
+ }
218
+ }
219
+ json_string += "], ";
220
+
221
+ json_string += "\"rotor_torque_directions\": [";
222
+ for (TI i = 0; i < N; i++){
223
+ json_string += "[" + rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_torque_directions[i][0]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_torque_directions[i][1]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_torque_directions[i][2]) + "]";
224
+ if (i < N - 1) {
225
+ json_string += ", ";
226
+ }
227
+ }
228
+ json_string += "], ";
229
+
230
+ json_string += "\"rotor_thrust_coefficients\": [";
231
+ for (TI i = 0; i < N; i++){
232
+ json_string += "[" + rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_thrust_coefficients[i][0]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_thrust_coefficients[i][1]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_thrust_coefficients[i][2]) + "]";
233
+ if (i < N - 1) {
234
+ json_string += ", ";
235
+ }
236
+ }
237
+ json_string += "], ";
238
+
239
+ json_string += "\"rotor_torque_constants\": [";
240
+ for (TI i = 0; i < N; i++){
241
+ json_string += rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_torque_constants[i]);
242
+ if (i < N - 1) {
243
+ json_string += ", ";
244
+ }
245
+ }
246
+ json_string += "], ";
247
+
248
+ json_string += "\"rotor_time_constants_rising\": [";
249
+ for (TI i = 0; i < N; i++){
250
+ json_string += rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_time_constants_rising[i]);
251
+ if (i < N - 1) {
252
+ json_string += ", ";
253
+ }
254
+ }
255
+ json_string += "], ";
256
+
257
+ json_string += "\"rotor_time_constants_falling\": [";
258
+ for (TI i = 0; i < N; i++){
259
+ json_string += rl::environments::l2f::detail::lossless_to_string<T>(parameters.rotor_time_constants_falling[i]);
260
+ if (i < N - 1) {
261
+ json_string += ", ";
262
+ }
263
+ }
264
+ json_string += "], ";
265
+
266
+ json_string += "\"mass\": " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.mass) + ", ";
267
+ json_string += "\"gravity\": [" + rl::environments::l2f::detail::lossless_to_string<T>(parameters.gravity[0]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.gravity[1]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.gravity[2]) + "], ";
268
+
269
+ json_string += "\"J\": [";
270
+ for (TI i = 0; i < 3; i++) {
271
+ json_string += "[" + rl::environments::l2f::detail::lossless_to_string<T>(parameters.J[i][0]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.J[i][1]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.J[i][2]) + "]";
272
+ if (i < 2) {
273
+ json_string += ", ";
274
+ }
275
+ }
276
+ json_string += "], ";
277
+
278
+ json_string += "\"J_inv\": [";
279
+ for (TI i = 0; i < 3; i++) {
280
+ json_string += "[" + rl::environments::l2f::detail::lossless_to_string<T>(parameters.J_inv[i][0]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.J_inv[i][1]) + ", " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.J_inv[i][2]) + "]";
281
+ if (i < 2) {
282
+ json_string += ", ";
283
+ }
284
+ }
285
+ json_string += "], ";
286
+
287
+ json_string += "\"hovering_throttle_relative\": " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.hovering_throttle_relative) + ", ";
288
+ json_string += "\"action_limit\": {";
289
+ json_string += "\"min\": " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.action_limit.min) + ", ";
290
+ json_string += "\"max\": " + rl::environments::l2f::detail::lossless_to_string<T>(parameters.action_limit.max);
291
+ json_string += "}"; // closing action_limit
292
+ json_string += "}"; // closing main JSON
293
+ return json_string;
294
+ }
295
+ template <typename DEVICE, typename SPEC, typename T>
296
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::IMU<T>& parameters) {
297
+ auto error_model_json = [](const auto& error_model){
298
+ std::string json_string = "{";
299
+ json_string += "\"noise\": {";
300
+ json_string += "\"mean\": " + rl::environments::l2f::detail::lossless_to_string(error_model.noise.mean) + ", ";
301
+ json_string += "\"std\": " + rl::environments::l2f::detail::lossless_to_string(error_model.noise.std);
302
+ json_string += "}, ";
303
+ json_string += "\"bias\": {";
304
+ json_string += "\"init_max\": " + rl::environments::l2f::detail::lossless_to_string(error_model.bias.init_max) + ", ";
305
+ json_string += "\"tau\": " + rl::environments::l2f::detail::lossless_to_string(error_model.bias.tau) + ", ";
306
+ json_string += "\"sigma\": " + rl::environments::l2f::detail::lossless_to_string(error_model.bias.sigma);
307
+ json_string += "}";
308
+ json_string += "}";
309
+ return json_string;
310
+ };
311
+ std::string json_string = "{";
312
+ json_string += "\"accelerometer\": {\"error\": " + error_model_json(parameters.accelerometer.error) + "}, ";
313
+ json_string += "\"gyro\": {\"error\": " + error_model_json(parameters.gyro.error) + "}";
314
+ json_string += "}";
315
+ return json_string;
316
+ }
317
+ template <typename DEVICE, typename SPEC, typename T>
318
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::CTBRController<T>& parameters) {
319
+ std::string json_string = "{";
320
+ json_string += "\"thrust_min\": " + rl::environments::l2f::detail::lossless_to_string(parameters.thrust_min) + ", ";
321
+ json_string += "\"thrust_max\": " + rl::environments::l2f::detail::lossless_to_string(parameters.thrust_max) + ", ";
322
+ json_string += "\"rate_limit\": [" + rl::environments::l2f::detail::lossless_to_string(parameters.rate_limit[0]) + ", " + rl::environments::l2f::detail::lossless_to_string(parameters.rate_limit[1]) + ", " + rl::environments::l2f::detail::lossless_to_string(parameters.rate_limit[2]) + "], ";
323
+ json_string += "\"kp\": [" + rl::environments::l2f::detail::lossless_to_string(parameters.kp[0]) + ", " + rl::environments::l2f::detail::lossless_to_string(parameters.kp[1]) + ", " + rl::environments::l2f::detail::lossless_to_string(parameters.kp[2]) + "], ";
324
+ json_string += "\"kd\": [" + rl::environments::l2f::detail::lossless_to_string(parameters.kd[0]) + ", " + rl::environments::l2f::detail::lossless_to_string(parameters.kd[1]) + ", " + rl::environments::l2f::detail::lossless_to_string(parameters.kd[2]) + "], ";
325
+ json_string += "\"torque_limit\": [" + rl::environments::l2f::detail::lossless_to_string(parameters.torque_limit[0]) + ", " + rl::environments::l2f::detail::lossless_to_string(parameters.torque_limit[1]) + ", " + rl::environments::l2f::detail::lossless_to_string(parameters.torque_limit[2]) + "]";
326
+ json_string += "}";
327
+ return json_string;
328
+ }
329
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
330
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::Integration<PARAM_SPEC>& parameters) {
331
+ return std::string("{\"dt\": ") + rl::environments::l2f::detail::lossless_to_string(parameters.dt) + "}";
332
+ }
333
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
334
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::Initialization<PARAM_SPEC>& parameters) {
335
+ std::string json_string = "{";
336
+ json_string += "\"guidance\": " + rl::environments::l2f::detail::lossless_to_string(parameters.guidance) + ", ";
337
+ json_string += "\"max_position\": " + rl::environments::l2f::detail::lossless_to_string(parameters.max_position) + ", ";
338
+ json_string += "\"max_angle\": " + rl::environments::l2f::detail::lossless_to_string(parameters.max_angle) + ", ";
339
+ json_string += "\"max_linear_velocity\": " + rl::environments::l2f::detail::lossless_to_string(parameters.max_linear_velocity) + ", ";
340
+ json_string += "\"max_angular_velocity\": " + rl::environments::l2f::detail::lossless_to_string(parameters.max_angular_velocity) + ", ";
341
+ json_string += "\"relative_rpm\": " + std::string(parameters.relative_rpm ? "true" : "false") + ", ";
342
+ json_string += "\"min_rpm\": " + rl::environments::l2f::detail::lossless_to_string(parameters.min_rpm) + ", ";
343
+ json_string += "\"max_rpm\": " + rl::environments::l2f::detail::lossless_to_string(parameters.max_rpm);
344
+ json_string += "}";
345
+ return json_string;
346
+ }
347
+ template <typename DEVICE, typename SPEC, typename T, unsigned T_ACTION_DIM>
348
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::reward_functions::Squared<T, T_ACTION_DIM>& parameters) {
349
+ std::string json_string = "{";
350
+ json_string += "\"non_negative\": " + std::string(parameters.non_negative ? "true" : "false") + ", ";
351
+ json_string += "\"scale\": " + rl::environments::l2f::detail::lossless_to_string(parameters.scale) + ", ";
352
+ json_string += "\"constant\": " + rl::environments::l2f::detail::lossless_to_string(parameters.constant) + ", ";
353
+ json_string += "\"termination_penalty\": " + rl::environments::l2f::detail::lossless_to_string(parameters.termination_penalty) + ", ";
354
+ json_string += "\"position\": " + rl::environments::l2f::detail::lossless_to_string(parameters.position) + ", ";
355
+ json_string += "\"position_clip\": " + rl::environments::l2f::detail::lossless_to_string(parameters.position_clip) + ", ";
356
+ json_string += "\"orientation\": " + rl::environments::l2f::detail::lossless_to_string(parameters.orientation) + ", ";
357
+ json_string += "\"linear_velocity\": " + rl::environments::l2f::detail::lossless_to_string(parameters.linear_velocity) + ", ";
358
+ json_string += "\"angular_velocity\": " + rl::environments::l2f::detail::lossless_to_string(parameters.angular_velocity) + ", ";
359
+ json_string += "\"linear_acceleration\": " + rl::environments::l2f::detail::lossless_to_string(parameters.linear_acceleration) + ", ";
360
+ json_string += "\"angular_acceleration\": " + rl::environments::l2f::detail::lossless_to_string(parameters.angular_acceleration) + ", ";
361
+ json_string += "\"action\": [";
362
+ for(typename DEVICE::index_t action_i = 0; action_i < T_ACTION_DIM; action_i++){
363
+ json_string += rl::environments::l2f::detail::lossless_to_string(parameters.action[action_i]);
364
+ if(action_i + 1 < T_ACTION_DIM){
365
+ json_string += ", ";
366
+ }
367
+ }
368
+ json_string += "], ";
369
+ json_string += "\"d_action\": [";
370
+ for(typename DEVICE::index_t action_i = 0; action_i < T_ACTION_DIM; action_i++){
371
+ json_string += rl::environments::l2f::detail::lossless_to_string(parameters.d_action[action_i]);
372
+ if(action_i + 1 < T_ACTION_DIM){
373
+ json_string += ", ";
374
+ }
375
+ }
376
+ json_string += "], ";
377
+ json_string += "\"position_error_integral\": " + rl::environments::l2f::detail::lossless_to_string(parameters.position_error_integral);
378
+ json_string += "}";
379
+ return json_string;
380
+ }
381
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
382
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::Termination<PARAM_SPEC>& parameters) {
383
+ std::string json_string = "{";
384
+ json_string += "\"enabled\": " + std::string(parameters.enabled ? "true" : "false") + ", ";
385
+ json_string += "\"position_threshold\": " + rl::environments::l2f::detail::lossless_to_string(parameters.position_threshold) + ", ";
386
+ json_string += "\"angle_threshold\": " + rl::environments::l2f::detail::lossless_to_string(parameters.angle_threshold) + ", ";
387
+ json_string += "\"linear_velocity_threshold\": " + rl::environments::l2f::detail::lossless_to_string(parameters.linear_velocity_threshold) + ", ";
388
+ json_string += "\"angular_velocity_threshold\": " + rl::environments::l2f::detail::lossless_to_string(parameters.angular_velocity_threshold) + ", ";
389
+ json_string += "\"position_integral_threshold\": " + rl::environments::l2f::detail::lossless_to_string(parameters.position_integral_threshold) + ", ";
390
+ json_string += "\"orientation_integral_threshold\": " + rl::environments::l2f::detail::lossless_to_string(parameters.orientation_integral_threshold);
391
+ json_string += "}";
392
+ return json_string;
393
+ }
394
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
395
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::ObservationNoise<PARAM_SPEC>& parameters) {
396
+ std::string json_string = "{";
397
+ json_string += "\"position\": " + rl::environments::l2f::detail::lossless_to_string(parameters.position) + ", ";
398
+ json_string += "\"orientation\": " + rl::environments::l2f::detail::lossless_to_string(parameters.orientation) + ", ";
399
+ json_string += "\"linear_velocity\": " + rl::environments::l2f::detail::lossless_to_string(parameters.linear_velocity) + ", ";
400
+ json_string += "\"angular_velocity\": " + rl::environments::l2f::detail::lossless_to_string(parameters.angular_velocity) + ", ";
401
+ json_string += "\"imu_acceleration\": " + rl::environments::l2f::detail::lossless_to_string(parameters.imu_acceleration);
402
+ json_string += "}";
403
+ return json_string;
404
+ }
405
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
406
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::ActionNoise<PARAM_SPEC>& parameters) {
407
+ std::string json_string = "{";
408
+ json_string += "\"normalized_rpm\": " + rl::environments::l2f::detail::lossless_to_string(parameters.normalized_rpm);
409
+ json_string += "}";
410
+ return json_string;
411
+ }
412
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
413
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::MDP<PARAM_SPEC>& parameters) {
414
+ std::string json_string = "{";
415
+ json_string += "\"init\": " + json(device, env, parameters.init) + ", ";
416
+ json_string += "\"reward\": " + json(device, env, parameters.reward) + ", ";
417
+ json_string += "\"observation_noise\": " + json(device, env, parameters.observation_noise) + ", ";
418
+ json_string += "\"action_noise\": " + json(device, env, parameters.action_noise) + ", ";
419
+ json_string += "\"termination\": " + json(device, env, parameters.termination);
420
+ json_string += "}";
421
+ return json_string;
422
+ }
423
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
424
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersBase<PARAM_SPEC>& parameters, bool top_level){
425
+ using T = typename SPEC::T;
426
+ using TI = typename DEVICE::index_t;
427
+ std::string json_string = top_level ? "{" : "";
428
+ json_string += "\"dynamics\": " + json(device, env, parameters.dynamics) + ", ";
429
+ json_string += "\"integration\": " + json(device, env, parameters.integration) + ", ";
430
+ json_string += "\"mdp\": " + json(device, env, parameters.mdp);
431
+ json_string += top_level ? "}" : "";
432
+ return json_string;
433
+ }
434
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
435
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::Disturbances<PARAM_SPEC>& parameters) {
436
+ std::string json_string = "{";
437
+ json_string += "\"random_force\": {";
438
+ json_string += "\"mean\": " + rl::environments::l2f::detail::lossless_to_string(parameters.random_force.mean) + ", ";
439
+ json_string += "\"std\": " + rl::environments::l2f::detail::lossless_to_string(parameters.random_force.std);
440
+ json_string += "}, ";
441
+ json_string += "\"random_torque\": {";
442
+ json_string += "\"mean\": " + rl::environments::l2f::detail::lossless_to_string(parameters.random_torque.mean) + ", ";
443
+ json_string += "\"std\": " + rl::environments::l2f::detail::lossless_to_string(parameters.random_torque.std);
444
+ json_string += "}";
445
+ json_string += "}";
446
+ return json_string;
447
+ }
448
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
449
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersDisturbances<PARAM_SPEC>& parameters, bool top_level){
450
+ using T = typename SPEC::T;
451
+ using TI = typename DEVICE::index_t;
452
+ std::string json_string = top_level ? "{" : "";
453
+ json_string += json(device, env, static_cast<const typename PARAM_SPEC::NEXT_COMPONENT&>(parameters), false);
454
+ json_string += ", \"disturbances\": " + json(device, env, parameters.disturbances);
455
+ json_string += (top_level ? "}" : "");
456
+ return json_string;
457
+ }
458
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
459
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersIMU<PARAM_SPEC>& parameters, bool top_level){
460
+ std::string json_string = top_level ? "{" : "";
461
+ json_string += json(device, env, static_cast<const typename PARAM_SPEC::NEXT_COMPONENT&>(parameters), false);
462
+ json_string += ", \"imu\": " + json(device, env, parameters.imu);
463
+ json_string += (top_level ? "}" : "");
464
+ return json_string;
465
+ }
466
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
467
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersCTBRController<PARAM_SPEC>& parameters, bool top_level){
468
+ std::string json_string = top_level ? "{" : "";
469
+ json_string += json(device, env, static_cast<const typename PARAM_SPEC::NEXT_COMPONENT&>(parameters), false);
470
+ json_string += ", \"ctbr_controller\": " + json(device, env, parameters.ctbr_controller);
471
+ json_string += (top_level ? "}" : "");
472
+ return json_string;
473
+ }
474
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
475
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::DomainRandomization<PARAM_SPEC>& parameters) {
476
+ std::string json_string = "{";
477
+ json_string += "\"thrust_to_weight_min\": " + rl::environments::l2f::detail::lossless_to_string(parameters.thrust_to_weight_min) + ", ";
478
+ json_string += "\"thrust_to_weight_max\": " + rl::environments::l2f::detail::lossless_to_string(parameters.thrust_to_weight_max) + ", ";
479
+ json_string += "\"torque_to_inertia_min\": " + rl::environments::l2f::detail::lossless_to_string(parameters.torque_to_inertia_min) + ", ";
480
+ json_string += "\"torque_to_inertia_max\": " + rl::environments::l2f::detail::lossless_to_string(parameters.torque_to_inertia_max) + ", ";
481
+ json_string += "\"mass_min\": " + rl::environments::l2f::detail::lossless_to_string(parameters.mass_min) + ", ";
482
+ json_string += "\"mass_max\": " + rl::environments::l2f::detail::lossless_to_string(parameters.mass_max) + ", ";
483
+ json_string += "\"mass_size_deviation\": " + rl::environments::l2f::detail::lossless_to_string(parameters.mass_size_deviation) + ", ";
484
+ json_string += "\"rotor_time_constant_rising_min\": " + rl::environments::l2f::detail::lossless_to_string(parameters.rotor_time_constant_rising_min) + ", ";
485
+ json_string += "\"rotor_time_constant_rising_max\": " + rl::environments::l2f::detail::lossless_to_string(parameters.rotor_time_constant_rising_max) + ", ";
486
+ json_string += "\"rotor_time_constant_falling_min\": " + rl::environments::l2f::detail::lossless_to_string(parameters.rotor_time_constant_falling_min) + ", ";
487
+ json_string += "\"rotor_time_constant_falling_max\": " + rl::environments::l2f::detail::lossless_to_string(parameters.rotor_time_constant_falling_max) + ", ";
488
+ json_string += "\"rotor_torque_constant_min\": " + rl::environments::l2f::detail::lossless_to_string(parameters.rotor_torque_constant_min) + ", ";
489
+ json_string += "\"rotor_torque_constant_max\": " + rl::environments::l2f::detail::lossless_to_string(parameters.rotor_torque_constant_max) + ", ";
490
+ json_string += "\"orientation_offset_angle_max\": " + rl::environments::l2f::detail::lossless_to_string(parameters.orientation_offset_angle_max) + ", ";
491
+ json_string += "\"disturbance_force_max\": " + rl::environments::l2f::detail::lossless_to_string(parameters.disturbance_force_max);
492
+ json_string += "}";
493
+ return json_string;
494
+ }
495
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
496
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersDomainRandomization<PARAM_SPEC>& parameters, bool top_level){
497
+ std::string json_string = top_level ? "{" : "";
498
+ json_string += json(device, env, static_cast<const typename PARAM_SPEC::NEXT_COMPONENT&>(parameters), false);
499
+ json_string += ", \"domain_randomization\": " + json(device, env, parameters.domain_randomization);
500
+ json_string += (top_level ? "}" : "");
501
+ return json_string;
502
+ }
503
+ template <typename DEVICE, typename SPEC, typename TRAJ_SPEC>
504
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::trajectories::Trajectory<TRAJ_SPEC>& parameters) {
505
+ using TI = typename DEVICE::index_t;
506
+ using TRAJECTORY = rl::environments::l2f::parameters::trajectories::Trajectory<TRAJ_SPEC>;
507
+ std::string json_string = "{";
508
+ json_string += "\"LENGTH\": " + std::to_string(TRAJECTORY::LENGTH) + ", ";
509
+ json_string += "\"DT\": " + rl::environments::l2f::detail::lossless_to_string(TRAJECTORY::DT) + ", ";
510
+ json_string += "\"steps\": [";
511
+ for (TI step_i=0; step_i < TRAJECTORY::LENGTH; ++step_i){
512
+ json_string += "{";
513
+ json_string += "\"position\": [" + rl::environments::l2f::detail::lossless_to_string(parameters.steps[step_i].position[0]) + ", " + rl::environments::l2f::detail::lossless_to_string(parameters.steps[step_i].position[1]) + ", " + rl::environments::l2f::detail::lossless_to_string(parameters.steps[step_i].position[2]) + "], ";
514
+ json_string += "\"yaw\": " + rl::environments::l2f::detail::lossless_to_string(parameters.steps[step_i].yaw) + ", ";
515
+ json_string += "\"linear_velocity\": [" + rl::environments::l2f::detail::lossless_to_string(parameters.steps[step_i].linear_velocity[0]) + ", " + rl::environments::l2f::detail::lossless_to_string(parameters.steps[step_i].linear_velocity[1]) + ", " + rl::environments::l2f::detail::lossless_to_string(parameters.steps[step_i].linear_velocity[2]) + "], ";
516
+ json_string += "\"yaw_velocity\": " + rl::environments::l2f::detail::lossless_to_string(parameters.steps[step_i].yaw_velocity);
517
+ json_string += "}";
518
+ json_string += (step_i < TRAJECTORY::LENGTH-1 ? ", " : "");
519
+ }
520
+ json_string += "]";
521
+ json_string += "}";
522
+ return json_string;
523
+ }
524
+ template <typename DEVICE, typename SPEC, typename T>
525
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::trajectories::lissajous::Parameters<T>& parameters) {
526
+ std::string json_string = "{";
527
+ json_string += "\"A\": " + rl::environments::l2f::detail::lossless_to_string(parameters.A) + ", ";
528
+ json_string += "\"B\": " + rl::environments::l2f::detail::lossless_to_string(parameters.B) + ", ";
529
+ json_string += "\"C\": " + rl::environments::l2f::detail::lossless_to_string(parameters.C) + ", ";
530
+ json_string += "\"a\": " + rl::environments::l2f::detail::lossless_to_string(parameters.a) + ", ";
531
+ json_string += "\"b\": " + rl::environments::l2f::detail::lossless_to_string(parameters.b) + ", ";
532
+ json_string += "\"c\": " + rl::environments::l2f::detail::lossless_to_string(parameters.c) + ", ";
533
+ json_string += "\"interval\": " + rl::environments::l2f::detail::lossless_to_string(parameters.interval) + ", ";
534
+ json_string += "\"ramp_duration\": " + rl::environments::l2f::detail::lossless_to_string(parameters.ramp_duration);
535
+ json_string += "}";
536
+ return json_string;
537
+ }
538
+ template <typename DEVICE, typename SPEC, typename TRAJ_PARAM_SPEC>
539
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::trajectories::TaggedParameters<TRAJ_PARAM_SPEC>& parameters) {
540
+ std::string json_string = "{";
541
+ if (parameters.type == rl::environments::l2f::parameters::trajectories::Type::LISSAJOUS) {
542
+ json_string += "\"type\": \"LISSAJOUS\", ";
543
+ json_string += "\"lissajous\": " + json(device, env, parameters.parameters.lissajous);
544
+ }
545
+ else {
546
+ utils::assert_exit(device, false, "L2F json export: Unknown trajectory_parameters type");
547
+ }
548
+ json_string += "}";
549
+ return json_string;
550
+ }
551
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
552
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersTrajectory<PARAM_SPEC>& parameters, bool top_level){
553
+ std::string json_string = top_level ? "{" : "";
554
+ json_string += json(device, env, static_cast<const typename PARAM_SPEC::NEXT_COMPONENT&>(parameters), false);
555
+ json_string += ", \"trajectory\": " + json(device, env, parameters.trajectory);
556
+ json_string += ", \"trajectory_parameters\": " + json(device, env, parameters.trajectory_parameters);
557
+ json_string += (top_level ? "}" : "");
558
+ return json_string;
559
+ }
560
+ template <typename DEVICE, typename SPEC, typename T, typename TI>
561
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::parameters::ObservationDelay<T, TI>& parameters) {
562
+ std::string json_string = "{";
563
+ json_string += "\"linear_velocity\": " + std::to_string(parameters.linear_velocity) + ", ";
564
+ json_string += "\"angular_velocity\": " + std::to_string(parameters.angular_velocity);
565
+ json_string += "}";
566
+ return json_string;
567
+ }
568
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
569
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const rl::environments::l2f::ParametersObservationDelay<PARAM_SPEC>& parameters, bool top_level){
570
+ std::string json_string = top_level ? "{" : "";
571
+ json_string += json(device, env, static_cast<const typename PARAM_SPEC::NEXT_COMPONENT&>(parameters), false);
572
+ json_string += ", \"observation_delay\": " + json(device, env, parameters.observation_delay);
573
+ json_string += (top_level ? "}" : "");
574
+ return json_string;
575
+ }
576
+
577
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
578
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateBase<STATE_SPEC>& state, bool top_level=true){
579
+ std::string json_string = top_level ? "{" : "";
580
+ json_string += "\"position\": [" + std::to_string(state.position[0]) + ", " + std::to_string(state.position[1]) + ", " + std::to_string(state.position[2]) + "], ";
581
+ json_string += "\"orientation\": [" + std::to_string(state.orientation[0]) + ", " + std::to_string(state.orientation[1]) + ", " + std::to_string(state.orientation[2]) + ", " + std::to_string(state.orientation[3]) + "], ";
582
+ json_string += "\"linear_velocity\": [" + std::to_string(state.linear_velocity[0]) + ", " + std::to_string(state.linear_velocity[1]) + ", " + std::to_string(state.linear_velocity[2]) + "], ";
583
+ json_string += "\"angular_velocity\": [" + std::to_string(state.angular_velocity[0]) + ", " + std::to_string(state.angular_velocity[1]) + ", " + std::to_string(state.angular_velocity[2]) + "]";
584
+ json_string += top_level ? "}" : "";
585
+ return json_string;
586
+ }
587
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
588
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateLastAction<STATE_SPEC>& state, bool top_level=true){
589
+ using TI = typename DEVICE::index_t;
590
+ std::string json_string = top_level ? "{" : "";
591
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
592
+ json_string += "\"last_action\": [";
593
+ for (TI action_i = 0; action_i < SPEC::PARAMETERS::N; action_i++){
594
+ json_string += std::to_string(state.last_action[action_i]);
595
+ if (action_i < SPEC::PARAMETERS::N - 1) {
596
+ json_string += ", ";
597
+ }
598
+ }
599
+ json_string += "]";
600
+ json_string += top_level ? "}" : "";
601
+ return json_string;
602
+ }
603
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
604
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateLinearAcceleration<STATE_SPEC>& state, bool top_level=true){
605
+ using TI = typename DEVICE::index_t;
606
+ std::string json_string = top_level ? "{" : "";
607
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
608
+ json_string += "\"linear_acceleration\": [";
609
+ for (TI i = 0; i < 3; i++){
610
+ json_string += std::to_string(state.linear_acceleration[i]);
611
+ if (i < 2) {
612
+ json_string += ", ";
613
+ }
614
+ }
615
+ json_string += "]";
616
+ json_string += top_level ? "}" : "";
617
+ return json_string;
618
+ }
619
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
620
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateGyro<STATE_SPEC>& state, bool top_level=true){
621
+ using TI = typename DEVICE::index_t;
622
+ std::string json_string = top_level ? "{" : "";
623
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
624
+ json_string += "\"gyro\": [";
625
+ for (TI i = 0; i < 3; i++){
626
+ json_string += std::to_string(state.gyro[i]);
627
+ if (i < 2) {
628
+ json_string += ", ";
629
+ }
630
+ }
631
+ json_string += "]";
632
+ json_string += ", ";
633
+ json_string += "\"gyro_bias\": [";
634
+ for (TI i = 0; i < 3; i++){
635
+ json_string += std::to_string(state.gyro_bias[i]);
636
+ if (i < 2) {
637
+ json_string += ", ";
638
+ }
639
+ }
640
+ json_string += "]";
641
+ json_string += top_level ? "}" : "";
642
+ return json_string;
643
+ }
644
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
645
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateAccelerometer<STATE_SPEC>& state, bool top_level=true){
646
+ using TI = typename DEVICE::index_t;
647
+ std::string json_string = top_level ? "{" : "";
648
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
649
+ json_string += "\"accelerometer\": [";
650
+ for (TI i = 0; i < 3; i++){
651
+ json_string += std::to_string(state.accelerometer[i]);
652
+ if (i < 2) {
653
+ json_string += ", ";
654
+ }
655
+ }
656
+ json_string += "]";
657
+ json_string += ", ";
658
+ json_string += "\"accelerometer_bias\": [";
659
+ for (TI i = 0; i < 3; i++){
660
+ json_string += std::to_string(state.accelerometer_bias[i]);
661
+ if (i < 2) {
662
+ json_string += ", ";
663
+ }
664
+ }
665
+ json_string += "]";
666
+ json_string += top_level ? "}" : "";
667
+ return json_string;
668
+ }
669
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
670
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateMahony<STATE_SPEC>& state, bool top_level=true){
671
+ using TI = typename DEVICE::index_t;
672
+ std::string json_string = top_level ? "{" : "";
673
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
674
+ json_string += "\"q_estimate\": [";
675
+ for (TI i = 0; i < 4; i++){
676
+ json_string += std::to_string(state.q_estimate[i]);
677
+ if (i < 3) {
678
+ json_string += ", ";
679
+ }
680
+ }
681
+ json_string += "], ";
682
+ json_string += "\"bias_estimate\": [";
683
+ for (TI i = 0; i < 3; i++){
684
+ json_string += std::to_string(state.bias_estimate[i]);
685
+ if (i < 2) {
686
+ json_string += ", ";
687
+ }
688
+ }
689
+ json_string += "]";
690
+ json_string += top_level ? "}" : "";
691
+ return json_string;
692
+ }
693
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
694
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateCTBRController<STATE_SPEC>& state, bool top_level=true){
695
+ std::string json_string = top_level ? "{" : "";
696
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
697
+ json_string += "\"previous_angular_velocity\": [" + std::to_string(state.previous_angular_velocity[0]) + ", " + std::to_string(state.previous_angular_velocity[1]) + ", " + std::to_string(state.previous_angular_velocity[2]) + "]";
698
+ json_string += top_level ? "}" : "";
699
+ return json_string;
700
+ }
701
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
702
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateLinearAccelerationHistory<STATE_SPEC>& state, bool top_level=true){
703
+ using TI = typename DEVICE::index_t;
704
+ using T = typename STATE_SPEC::T;
705
+ using STATE = rl::environments::l2f::StateLinearAccelerationHistory<STATE_SPEC>;
706
+ std::string json_string = top_level ? "{" : "";
707
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
708
+ json_string += "\"linear_acceleration_body_history\": [";
709
+ for (TI step_i = 0; step_i < STATE_SPEC::HISTORY_LENGTH; step_i++){
710
+ json_string += "[";
711
+ for (TI dim_i = 0; dim_i < STATE::ACCELERATION_DIM; dim_i++){
712
+ json_string += rl::environments::l2f::detail::lossless_to_string<T>(state.linear_acceleration_body_history[step_i][dim_i]);
713
+ if (dim_i < STATE::ACCELERATION_DIM - 1) {
714
+ json_string += ", ";
715
+ }
716
+ }
717
+ json_string += "]";
718
+ if (step_i + 1 < STATE_SPEC::HISTORY_LENGTH) {
719
+ json_string += ", ";
720
+ }
721
+ }
722
+ json_string += "], ";
723
+ json_string += "\"acceleration_history_step\": " + std::to_string(state.acceleration_history_step);
724
+ json_string += top_level ? "}" : "";
725
+ return json_string;
726
+ }
727
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
728
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateAngularVelocityDelay<STATE_SPEC>& state, bool top_level=true){
729
+ using TI = typename DEVICE::index_t;
730
+ using STATE = rl::environments::l2f::StateAngularVelocityDelay<STATE_SPEC>;
731
+ std::string json_string = top_level ? "{" : "";
732
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
733
+ json_string += "\"angular_velocity_history\": [";
734
+ for (TI step_i = 0; step_i < STATE::HISTORY_MEM_LENGTH; step_i++){
735
+ json_string += "[";
736
+ for (TI dim_i = 0; dim_i < 3; dim_i++){
737
+ json_string += std::to_string(state.angular_velocity_history[step_i][dim_i]);
738
+ if (dim_i < 2) {
739
+ json_string += ", ";
740
+ }
741
+ }
742
+ json_string += "]";
743
+ if (step_i < STATE::HISTORY_MEM_LENGTH - 1) {
744
+ json_string += ", ";
745
+ }
746
+ }
747
+ json_string += "]";
748
+ json_string += top_level ? "}" : "";
749
+ return json_string;
750
+ }
751
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
752
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateLinearVelocityDelay<STATE_SPEC>& state, bool top_level=true){
753
+ using TI = typename DEVICE::index_t;
754
+ using STATE = rl::environments::l2f::StateLinearVelocityDelay<STATE_SPEC>;
755
+ std::string json_string = top_level ? "{" : "";
756
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
757
+ json_string += "\"linear_velocity_history\": [";
758
+ for (TI step_i = 0; step_i < STATE::HISTORY_MEM_LENGTH; step_i++){
759
+ json_string += "[";
760
+ for (TI dim_i = 0; dim_i < 3; dim_i++){
761
+ json_string += std::to_string(state.linear_velocity_history[step_i][dim_i]);
762
+ if (dim_i < 2) {
763
+ json_string += ", ";
764
+ }
765
+ }
766
+ json_string += "]";
767
+ if (step_i < STATE::HISTORY_MEM_LENGTH - 1) {
768
+ json_string += ", ";
769
+ }
770
+ }
771
+ json_string += "]";
772
+ json_string += top_level ? "}" : "";
773
+ return json_string;
774
+ }
775
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
776
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StatePoseErrorIntegral<STATE_SPEC>& state, bool top_level=true){
777
+ std::string json_string = top_level ? "{" : "";
778
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
779
+ json_string += "\"position_integral\": [" + std::to_string(state.position_integral[0]) + ", " + std::to_string(state.position_integral[1]) + ", " + std::to_string(state.position_integral[2]) + "], ";
780
+ json_string += "\"orientation_integral\": " + std::to_string(state.orientation_integral);
781
+ json_string += top_level ? "}" : "";
782
+ return json_string;
783
+ }
784
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
785
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateRotors<STATE_SPEC>& state, bool top_level=true){
786
+ using TI = typename DEVICE::index_t;
787
+ using STATE = rl::environments::l2f::StateRotors<STATE_SPEC>;
788
+ std::string json_string = top_level ? "{" : "";
789
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
790
+ json_string += "\"rpm\": [";
791
+ for (TI action_i = 0; action_i < STATE::ACTION_DIM; action_i++){
792
+ json_string += std::to_string(state.rpm[action_i]);
793
+ if (action_i < STATE::ACTION_DIM - 1) {
794
+ json_string += ", ";
795
+ }
796
+ }
797
+ json_string += "]";
798
+ json_string += top_level ? "}" : "";
799
+ return json_string;
800
+ }
801
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
802
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateRotorsHistory<STATE_SPEC>& state, bool top_level=true){
803
+ using TI = typename DEVICE::index_t;
804
+ using STATE = rl::environments::l2f::StateRotorsHistory<STATE_SPEC>;
805
+ std::string json_string = top_level ? "{" : "";
806
+ json_string += json(device, env, parameters, static_cast<const typename STATE::NEXT_COMPONENT&>(state), false) + ", ";
807
+ json_string += "\"action_history\": [";
808
+ for (TI step_i = 0; step_i < STATE_SPEC::HISTORY_LENGTH; step_i++){
809
+ json_string += "[";
810
+ for (TI action_i = 0; action_i < SPEC::PARAMETERS::N; action_i++){
811
+ json_string += std::to_string(state.action_history[step_i][action_i]);
812
+ if (action_i < SPEC::PARAMETERS::N - 1) {
813
+ json_string += ", ";
814
+ }
815
+ }
816
+ json_string += "]";
817
+ if (step_i < STATE_SPEC::HISTORY_LENGTH - 1) {
818
+ json_string += ", ";
819
+ }
820
+ }
821
+ json_string += "]";
822
+ json_string += top_level ? "}" : "";
823
+ return json_string;
824
+ }
825
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
826
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateRandomForce<STATE_SPEC>& state, bool top_level=true){
827
+ std::string json_string = top_level ? "{" : "";
828
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
829
+ json_string += "\"force\": [" + std::to_string(state.force[0]) + ", " + std::to_string(state.force[1]) + ", " + std::to_string(state.force[2]) + "], ";
830
+ json_string += "\"torque\": [" + std::to_string(state.torque[0]) + ", " + std::to_string(state.torque[1]) + ", " + std::to_string(state.torque[2]) + "]";
831
+ json_string += top_level ? "}" : "";
832
+ return json_string;
833
+ }
834
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
835
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateTrajectory<STATE_SPEC>& state, bool top_level=true){
836
+ std::string json_string = top_level ? "{" : "";
837
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
838
+ json_string += "\"trajectory\": {";
839
+ json_string += "\"trajectory_step\": " + std::to_string(state.trajectory_step);
840
+ json_string += "}";
841
+ json_string += top_level ? "}" : "";
842
+ return json_string;
843
+ }
844
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
845
+ std::string json(DEVICE& device, const rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, const rl::environments::l2f::StateRenderRotorPhase<STATE_SPEC>& state, bool top_level=true){
846
+ using TI = typename DEVICE::index_t;
847
+ using STATE = rl::environments::l2f::StateRenderRotorPhase<STATE_SPEC>;
848
+ std::string json_string = top_level ? "{" : "";
849
+ json_string += json(device, env, parameters, static_cast<const typename STATE_SPEC::NEXT_COMPONENT&>(state), false) + ", ";
850
+ json_string += "\"rotor_phase\": [";
851
+ for (TI rotor_i = 0; rotor_i < STATE::ACTION_DIM; rotor_i++){
852
+ json_string += std::to_string(state.rotor_phase[rotor_i]);
853
+ if (rotor_i < STATE::ACTION_DIM - 1) {
854
+ json_string += ", ";
855
+ }
856
+ }
857
+ json_string += "]";
858
+ json_string += top_level ? "}" : "";
859
+ return json_string;
860
+ }
861
+ #ifdef RL_TOOLS_ENABLE_JSON
862
+ // chain components nest in any order: every chain overload is visible to every other
863
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
864
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersBase<PARAM_SPEC>& parameters);
865
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
866
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersDisturbances<PARAM_SPEC>& parameters);
867
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
868
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersIMU<PARAM_SPEC>& parameters);
869
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
870
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersCTBRController<PARAM_SPEC>& parameters);
871
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
872
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersDomainRandomization<PARAM_SPEC>& parameters);
873
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
874
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersTrajectory<PARAM_SPEC>& parameters);
875
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
876
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersObservationDelay<PARAM_SPEC>& parameters);
877
+ template <typename DEVICE, typename SPEC, typename T_T, typename T_TI, T_TI N>
878
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::Dynamics<T_T, T_TI, N>& parameters){
879
+ using TI = typename DEVICE::index_t;
880
+ for(const char* key : {"rotor_positions", "rotor_thrust_directions", "rotor_torque_directions", "rotor_thrust_coefficients", "rotor_torque_constants", "rotor_time_constants_rising", "rotor_time_constants_falling"}){
881
+ const auto& values = json_object.at(key);
882
+ if(!values.is_array() || values.size() != N){
883
+ throw std::runtime_error(std::string("l2f::parameters::Dynamics: ") + key + " has " + std::to_string(values.size()) + " entries, expected " + std::to_string(N));
884
+ }
885
+ }
886
+ for (TI i = 0; i < N; i++){
887
+ parameters.rotor_positions[i][0] = json_object["rotor_positions"][i][0];
888
+ parameters.rotor_positions[i][1] = json_object["rotor_positions"][i][1];
889
+ parameters.rotor_positions[i][2] = json_object["rotor_positions"][i][2];
890
+ parameters.rotor_thrust_directions[i][0] = json_object["rotor_thrust_directions"][i][0];
891
+ parameters.rotor_thrust_directions[i][1] = json_object["rotor_thrust_directions"][i][1];
892
+ parameters.rotor_thrust_directions[i][2] = json_object["rotor_thrust_directions"][i][2];
893
+ parameters.rotor_torque_directions[i][0] = json_object["rotor_torque_directions"][i][0];
894
+ parameters.rotor_torque_directions[i][1] = json_object["rotor_torque_directions"][i][1];
895
+ parameters.rotor_torque_directions[i][2] = json_object["rotor_torque_directions"][i][2];
896
+ parameters.rotor_thrust_coefficients[i][0] = json_object["rotor_thrust_coefficients"][i][0];
897
+ parameters.rotor_thrust_coefficients[i][1] = json_object["rotor_thrust_coefficients"][i][1];
898
+ parameters.rotor_thrust_coefficients[i][2] = json_object["rotor_thrust_coefficients"][i][2];
899
+ parameters.rotor_torque_constants[i] = json_object["rotor_torque_constants"][i];
900
+ parameters.rotor_time_constants_rising[i] = json_object["rotor_time_constants_rising"][i];
901
+ parameters.rotor_time_constants_falling[i] = json_object["rotor_time_constants_falling"][i];
902
+ }
903
+
904
+ parameters.mass = json_object["mass"];
905
+ parameters.gravity[0] = json_object["gravity"][0];
906
+ parameters.gravity[1] = json_object["gravity"][1];
907
+ parameters.gravity[2] = json_object["gravity"][2];
908
+
909
+ for (TI i = 0; i < 3; i++) {
910
+ for (TI j = 0; j < 3; j++) {
911
+ parameters.J[i][j] = json_object["J"][i][j];
912
+ parameters.J_inv[i][j] = json_object["J_inv"][i][j];
913
+ }
914
+ }
915
+
916
+ parameters.hovering_throttle_relative = json_object["hovering_throttle_relative"];
917
+ parameters.action_limit.min = json_object["action_limit"]["min"];
918
+ parameters.action_limit.max = json_object["action_limit"]["max"];
919
+ }
920
+ template <typename DEVICE, typename SPEC, typename T>
921
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::IMU<T>& parameters) {
922
+ auto error_model_from_json = [](const nlohmann::json& error_model_json, auto& error_model){
923
+ const auto noise_json = error_model_json.value("noise", nlohmann::json::object());
924
+ error_model.noise.mean = noise_json.value("mean", (T)0);
925
+ error_model.noise.std = noise_json.value("std", (T)0);
926
+ const auto bias_json = error_model_json.value("bias", nlohmann::json::object());
927
+ error_model.bias.init_max = bias_json.value("init_max", (T)0);
928
+ error_model.bias.tau = bias_json.value("tau", (T)0);
929
+ error_model.bias.sigma = bias_json.value("sigma", (T)0);
930
+ };
931
+ error_model_from_json(json_object.value("accelerometer", nlohmann::json::object()).value("error", nlohmann::json::object()), parameters.accelerometer.error);
932
+ error_model_from_json(json_object.value("gyro", nlohmann::json::object()).value("error", nlohmann::json::object()), parameters.gyro.error);
933
+ }
934
+ template <typename DEVICE, typename SPEC, typename T>
935
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::CTBRController<T>& parameters) {
936
+ parameters.thrust_min = json_object["thrust_min"];
937
+ parameters.thrust_max = json_object["thrust_max"];
938
+ for(typename DEVICE::index_t i = 0; i < 3; i++){
939
+ parameters.rate_limit[i] = json_object["rate_limit"][i];
940
+ parameters.kp[i] = json_object["kp"][i];
941
+ parameters.kd[i] = json_object["kd"][i];
942
+ parameters.torque_limit[i] = json_object["torque_limit"][i];
943
+ }
944
+ }
945
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
946
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::Integration<PARAM_SPEC>& parameters) {
947
+ parameters.dt = json_object["dt"];
948
+ }
949
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
950
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::Initialization<PARAM_SPEC>& parameters) {
951
+ parameters.guidance = json_object["guidance"];
952
+ parameters.max_position = json_object["max_position"];
953
+ parameters.max_angle = json_object["max_angle"];
954
+ parameters.max_linear_velocity = json_object["max_linear_velocity"];
955
+ parameters.max_angular_velocity = json_object["max_angular_velocity"];
956
+ parameters.relative_rpm = json_object["relative_rpm"];
957
+ parameters.min_rpm = json_object["min_rpm"];
958
+ parameters.max_rpm = json_object["max_rpm"];
959
+ }
960
+ template <typename DEVICE, typename SPEC, typename T, unsigned T_ACTION_DIM>
961
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::reward_functions::Squared<T, T_ACTION_DIM>& parameters) {
962
+ parameters.non_negative = json_object["non_negative"];
963
+ parameters.scale = json_object["scale"];
964
+ parameters.constant = json_object["constant"];
965
+ parameters.termination_penalty = json_object["termination_penalty"];
966
+ parameters.position = json_object["position"];
967
+ parameters.position_clip = json_object["position_clip"];
968
+ parameters.orientation = json_object["orientation"];
969
+ parameters.linear_velocity = json_object["linear_velocity"];
970
+ parameters.angular_velocity = json_object["angular_velocity"];
971
+ parameters.linear_acceleration = json_object["linear_acceleration"];
972
+ parameters.angular_acceleration = json_object["angular_acceleration"];
973
+ if(json_object["action"].is_array()){
974
+ for(typename DEVICE::index_t action_i = 0; action_i < T_ACTION_DIM; action_i++){
975
+ parameters.action[action_i] = json_object["action"][action_i];
976
+ }
977
+ }
978
+ else{
979
+ T action = json_object["action"];
980
+ for(typename DEVICE::index_t action_i = 0; action_i < T_ACTION_DIM; action_i++){
981
+ parameters.action[action_i] = action;
982
+ }
983
+ }
984
+ if(json_object["d_action"].is_array()){
985
+ for(typename DEVICE::index_t action_i = 0; action_i < T_ACTION_DIM; action_i++){
986
+ parameters.d_action[action_i] = json_object["d_action"][action_i];
987
+ }
988
+ }
989
+ else{
990
+ T d_action = json_object["d_action"];
991
+ for(typename DEVICE::index_t action_i = 0; action_i < T_ACTION_DIM; action_i++){
992
+ parameters.d_action[action_i] = d_action;
993
+ }
994
+ }
995
+ parameters.position_error_integral = json_object["position_error_integral"];
996
+ }
997
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
998
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::Termination<PARAM_SPEC>& parameters) {
999
+ parameters.enabled = json_object["enabled"];
1000
+ parameters.position_threshold = json_object["position_threshold"];
1001
+ parameters.angle_threshold = json_object.value("angle_threshold", (PARAM_SPEC)0);
1002
+ parameters.linear_velocity_threshold = json_object["linear_velocity_threshold"];
1003
+ parameters.angular_velocity_threshold = json_object["angular_velocity_threshold"];
1004
+ parameters.position_integral_threshold = json_object["position_integral_threshold"];
1005
+ parameters.orientation_integral_threshold = json_object["orientation_integral_threshold"];
1006
+ }
1007
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
1008
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::ObservationNoise<PARAM_SPEC>& parameters) {
1009
+ parameters.position = json_object["position"];
1010
+ parameters.orientation = json_object["orientation"];
1011
+ parameters.linear_velocity = json_object["linear_velocity"];
1012
+ parameters.angular_velocity = json_object["angular_velocity"];
1013
+ parameters.imu_acceleration = json_object["imu_acceleration"];
1014
+ }
1015
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
1016
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::ActionNoise<PARAM_SPEC>& parameters) {
1017
+ parameters.normalized_rpm = json_object["normalized_rpm"];
1018
+ }
1019
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
1020
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::MDP<PARAM_SPEC>& parameters) {
1021
+ from_json(device, env, json_object["init"], parameters.init);
1022
+ from_json(device, env, json_object["reward"], parameters.reward);
1023
+ from_json(device, env, json_object["observation_noise"], parameters.observation_noise);
1024
+ from_json(device, env, json_object["action_noise"], parameters.action_noise);
1025
+ from_json(device, env, json_object["termination"], parameters.termination);
1026
+ }
1027
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
1028
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersBase<PARAM_SPEC>& parameters){
1029
+ from_json(device, env, json_object["dynamics"], parameters.dynamics);
1030
+ from_json(device, env, json_object["integration"], parameters.integration);
1031
+ from_json(device, env, json_object["mdp"], parameters.mdp);
1032
+ }
1033
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
1034
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::Disturbances<PARAM_SPEC>& parameters) {
1035
+ parameters.random_force.mean = json_object["random_force"]["mean"];
1036
+ parameters.random_force.std = json_object["random_force"]["std"];
1037
+ parameters.random_torque.mean = json_object["random_torque"]["mean"];
1038
+ parameters.random_torque.std = json_object["random_torque"]["std"];
1039
+ }
1040
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
1041
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersDisturbances<PARAM_SPEC>& parameters){
1042
+ from_json(device, env, json_object, static_cast<typename PARAM_SPEC::NEXT_COMPONENT&>(parameters));
1043
+ from_json(device, env, json_object["disturbances"], parameters.disturbances);
1044
+ }
1045
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
1046
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersIMU<PARAM_SPEC>& parameters){
1047
+ from_json(device, env, json_object, static_cast<typename PARAM_SPEC::NEXT_COMPONENT&>(parameters));
1048
+ if (json_object.contains("imu")){
1049
+ from_json(device, env, json_object["imu"], parameters.imu);
1050
+ }
1051
+ else {
1052
+ parameters.imu = {};
1053
+ }
1054
+ }
1055
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
1056
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersCTBRController<PARAM_SPEC>& parameters){
1057
+ from_json(device, env, json_object, static_cast<typename PARAM_SPEC::NEXT_COMPONENT&>(parameters));
1058
+ from_json(device, env, json_object["ctbr_controller"], parameters.ctbr_controller);
1059
+ }
1060
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
1061
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::DomainRandomization<PARAM_SPEC>& parameters) {
1062
+ parameters.thrust_to_weight_min = json_object["thrust_to_weight_min"];
1063
+ parameters.thrust_to_weight_max = json_object["thrust_to_weight_max"];
1064
+ parameters.torque_to_inertia_min = json_object["torque_to_inertia_min"];
1065
+ parameters.torque_to_inertia_max = json_object["torque_to_inertia_max"];
1066
+ parameters.mass_min = json_object["mass_min"];
1067
+ parameters.mass_max = json_object["mass_max"];
1068
+ parameters.mass_size_deviation = json_object["mass_size_deviation"];
1069
+ parameters.rotor_time_constant_rising_min = json_object["rotor_time_constant_rising_min"];
1070
+ parameters.rotor_time_constant_rising_max = json_object["rotor_time_constant_rising_max"];
1071
+ parameters.rotor_time_constant_falling_min = json_object["rotor_time_constant_falling_min"];
1072
+ parameters.rotor_time_constant_falling_max = json_object["rotor_time_constant_falling_max"];
1073
+ parameters.rotor_torque_constant_min = json_object["rotor_torque_constant_min"];
1074
+ parameters.rotor_torque_constant_max = json_object["rotor_torque_constant_max"];
1075
+ parameters.orientation_offset_angle_max = json_object["orientation_offset_angle_max"];
1076
+ parameters.disturbance_force_max = json_object["disturbance_force_max"];
1077
+ }
1078
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
1079
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersDomainRandomization<PARAM_SPEC>& parameters){
1080
+ from_json(device, env, json_object, static_cast<typename PARAM_SPEC::NEXT_COMPONENT&>(parameters));
1081
+ from_json(device, env, json_object["domain_randomization"], parameters.domain_randomization);
1082
+ }
1083
+ template <typename DEVICE, typename SPEC, typename TRAJ_SPEC>
1084
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::trajectories::Trajectory<TRAJ_SPEC>& trajectory) {
1085
+ using T = typename TRAJ_SPEC::T;
1086
+ using TI = typename DEVICE::index_t;
1087
+ using TRAJECTORY = rl::environments::l2f::parameters::trajectories::Trajectory<TRAJ_SPEC>;
1088
+ rl_tools::utils::assert_exit(device, json_object["LENGTH"] == TRAJECTORY::LENGTH, "Mismatch in trajectory length");
1089
+ T json_dt = json_object["DT"];
1090
+ T traj_dt = TRAJECTORY::DT;
1091
+ rl_tools::utils::assert_exit(device, json_dt == traj_dt, "Mismatch in trajectory dt");
1092
+ for (TI step_i = 0; step_i < TRAJECTORY::LENGTH; step_i++){
1093
+ auto& step = trajectory.steps[step_i];
1094
+ for (TI axis_i=0; axis_i < 3; axis_i++){
1095
+ step.position[axis_i] = json_object["steps"][step_i]["position"][axis_i];
1096
+ step.yaw = json_object["steps"][step_i]["yaw"];
1097
+ step.linear_velocity[axis_i] = json_object["steps"][step_i]["linear_velocity"][axis_i];
1098
+ step.yaw_velocity = json_object["steps"][step_i]["yaw_velocity"];
1099
+ }
1100
+ }
1101
+ }
1102
+ template <typename DEVICE, typename SPEC, typename T>
1103
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::trajectories::lissajous::Parameters<T>& parameters) {
1104
+ parameters.A = json_object["A"];
1105
+ parameters.B = json_object["B"];
1106
+ parameters.C = json_object["C"];
1107
+ parameters.a = json_object["a"];
1108
+ parameters.b = json_object["b"];
1109
+ parameters.c = json_object["c"];
1110
+ // backwards compat, deprecated
1111
+ if (json_object.contains("duration")) {
1112
+ parameters.interval = json_object["duration"];
1113
+ }
1114
+ else {
1115
+ parameters.interval = json_object["interval"];
1116
+ }
1117
+ parameters.ramp_duration = json_object["ramp_duration"];
1118
+ }
1119
+ template <typename DEVICE, typename SPEC, typename TRAJ_PARAM_SPEC>
1120
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::trajectories::TaggedParameters<TRAJ_PARAM_SPEC>& parameters) {
1121
+ std::string type_str = json_object["type"];
1122
+ if (type_str == "LISSAJOUS") {
1123
+ parameters.type = rl::environments::l2f::parameters::trajectories::Type::LISSAJOUS;
1124
+ from_json(device, env, json_object["lissajous"], parameters.parameters.lissajous);
1125
+ }
1126
+ else {
1127
+ utils::assert_exit(device, false, "L2F json import: Unknown trajectory_parameters type");
1128
+ }
1129
+ }
1130
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
1131
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersTrajectory<PARAM_SPEC>& parameters){
1132
+ from_json(device, env, json_object, static_cast<typename PARAM_SPEC::NEXT_COMPONENT&>(parameters));
1133
+ from_json(device, env, json_object["trajectory"], parameters.trajectory);
1134
+ from_json(device, env, json_object["trajectory_parameters"], parameters.trajectory_parameters);
1135
+ }
1136
+ template <typename DEVICE, typename SPEC, typename T, typename TI>
1137
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::parameters::ObservationDelay<T, TI>& parameters) {
1138
+ parameters.linear_velocity = json_object["linear_velocity"];
1139
+ parameters.angular_velocity = json_object["angular_velocity"];
1140
+ }
1141
+ template <typename DEVICE, typename SPEC, typename PARAM_SPEC>
1142
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, nlohmann::json json_object, rl::environments::l2f::ParametersObservationDelay<PARAM_SPEC>& parameters){
1143
+ from_json(device, env, json_object, static_cast<typename PARAM_SPEC::NEXT_COMPONENT&>(parameters));
1144
+ from_json(device, env, json_object["observation_delay"], parameters.observation_delay);
1145
+ }
1146
+ template <typename DEVICE, typename SPEC, typename PARAMETERS>
1147
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, std::string json_string, PARAMETERS& parameters){
1148
+ nlohmann::json json_object = nlohmann::json::parse(json_string);
1149
+ from_json(device, env, json_object, parameters);
1150
+ }
1151
+
1152
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1153
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateBase<STATE_SPEC>& state){
1154
+ using TI = typename DEVICE::index_t;
1155
+ for (TI i = 0; i < 3; i++){
1156
+ state.position[i] = json_object["position"][i];
1157
+ state.orientation[i] = json_object["orientation"][i];
1158
+ state.linear_velocity[i] = json_object["linear_velocity"][i];
1159
+ state.angular_velocity[i] = json_object["angular_velocity"][i];
1160
+ }
1161
+ state.orientation[3] = json_object["orientation"][3];
1162
+ }
1163
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1164
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateLastAction<STATE_SPEC>& state){
1165
+ from_json(device, env, parameters, json_object, static_cast<typename STATE_SPEC::NEXT_COMPONENT&>(state));
1166
+ for (typename DEVICE::index_t action_i = 0; action_i < SPEC::PARAMETERS::N; action_i++){
1167
+ state.last_action[action_i] = json_object["last_action"][action_i];
1168
+ }
1169
+ }
1170
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1171
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateLinearAcceleration<STATE_SPEC>& state){
1172
+ using TI = typename DEVICE::index_t;
1173
+ from_json(device, env, parameters, json_object, static_cast<typename STATE_SPEC::NEXT_COMPONENT&>(state));
1174
+ for (TI i = 0; i < 3; i++){
1175
+ state.linear_acceleration[i] = json_object["linear_acceleration"][i];
1176
+ }
1177
+ }
1178
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1179
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateGyro<STATE_SPEC>& state){
1180
+ using TI = typename DEVICE::index_t;
1181
+ from_json(device, env, parameters, json_object, static_cast<typename STATE_SPEC::NEXT_COMPONENT&>(state));
1182
+ for (TI i = 0; i < 3; i++){
1183
+ state.gyro[i] = json_object["gyro"][i];
1184
+ state.gyro_bias[i] = json_object["gyro_bias"][i];
1185
+ }
1186
+ }
1187
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1188
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateAccelerometer<STATE_SPEC>& state){
1189
+ using TI = typename DEVICE::index_t;
1190
+ from_json(device, env, parameters, json_object, static_cast<typename STATE_SPEC::NEXT_COMPONENT&>(state));
1191
+ for (TI i = 0; i < 3; i++){
1192
+ state.accelerometer[i] = json_object["accelerometer"][i];
1193
+ state.accelerometer_bias[i] = json_object["accelerometer_bias"][i];
1194
+ }
1195
+ }
1196
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1197
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateMahony<STATE_SPEC>& state){
1198
+ using TI = typename DEVICE::index_t;
1199
+ using T = typename STATE_SPEC::T;
1200
+ using STATE = rl::environments::l2f::StateMahony<STATE_SPEC>;
1201
+ from_json(device, env, parameters, json_object, static_cast<typename STATE_SPEC::NEXT_COMPONENT&>(state));
1202
+ if(json_object.contains("q_estimate")){
1203
+ for (TI i = 0; i < 4; i++){
1204
+ state.q_estimate[i] = json_object["q_estimate"][i];
1205
+ }
1206
+ }
1207
+ else if(json_object.contains("world_z_body_estimate")){
1208
+ T world_z_body[3];
1209
+ for (TI i = 0; i < 3; i++){
1210
+ world_z_body[i] = json_object["world_z_body_estimate"][i];
1211
+ }
1212
+ state.q_estimate[0] = 1;
1213
+ state.q_estimate[1] = 0;
1214
+ state.q_estimate[2] = 0;
1215
+ state.q_estimate[3] = 0;
1216
+ rl::environments::l2f::mahony_quaternion_from_accel(device, world_z_body, state.q_estimate);
1217
+ }
1218
+ else{
1219
+ T world_z_body[3];
1220
+ rl::environments::l2f::quaternion_to_world_z_body<DEVICE, T>(state.orientation, world_z_body);
1221
+ state.q_estimate[0] = 1;
1222
+ state.q_estimate[1] = 0;
1223
+ state.q_estimate[2] = 0;
1224
+ state.q_estimate[3] = 0;
1225
+ rl::environments::l2f::mahony_quaternion_from_accel(device, world_z_body, state.q_estimate);
1226
+ }
1227
+ if(json_object.contains("bias_estimate")){
1228
+ for (TI i = 0; i < 3; i++){
1229
+ state.bias_estimate[i] = json_object["bias_estimate"][i];
1230
+ }
1231
+ }
1232
+ else if(json_object.contains("gyro_bias_tangent")){
1233
+ for (TI i = 0; i < 3; i++){
1234
+ state.bias_estimate[i] = json_object["gyro_bias_tangent"][i];
1235
+ }
1236
+ }
1237
+ else{
1238
+ for (TI i = 0; i < 3; i++){
1239
+ state.bias_estimate[i] = 0;
1240
+ }
1241
+ }
1242
+ T q_norm = math::sqrt(device.math,
1243
+ state.q_estimate[0]*state.q_estimate[0] +
1244
+ state.q_estimate[1]*state.q_estimate[1] +
1245
+ state.q_estimate[2]*state.q_estimate[2] +
1246
+ state.q_estimate[3]*state.q_estimate[3]);
1247
+ if(q_norm > (T)1e-12){
1248
+ for(TI i = 0; i < 4; i++){
1249
+ state.q_estimate[i] /= q_norm;
1250
+ }
1251
+ }
1252
+ else{
1253
+ state.q_estimate[0] = 1;
1254
+ state.q_estimate[1] = 0;
1255
+ state.q_estimate[2] = 0;
1256
+ state.q_estimate[3] = 0;
1257
+ }
1258
+ for(TI i = 0; i < 3; i++){
1259
+ state.bias_estimate[i] = math::clamp(device.math, state.bias_estimate[i], -STATE::MAX_BIAS, STATE::MAX_BIAS);
1260
+ }
1261
+ }
1262
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1263
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateCTBRController<STATE_SPEC>& state){
1264
+ using TI = typename DEVICE::index_t;
1265
+ from_json(device, env, parameters, json_object, static_cast<typename STATE_SPEC::NEXT_COMPONENT&>(state));
1266
+ for(TI i = 0; i < 3; i++){
1267
+ state.previous_angular_velocity[i] = json_object["previous_angular_velocity"][i];
1268
+ }
1269
+ }
1270
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1271
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateLinearAccelerationHistory<STATE_SPEC>& state){
1272
+ using TI = typename DEVICE::index_t;
1273
+ using STATE = rl::environments::l2f::StateLinearAccelerationHistory<STATE_SPEC>;
1274
+ from_json(device, env, parameters, json_object, static_cast<typename STATE_SPEC::NEXT_COMPONENT&>(state));
1275
+ const auto& hist = json_object.at("linear_acceleration_body_history");
1276
+ if (hist.size() != STATE_SPEC::HISTORY_LENGTH){
1277
+ throw std::runtime_error("StateLinearAccelerationHistory: linear_acceleration_body_history has " + std::to_string(hist.size()) + " entries, expected " + std::to_string(STATE_SPEC::HISTORY_LENGTH));
1278
+ }
1279
+ for(TI step_i = 0; step_i < STATE_SPEC::HISTORY_LENGTH; step_i++){
1280
+ const auto& step_entry = hist.at(step_i);
1281
+ if (step_entry.size() != STATE::ACCELERATION_DIM){
1282
+ throw std::runtime_error("StateLinearAccelerationHistory: entry " + std::to_string(step_i) + " has " + std::to_string(step_entry.size()) + " components, expected " + std::to_string(STATE::ACCELERATION_DIM));
1283
+ }
1284
+ for(TI dim_i = 0; dim_i < STATE::ACCELERATION_DIM; dim_i++){
1285
+ state.linear_acceleration_body_history[step_i][dim_i] = step_entry.at(dim_i);
1286
+ }
1287
+ }
1288
+ TI raw_step = json_object.at("acceleration_history_step");
1289
+ if constexpr(STATE_SPEC::HISTORY_LENGTH == 0){
1290
+ state.acceleration_history_step = 0;
1291
+ }
1292
+ else{
1293
+ if (raw_step >= STATE_SPEC::HISTORY_LENGTH){
1294
+ throw std::runtime_error("StateLinearAccelerationHistory: acceleration_history_step " + std::to_string(raw_step) + " out of range [0, " + std::to_string(STATE_SPEC::HISTORY_LENGTH) + ")");
1295
+ }
1296
+ state.acceleration_history_step = raw_step;
1297
+ }
1298
+ }
1299
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1300
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateAngularVelocityDelay<STATE_SPEC>& state){
1301
+ using TI = typename DEVICE::index_t;
1302
+ using STATE = rl::environments::l2f::StateAngularVelocityDelay<STATE_SPEC>;
1303
+ from_json(device, env, parameters, json_object, static_cast<typename STATE::NEXT_COMPONENT&>(state));
1304
+ for(TI step_i = 0; step_i < STATE_SPEC::HISTORY_LENGTH; step_i++){
1305
+ for(TI dim_i = 0; dim_i < 3; dim_i++){
1306
+ state.angular_velocity_history[step_i][dim_i] = json_object["angular_velocity_history"][step_i][dim_i];
1307
+ }
1308
+ }
1309
+ }
1310
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1311
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateLinearVelocityDelay<STATE_SPEC>& state){
1312
+ using TI = typename DEVICE::index_t;
1313
+ using STATE = rl::environments::l2f::StateLinearVelocityDelay<STATE_SPEC>;
1314
+ from_json(device, env, parameters, json_object, static_cast<typename STATE::NEXT_COMPONENT&>(state));
1315
+ for(TI step_i = 0; step_i < STATE_SPEC::HISTORY_LENGTH; step_i++){
1316
+ for(TI dim_i = 0; dim_i < 3; dim_i++){
1317
+ state.linear_velocity_history[step_i][dim_i] = json_object["linear_velocity_history"][step_i][dim_i];
1318
+ }
1319
+ }
1320
+ }
1321
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1322
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StatePoseErrorIntegral<STATE_SPEC>& state){
1323
+ from_json(device, env, parameters, json_object, static_cast<typename STATE_SPEC::NEXT_COMPONENT&>(state));
1324
+ state.position_integral[0] = json_object["position_integral"][0];
1325
+ state.position_integral[1] = json_object["position_integral"][1];
1326
+ state.position_integral[2] = json_object["position_integral"][2];
1327
+ state.orientation_integral = json_object["orientation_integral"];
1328
+ }
1329
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1330
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateRotors<STATE_SPEC>& state){
1331
+ using TI = typename DEVICE::index_t;
1332
+ using STATE = rl::environments::l2f::StateRotors<STATE_SPEC>;
1333
+ from_json(device, env, parameters, json_object, static_cast<typename STATE_SPEC::NEXT_COMPONENT&>(state));
1334
+ for (TI action_i = 0; action_i < STATE::ACTION_DIM; action_i++){
1335
+ state.rpm[action_i] = json_object["rpm"][action_i];
1336
+ }
1337
+ }
1338
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1339
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateRotorsHistory<STATE_SPEC>& state){
1340
+ using TI = typename DEVICE::index_t;
1341
+ using STATE = rl::environments::l2f::StateRotorsHistory<STATE_SPEC>;
1342
+ from_json(device, env, parameters, json_object, static_cast<typename STATE::NEXT_COMPONENT&>(state));
1343
+ for(TI step_i = 0; step_i < STATE_SPEC::HISTORY_LENGTH; step_i++){
1344
+ for(TI action_i = 0; action_i < SPEC::PARAMETERS::N; action_i++){
1345
+ state.action_history[step_i][action_i] = json_object["action_history"][step_i][action_i];
1346
+ }
1347
+ }
1348
+ }
1349
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1350
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateRandomForce<STATE_SPEC>& state){
1351
+ using TI = typename DEVICE::index_t;
1352
+ from_json(device, env, parameters, json_object, static_cast<typename STATE_SPEC::NEXT_COMPONENT&>(state));
1353
+ for (TI i = 0; i < 3; i++){
1354
+ state.force[i] = json_object["force"][i];
1355
+ state.torque[i] = json_object["torque"][i];
1356
+ }
1357
+ }
1358
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1359
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateTrajectory<STATE_SPEC>& state){
1360
+ using TI = typename DEVICE::index_t;
1361
+ from_json(device, env, parameters, json_object, static_cast<typename STATE_SPEC::NEXT_COMPONENT&>(state));
1362
+ state.trajectory_step = json_object["trajectory"]["trajectory_step"];
1363
+ }
1364
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE_SPEC>
1365
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, nlohmann::json json_object, rl::environments::l2f::StateRenderRotorPhase<STATE_SPEC>& state){
1366
+ using TI = typename DEVICE::index_t;
1367
+ using STATE = rl::environments::l2f::StateRenderRotorPhase<STATE_SPEC>;
1368
+ from_json(device, env, parameters, json_object, static_cast<typename STATE_SPEC::NEXT_COMPONENT&>(state));
1369
+ for (TI rotor_i = 0; rotor_i < STATE::ACTION_DIM; rotor_i++){
1370
+ state.rotor_phase[rotor_i] = json_object["rotor_phase"][rotor_i];
1371
+ }
1372
+ }
1373
+ template <typename DEVICE, typename SPEC, typename PARAMETERS, typename STATE>
1374
+ void from_json(DEVICE& device, rl::environments::Multirotor<SPEC>& env, const PARAMETERS& parameters, std::string json_string, STATE& state){
1375
+ using TI = typename DEVICE::index_t;
1376
+ nlohmann::json json_object = nlohmann::json::parse(json_string);
1377
+ from_json(device, env, parameters, json_object, state);
1378
+ }
1379
+ #endif
1380
+ template <typename DEVICE, typename SPEC>
1381
+ std::string get_ui(DEVICE& device, rl::environments::Multirotor<SPEC>& env){
1382
+ // just the body of `function render(ctx, state, action) {` (so that it can be easily processed by `new Function("ctx", "state", "action", body)`
1383
+ #ifndef _MSC_VER
1384
+ std::string ui = R"RL_TOOLS_LITERAL(
1385
+
1386
+
1387
+
1388
+
1389
+
1390
+
1391
+
1392
+
1393
+
1394
+
1395
+
1396
+
1397
+
1398
+ import * as THREE from "three"
1399
+ import {OrbitControls} from "three-orbitcontrols"
1400
+ import {GLTFLoader} from "three-gltfloader"
1401
+
1402
+ export class CoordinateSystem{
1403
+ constructor(origin, length=1, diameter=0.01) {
1404
+ this.cs = new THREE.Group()
1405
+ const material_red = new THREE.MeshLambertMaterial({color: 0xAA0000})
1406
+ const material_green = new THREE.MeshLambertMaterial({color: 0x00AA00})
1407
+ const material_blue = new THREE.MeshLambertMaterial({color: 0x0000AA})
1408
+ const line = new THREE.BoxGeometry(length, diameter, diameter)
1409
+ var x = new THREE.Mesh( line, material_red);
1410
+ x.position.set(length/2, 0, 0)
1411
+ var y = new THREE.Mesh( line, material_green);
1412
+ y.position.set(0, length/2, 0)
1413
+ y.rotation.set(0, 0, Math.PI/2)
1414
+ var z = new THREE.Mesh( line, material_blue);
1415
+ z.position.set(0, 0, length/2)
1416
+ z.rotation.set(0, Math.PI/2, 0)
1417
+ this.cs.add(x)
1418
+ this.cs.add(y)
1419
+ this.cs.add(z)
1420
+ this.cs.position.set(origin[0], origin[1], origin[2])
1421
+ }
1422
+ get(){
1423
+ return this.cs
1424
+ }
1425
+ }
1426
+
1427
+ function norm(a){
1428
+ return Math.sqrt(a.map(x => x**2).reduce((a, c) => a + c, 0))
1429
+ }
1430
+
1431
+ function Matrix4FromRotMatTranspose(rotMat){
1432
+ const m = new THREE.Matrix4()
1433
+ m.set(
1434
+ rotMat[0][0], rotMat[1][0], rotMat[2][0], 0,
1435
+ rotMat[0][1], rotMat[1][1], rotMat[2][1], 0,
1436
+ rotMat[0][2], rotMat[1][2], rotMat[2][2], 0,
1437
+ 0, 0, 0, 1)
1438
+ return m
1439
+ }
1440
+
1441
+ function Matrix4FromRotMat(rotMat){
1442
+ const m = new THREE.Matrix4()
1443
+ m.set(
1444
+ rotMat[0][0], rotMat[0][1], rotMat[0][2], 0,
1445
+ rotMat[1][0], rotMat[1][1], rotMat[1][2], 0,
1446
+ rotMat[2][0], rotMat[2][1], rotMat[2][2], 0,
1447
+ 0, 0, 0, 1)
1448
+ return m
1449
+ }
1450
+
1451
+
1452
+
1453
+
1454
+ class State{
1455
+ constructor(canvas, {devicePixelRatio, showAxes=false, capture=false, camera_position=[0.5, 0.5, 1], camera_distance=null, interactive=true, conta_url="/conta/"}){
1456
+ this.canvas = canvas
1457
+ this.IS_MOBILE = this.is_mobile();
1458
+ this.actualDevicePixelRatio = devicePixelRatio || window.devicePixelRatio
1459
+ this.devicePixelRatio = !this.IS_MOBILE ? this.actualDevicePixelRatio : Math.min(this.actualDevicePixelRatio || 1, 2)
1460
+ this.showAxes = showAxes
1461
+ this.cursor_grab = interactive // Instruct the embedding code to make the cursor a grab cursor
1462
+ this.render_tick = 0
1463
+ this.capture = capture
1464
+ this.camera_position = camera_position
1465
+ this.camera_distance = camera_distance
1466
+ this.interactive = interactive
1467
+ this.lastCanvasWidth = 0
1468
+ this.lastCanvasHeight = 0
1469
+ this.conta_url = conta_url
1470
+ }
1471
+
1472
+ is_mobile() {
1473
+ const isIOS = /iP(hone|ad|od)/.test(navigator.platform) || /iPhone|iPad|iPod/.test(navigator.userAgent);
1474
+ const isAndroid = /Android/.test(navigator.userAgent);
1475
+ const isMobile = /Mobi|Android/i.test(navigator.userAgent) || 'ontouchstart' in window || navigator.maxTouchPoints > 0;
1476
+ const isTablet = /iPad|Android(?!.*Mobile)/.test(navigator.userAgent);
1477
+ return isIOS || isAndroid || isMobile || isTablet;
1478
+ }
1479
+
1480
+ async initialize(){
1481
+ const width = this.canvas.width
1482
+ const height = this.canvas.height
1483
+ this.scene = new THREE.Scene();
1484
+ this.camera = new THREE.PerspectiveCamera( 40, width / height, 0.1, 1000 );
1485
+ this.scene.add(this.camera);
1486
+
1487
+ this.renderer = new THREE.WebGLRenderer({
1488
+ canvas: this.canvas,
1489
+ antialias: !this.IS_MOBILE,
1490
+ alpha: !this.IS_MOBILE,
1491
+ powerPreference: this.IS_MOBILE ? 'low-power' : 'high-performance',
1492
+ preserveDrawingBuffer: this.capture && !this.IS_MOBILE
1493
+ });
1494
+
1495
+ this.renderer.setPixelRatio(this.devicePixelRatio)
1496
+ this.renderer.setClearColor(0xffffff, 0);
1497
+
1498
+ this.renderer.setSize(width/this.actualDevicePixelRatio, height/this.actualDevicePixelRatio);
1499
+
1500
+ this.lastCanvasWidth = this.canvas.width
1501
+ this.lastCanvasHeight = this.canvas.height
1502
+
1503
+
1504
+ // canvasContainer.appendChild(this.renderer.domElement );
1505
+
1506
+ this.controls = this.interactive ? new OrbitControls(this.camera, this.renderer.domElement) : null;
1507
+
1508
+ // this.controls.enabled = false;
1509
+ // window.addEventListener('keydown', (event) => {
1510
+ // if (event.key === 'Alt') {
1511
+ // this.controls.enabled = true;
1512
+ // this.canvas.style.cursor = "grab"
1513
+ // }
1514
+ // });
1515
+
1516
+ // window.addEventListener('keyup', (event) => {
1517
+ // if (event.key === 'Alt') {
1518
+ // this.controls.enabled = false;
1519
+ // this.canvas.style.cursor = "default"
1520
+ // }
1521
+ // });
1522
+ this.canvas.title = "Alt+Drag to rotate the camera. Alt+CTRL+Drag to move the camera."
1523
+
1524
+ this.simulator = new THREE.Group()
1525
+ this.simulator.rotation.set(-Math.PI / 2, 0, Math.PI / 2, 'XYZ');
1526
+
1527
+ // const axesHelper = new THREE.AxesHelper(5);
1528
+ // this.scene.add(axesHelper)
1529
+ this.scene.add(this.simulator)
1530
+
1531
+ var light = new THREE.AmbientLight( 0xffffff,0.5 ); // soft white light
1532
+ this.scene.add(light);
1533
+ var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.4 )
1534
+ directionalLight.position.set(-100, 100, 0)
1535
+ directionalLight.target.position.set(0, 0, 0)
1536
+ this.scene.add( directionalLight )
1537
+ var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.3 )
1538
+ directionalLight.position.set(0, 100, 100)
1539
+ directionalLight.target.position.set(0, 0, 0)
1540
+ this.scene.add( directionalLight )
1541
+ var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.2 )
1542
+ directionalLight.position.set(0, 100, -100)
1543
+ directionalLight.target.position.set(0, 0, 0)
1544
+ this.scene.add( directionalLight )
1545
+
1546
+ // this.camera.position.set(...this.camera_position)
1547
+ // this.camera.quaternion.set(-0.14, 0.70, 0.14, 0.68)
1548
+ // this.controls.target.set(0.0, 0.0, 0.0)
1549
+ // this.controls.minDistance = 1
1550
+ // this.controls.minDistance = 5
1551
+ // this.controls.update()
1552
+
1553
+ this.camera_set = false
1554
+ this.THREE = THREE
1555
+ }
1556
+
1557
+ }
1558
+
1559
+
1560
+ function thrust_direction_to_quaternion(thrust_direction){
1561
+ const x = thrust_direction[0];
1562
+ const y = thrust_direction[1];
1563
+ const z = thrust_direction[2];
1564
+
1565
+ const z_unit = [0.0, 0.0, 1.0];
1566
+
1567
+ let cross_x = z_unit[1] * z - z_unit[2] * y;
1568
+ let cross_y = z_unit[2] * x - z_unit[0] * z;
1569
+ let cross_z = z_unit[0] * y - z_unit[1] * x;
1570
+
1571
+ const dot = z_unit[0] * x + z_unit[1] * y + z_unit[2] * z;
1572
+
1573
+ const angle = Math.acos(dot);
1574
+
1575
+ const cross_magnitude = Math.sqrt(cross_x * cross_x + cross_y * cross_y + cross_z * cross_z);
1576
+ if (cross_magnitude != 0) {
1577
+ cross_x /= cross_magnitude;
1578
+ cross_y /= cross_magnitude;
1579
+ cross_z /= cross_magnitude;
1580
+ }
1581
+
1582
+ const half_angle = angle / 2.0;
1583
+ const sin_half_angle = Math.sin(half_angle);
1584
+
1585
+ const qw = Math.cos(half_angle);
1586
+ const qx = cross_x * sin_half_angle;
1587
+ const qy = cross_y * sin_half_angle;
1588
+ const qz = cross_z * sin_half_angle;
1589
+ return [qw, qx, qy, qz];
1590
+ }
1591
+
1592
+ export class DroneMesh{
1593
+ static glbCache = new Map();
1594
+ static gltfLoader = new GLTFLoader();
1595
+
1596
+ constructor(parameters, origin, displayIMUCoordinateSystem, displayActions, conta_url){
1597
+ console.assert(parameters.ui)
1598
+ this.group = new THREE.Group()
1599
+ const url = `${conta_url}${parameters.ui.model}`
1600
+
1601
+ if (DroneMesh.glbCache.has(url)) {
1602
+ this.loaded = DroneMesh.glbCache.get(url)
1603
+ } else {
1604
+ const loadingPromise = DroneMesh.gltfLoader.loadAsync(url).then((gltf) => {
1605
+ return gltf
1606
+ }).catch((error) => {
1607
+ DroneMesh.glbCache.delete(url)
1608
+ throw error
1609
+ })
1610
+
1611
+ DroneMesh.glbCache.set(url, loadingPromise)
1612
+ this.loaded = loadingPromise
1613
+ }
1614
+
1615
+ this.loaded.then((gltf) => {
1616
+ const object = gltf.scene.clone()
1617
+ const object_group = new THREE.Group()
1618
+ object_group.add(object)
1619
+ // if(parameters.ui.name == "x500"){
1620
+ object_group.rotation.set(Math.PI / 2, 0, Math.PI / 2, 'ZYX')
1621
+ const scale = 0.5
1622
+ object_group.scale.set(scale, scale, scale)
1623
+ // }
1624
+ this.group.add(object_group)
1625
+ })
1626
+ if (displayIMUCoordinateSystem) {
1627
+ const scale = 1 //model.mass
1628
+ const coordinateSystemLength = Math.cbrt(scale)
1629
+ const coordinateSystemThickness = 0.01 * coordinateSystemLength
1630
+ this.group.add((new CoordinateSystem([0, 0, 0], coordinateSystemLength, coordinateSystemThickness)).get())
1631
+ }
1632
+ }
1633
+ get(){
1634
+ return this.group
1635
+ }
1636
+ set_action(action){ }
1637
+ }
1638
+
1639
+ export class DroneDefault{
1640
+ constructor(parameters, origin, displayIMUCoordinateSystem, displayActions){
1641
+ const url = window.location.href;
1642
+ const urlObj = new URL(url);
1643
+ const params = new URLSearchParams(urlObj.search);
1644
+ if(params.has('L2FDisplayActions') === true){
1645
+ displayActions = params.get('L2FDisplayActions') === "true";
1646
+ }
1647
+
1648
+ // console.log(model)
1649
+ this.origin = origin
1650
+ this.parameters = parameters
1651
+ this.droneFrame = new THREE.Group()
1652
+ this.drone = new THREE.Group()
1653
+ if(origin){
1654
+ this.drone.position.set(...origin)
1655
+ }
1656
+ // this.drone.add((new CoordinateSystem()).get())
1657
+ // this.drone.add((new CoordinateSystem(10 * this.scale, 0.1 * this.scale)).get())
1658
+ this.scale = parameters.dynamics.mass
1659
+ const material = new THREE.MeshLambertMaterial({color: 0xAAAAAA})
1660
+ const clockwise_rotor_material = new THREE.MeshLambertMaterial({color: 0x00FF00})
1661
+ const counter_clockwise_rotor_material = new THREE.MeshLambertMaterial({color: 0xFF0000})
1662
+
1663
+ const coordinateSystemLength = Math.cbrt(this.scale)
1664
+ const coordinateSystemThickness = 0.01 * coordinateSystemLength
1665
+
1666
+ const centerSize = Math.cbrt(this.scale) / 15
1667
+ const centerForm = new THREE.BoxGeometry(centerSize, centerSize, centerSize*0.3)
1668
+ const center = new THREE.Mesh( centerForm, material);
1669
+
1670
+ this.parameters.dynamics["imu_position"] = [0, 0, 0]
1671
+ this.parameters.dynamics["imu_orientation"] = [1, 0, 0, 0]
1672
+
1673
+ this.imuGroup = new THREE.Group()
1674
+ this.imuGroup.position.set(...this.parameters.dynamics.imu_position)
1675
+ this.imuGroup.quaternion.set(this.parameters.dynamics.imu_orientation[1], this.parameters.dynamics.imu_orientation[2], this.parameters.dynamics.imu_orientation[3], this.parameters.dynamics.imu_orientation[0])
1676
+ if (displayIMUCoordinateSystem) {
1677
+ this.imuGroup.add((new CoordinateSystem([0, 0, 0], coordinateSystemLength, coordinateSystemThickness)).get())
1678
+ }
1679
+ this.drone.add(this.imuGroup)
1680
+ this.drone.add(center)
1681
+
1682
+ this.rotors = []
1683
+
1684
+ const averageArmLength = this.parameters.dynamics.rotor_positions.map(position => norm(position)).reduce((a, c) => a + c, 0) / this.parameters.dynamics.rotor_positions.length
1685
+ for(const [rotorIndex, rotor_position] of this.parameters.dynamics.rotor_positions.entries()){
1686
+ let rotorCageRadiusFactor = 1
1687
+ let rotorCageThicknessFactor = 1
1688
+ const rotorCageRadius = averageArmLength/3 * Math.sqrt(rotorCageRadiusFactor)
1689
+ const rotorCageThickness = averageArmLength/20 * Math.sqrt(rotorCageThicknessFactor)
1690
+ const armGroup = new THREE.Group()
1691
+ const length = norm(rotor_position)
1692
+ const armDiameter = averageArmLength/10
1693
+ const armLength = length - rotorCageRadius
1694
+ const armForm = new THREE.CylinderGeometry( armDiameter/2, armDiameter/2, armLength, 8 );
1695
+ const rot = new THREE.Quaternion(); // Geometry extends in y -> transform y to relative pos
1696
+ rot.setFromUnitVectors(new THREE.Vector3(...[0, 1, 0]), (new THREE.Vector3(...rotor_position)).normalize());
1697
+ armGroup.quaternion.set(rot.x, rot.y, rot.z, rot.w)
1698
+
1699
+ const arm = new THREE.Mesh(armForm, material)
1700
+ arm.position.set(0, armLength/2, 0)
1701
+ armGroup.add(arm)
1702
+
1703
+ const rotorGroup = new THREE.Group()
1704
+ rotorGroup.position.set(...rotor_position)
1705
+
1706
+ const thrust_orientation = thrust_direction_to_quaternion(this.parameters.dynamics.rotor_thrust_directions[rotorIndex])
1707
+ rotorGroup.quaternion.set(thrust_orientation[3], thrust_orientation[0], thrust_orientation[1], thrust_orientation[2])
1708
+ // rotorGroup.add((new CoordinateSystem([0, 0, 0], 0.1, 0.01)).get())
1709
+ const rotorCageForm = new THREE.TorusGeometry(rotorCageRadius, rotorCageThickness, 16, 32 );
1710
+ const cageMaterial = (this.parameters.dynamics.rotor_thrust_directions[rotorIndex][2] < 0 ? clockwise_rotor_material : counter_clockwise_rotor_material)// new THREE.MeshLambertMaterial({color: 0xAAAAAA})
1711
+ const rotorCage = new THREE.Mesh(rotorCageForm, cageMaterial)
1712
+ rotorGroup.add(rotorCage)
1713
+
1714
+ const forceArrow = new THREE.ArrowHelper(new THREE.Vector3(0,0,1), new THREE.Vector3(0,0,0 ), 0, 0x000000);
1715
+ if(displayActions){
1716
+ rotorGroup.add(forceArrow)
1717
+ }
1718
+
1719
+ this.drone.add(rotorGroup)
1720
+ this.drone.add(armGroup)
1721
+ this.droneFrame.add(this.drone)
1722
+ this.rotors.push({
1723
+ forceArrow,
1724
+ rotorCage
1725
+ })
1726
+ }
1727
+
1728
+ }
1729
+ get(){
1730
+ return this.droneFrame
1731
+ }
1732
+ // setState(state){
1733
+ // const mat = Matrix4FromRotMat(state.orientation)
1734
+ // this.droneFrame.quaternion.setFromRotationMatrix(mat)
1735
+ // this.droneFrame.position.set(state.pose.position[0] + this.origin[0], state.pose.position[1] + this.origin[1], state.pose.position[2] + this.origin[2])
1736
+ // const avg_rot_rate = state.rotor_states.reduce((a, c) => a + c["power"], 0)/state.rotor_states.length
1737
+ // state.rotor_states.map((rotorState, i) => {
1738
+ // const forceArrow = this.rotors[i].forceArrow
1739
+ // const rotorCage = this.rotors[i].rotorCage
1740
+ // const min_rpm = this.model.rotors[i].min_rpm
1741
+ // const max_rpm = this.model.rotors[i].max_rpm
1742
+
1743
+
1744
+ // const rot_rate = rotorState["power"]
1745
+ // const force_magnitude = (rot_rate - avg_rot_rate)/max_rpm * 10///1000
1746
+ // forceArrow.setDirection(new THREE.Vector3(0, 0, rot_rate)) //Math.sign(force_magnitude)))
1747
+ // forceArrow.setLength(Math.cbrt(this.this.scale)/10) //Math.abs(force_magnitude))
1748
+ // })
1749
+ // }
1750
+ set_action(action){
1751
+ for(let i = 0; i < 4; i++){
1752
+ const forceArrow = this.rotors[i].forceArrow
1753
+ const force_magnitude = action[i]
1754
+ forceArrow.setDirection(new THREE.Vector3(0, 0, force_magnitude))
1755
+ forceArrow.setLength(Math.cbrt(this.scale)/10)
1756
+ }
1757
+ }
1758
+
1759
+ }
1760
+
1761
+ async function drone_factory(parameters, origin, displayIMUCoordinateSystem, displayActions, conta_url){
1762
+ if(parameters.ui && parameters.ui.enable && parameters.ui.model){
1763
+ try{
1764
+ const model = new DroneMesh(parameters, origin, displayIMUCoordinateSystem, displayActions, conta_url)
1765
+ await model.loaded
1766
+ return model
1767
+ }
1768
+ catch(error){
1769
+ console.error("An error occurred:", error.message);
1770
+ }
1771
+ }
1772
+ return new DroneDefault(parameters, origin, displayIMUCoordinateSystem, displayActions)
1773
+ }
1774
+
1775
+ export async function init(canvas, options){
1776
+ const state = new State(canvas, options)
1777
+ await state.initialize()
1778
+ return state
1779
+ }
1780
+ function clear_episode(ui_state){
1781
+ if(ui_state.drone){
1782
+ ui_state.simulator.remove(ui_state.drone.get())
1783
+ if(ui_state.showAxes){
1784
+ ui_state.simulator.remove(ui_state.origin_coordinate_system.get())
1785
+ }
1786
+ }
1787
+ if(ui_state.drones){
1788
+ ui_state.drones.map(drone => ui_state.simulator.remove(drone.get()))
1789
+ if(ui_state.showAxes){
1790
+ ui_state.origin_coordinate_systems.map(cs => ui_state.simulator.remove(cs.get()))
1791
+ }
1792
+ }
1793
+ // Clear trajectory visualization
1794
+ if(ui_state.trajectoryVis){
1795
+ ui_state.simulator.remove(ui_state.trajectoryVis.group)
1796
+ ui_state.trajectoryVis = null
1797
+ }
1798
+ if(ui_state.trajectoryVisArray){
1799
+ ui_state.trajectoryVisArray.forEach(tv => {
1800
+ if(tv) ui_state.simulator.remove(tv.group)
1801
+ })
1802
+ ui_state.trajectoryVisArray = null
1803
+ }
1804
+ }
1805
+ function set_camera(ui_state, distance, target){
1806
+ const scale = 1/Math.sqrt(ui_state.camera_position[0]**2 + ui_state.camera_position[1]**2 + ui_state.camera_position[2]**2) * distance
1807
+ const tx = target ? target[0] : 0
1808
+ const ty = target ? target[1] : 0
1809
+ const tz = target ? target[2] : 0
1810
+ if(!ui_state.camera_set){
1811
+ ui_state.camera.position.set(ui_state.camera_position[0] * scale + tx, ui_state.camera_position[1] * scale + ty, ui_state.camera_position[2] * scale + tz)
1812
+ ui_state.camera.lookAt(tx, ty, tz)
1813
+ if(ui_state.controls){
1814
+ ui_state.controls.target.set(tx, ty, tz)
1815
+ }
1816
+ ui_state.camera_set = true
1817
+ if(ui_state.controls) ui_state.controls.update()
1818
+ }
1819
+ }
1820
+ export async function episode_init(ui_state, parameters){
1821
+ let distance = (parameters.ui && parameters.ui.camera_distance) ? parameters.ui.camera_distance : Math.cbrt(parameters.dynamics.mass) * 2
1822
+ if(ui_state.camera_distance){
1823
+ distance = ui_state.camera_distance
1824
+ }
1825
+ set_camera(ui_state, distance)
1826
+ clear_episode(ui_state)
1827
+ ui_state.drone = await drone_factory(parameters, [0, 0, 0], ui_state.showAxes, false, ui_state.conta_url)
1828
+ ui_state.simulator.add(ui_state.drone.get())
1829
+ const scale = parameters.dynamics.mass
1830
+ if(ui_state.showAxes){
1831
+ ui_state.origin_coordinate_system = new CoordinateSystem([0, 0, 0], 1 * scale, 0.01 * scale)
1832
+ ui_state.simulator.add(ui_state.origin_coordinate_system.get())
1833
+ }
1834
+ ui_state.trajectoryVis = create_trajectory_visualization(parameters, scale)
1835
+ if(ui_state.trajectoryVis){
1836
+ ui_state.simulator.add(ui_state.trajectoryVis.group)
1837
+ }
1838
+ await setup_onboard_camera(ui_state, parameters)
1839
+ }
1840
+
1841
+ export async function episode_init_multi(ui_state, parameters){
1842
+ const grid_distance = 0.0
1843
+ const grid_size = Math.ceil(Math.sqrt(parameters.length))
1844
+ let distance = (grid_distance > 0 ? grid_distance * grid_size * 2 : Math.cbrt(parameters[0].dynamics.mass))
1845
+ if(parameters.ui && parameters.ui.camera_distance){
1846
+ distance = parameters.ui.camera_distance
1847
+ }
1848
+ if(ui_state.camera_distance){
1849
+ distance = ui_state.camera_distance
1850
+ }
1851
+ set_camera(ui_state, distance)
1852
+ clear_episode(ui_state)
1853
+ ui_state.drones = []
1854
+ ui_state.trajectoryVisArray = []
1855
+ if(!ui_state.showAxes && ui_state.origin_coordinate_systems){
1856
+ ui_state.origin_coordinate_systems.forEach(cs => {
1857
+ ui_state.simulator.remove(cs.get())
1858
+ })
1859
+ }
1860
+ ui_state.origin_coordinate_systems = []
1861
+ await Promise.all(parameters.map(async (parameter, i) => {
1862
+ const x = (i % grid_size) * grid_distance
1863
+ const y = Math.floor(i / grid_size) * grid_distance
1864
+ const drone = await drone_factory(parameter, [x, y, 0], ui_state.showAxes, false, ui_state.conta_url)
1865
+ ui_state.simulator.add(drone.get())
1866
+ if(ui_state.showAxes){
1867
+ const cs = new CoordinateSystem([x, y, 0], 1, 0.01)
1868
+ ui_state.simulator.add(cs.get())
1869
+ ui_state.origin_coordinate_systems.push(cs)
1870
+ }
1871
+ ui_state.drones.push(drone)
1872
+ // Create trajectory visualization for first N drones only (performance optimization)
1873
+ const MAX_TRAJECTORY_VISUALIZATIONS = 5
1874
+ if(i < MAX_TRAJECTORY_VISUALIZATIONS){
1875
+ const scale = parameter.dynamics.mass
1876
+ const trajectoryVis = create_trajectory_visualization(parameter, scale)
1877
+ if(trajectoryVis){
1878
+ // Offset trajectory to match drone grid position
1879
+ trajectoryVis.group.position.set(x, y, 0)
1880
+ ui_state.simulator.add(trajectoryVis.group)
1881
+ }
1882
+ ui_state.trajectoryVisArray.push(trajectoryVis)
1883
+ } else {
1884
+ ui_state.trajectoryVisArray.push(null)
1885
+ }
1886
+ }))
1887
+ await setup_onboard_camera(ui_state, parameters[0])
1888
+ }
1889
+
1890
+ function get_desired_onboard_dims(parameters){
1891
+ const visual = parameters && parameters.visual
1892
+ if(visual && visual.cam_width && visual.cam_height && visual.fov){
1893
+ return {
1894
+ cam_w: visual.cam_width,
1895
+ cam_h: visual.cam_height,
1896
+ fov: visual.fov,
1897
+ }
1898
+ }
1899
+ throw new Error("get_desired_onboard_dims: parameters.visual is missing cam_width/cam_height")
1900
+ }
1901
+
1902
+ // parameters.visual.fov is the horizontal FOV in degrees, matching rendering::make_camera_data
1903
+ function onboard_vertical_fov_degrees(horizontal_fov_degrees, aspect){
1904
+ const horizontal_fov = horizontal_fov_degrees * Math.PI / 180
1905
+ return 2 * Math.atan(Math.tan(horizontal_fov / 2) / aspect) * 180 / Math.PI
1906
+ }
1907
+
1908
+ function ensure_onboard_render_state(ui_state, cam_w, cam_h, fov_degrees){
1909
+ if(!ui_state.onboard_scene) return
1910
+ const aspect = cam_w / cam_h
1911
+ const vfov_deg = onboard_vertical_fov_degrees(fov_degrees, aspect)
1912
+ let rt_changed = false
1913
+ if(!ui_state.onboard_render_target){
1914
+ ui_state.onboard_render_target = new THREE.WebGLRenderTarget(cam_w, cam_h)
1915
+ rt_changed = true
1916
+ } else if(ui_state.onboard_render_target.width !== cam_w || ui_state.onboard_render_target.height !== cam_h){
1917
+ ui_state.onboard_render_target.setSize(cam_w, cam_h)
1918
+ rt_changed = true
1919
+ }
1920
+ const buf_size = cam_w * cam_h * 4
1921
+ if(!ui_state.onboard_pixel_buffer || ui_state.onboard_pixel_buffer.length !== buf_size){
1922
+ ui_state.onboard_pixel_buffer = new Uint8Array(buf_size)
1923
+ }
1924
+ if(ui_state.onboard_camera){
1925
+ const eps = 1e-4
1926
+ if(Math.abs(ui_state.onboard_camera.aspect - aspect) > eps || Math.abs(ui_state.onboard_camera.fov - vfov_deg) > eps){
1927
+ ui_state.onboard_camera.aspect = aspect
1928
+ ui_state.onboard_camera.fov = vfov_deg
1929
+ ui_state.onboard_camera.updateProjectionMatrix()
1930
+ }
1931
+ }
1932
+ ui_state.onboard_overlay_max_extent = Math.max(cam_w, cam_h) * 3
1933
+ if(rt_changed){
1934
+ ui_state.onboard_overlay_quad = null
1935
+ ui_state.onboard_overlay_blit_scene = null
1936
+ ui_state.onboard_overlay_blit_camera = null
1937
+ }
1938
+ }
1939
+
1940
+ async function setup_onboard_camera(ui_state, parameters){
1941
+ const visual = parameters.visual
1942
+ if(!visual || !visual.scene_hash || visual.scene_hash === '0000000000000000000000000000000000000000') return
1943
+ const dims = get_desired_onboard_dims(parameters)
1944
+ const aspect = dims.cam_w / dims.cam_h
1945
+ const vfov_deg = onboard_vertical_fov_degrees(dims.fov, aspect)
1946
+ ui_state.onboard_camera = new THREE.PerspectiveCamera(vfov_deg, aspect, 0.05, 100)
1947
+ ui_state.onboard_scene = new THREE.Scene()
1948
+ ui_state.onboard_scene.background = new THREE.Color(0x87CEEB)
1949
+ const ambient = new THREE.AmbientLight(0xffffff, 0.6)
1950
+ ui_state.onboard_scene.add(ambient)
1951
+ const dir_light = new THREE.DirectionalLight(0xffffff, 0.8)
1952
+ dir_light.position.set(5, 10, 5)
1953
+ ui_state.onboard_scene.add(dir_light)
1954
+ const scene_url = `${ui_state.conta_url}${visual.scene_hash}`
1955
+ try {
1956
+ const prev_enabled = THREE.ColorManagement.enabled
1957
+ THREE.ColorManagement.enabled = false
1958
+ const gltf = await new GLTFLoader().loadAsync(scene_url)
1959
+ THREE.ColorManagement.enabled = prev_enabled
1960
+ ui_state.onboard_scene.add(gltf.scene)
1961
+ } catch(e) {
1962
+ console.error('Failed to load scene GLB for onboard camera:', e)
1963
+ ui_state.onboard_camera = null
1964
+ ui_state.onboard_scene = null
1965
+ }
1966
+ ui_state.onboard_scene_translation = visual.scene_translation || [0, 0, 0]
1967
+ ensure_onboard_render_state(ui_state, dims.cam_w, dims.cam_h, dims.fov)
1968
+ }
1969
+
1970
+ function update_onboard_camera(ui_state, state, parameters){
1971
+ if(!ui_state.onboard_camera || !ui_state.onboard_scene) return
1972
+ const st = ui_state.onboard_scene_translation || [0, 0, 0]
1973
+ // FLU (X-fwd, Y-left, Z-up) → Three.js Y-up: (x,y,z) → (x, z, -y)
1974
+ // st is in FLU coordinates
1975
+ ui_state.onboard_camera.position.set(state.position[0] + st[0], state.position[2] + st[2], -(state.position[1] + st[1]))
1976
+ // FLU quat axis (ax,ay,az) → Three.js axis (ax, az, -ay)
1977
+ const qw = state.orientation[0], qx = state.orientation[1], qy = state.orientation[2], qz = state.orientation[3]
1978
+ const scene_quat = new THREE.Quaternion(qx, qz, -qy, qw)
1979
+ // Camera forward = body +X = Three.js +X, Three.js camera looks along -Z
1980
+ const body_to_cam = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), -Math.PI / 2)
1981
+ ui_state.onboard_camera.quaternion.copy(scene_quat.multiply(body_to_cam))
1982
+ }
1983
+
1984
+ function render_onboard_overlay(ui_state){
1985
+ if(!ui_state.onboard_camera || !ui_state.onboard_scene || !ui_state.renderer) return
1986
+ const max_extent = ui_state.onboard_overlay_max_extent || 128
1987
+ const rt = ui_state.onboard_render_target
1988
+ const rt_aspect = (rt && rt.width && rt.height) ? (rt.width / rt.height) : (ui_state.onboard_camera.aspect || 1)
1989
+ const overlay_w = rt_aspect >= 1 ? max_extent : Math.max(1, Math.round(max_extent * rt_aspect))
1990
+ const overlay_h = rt_aspect >= 1 ? Math.max(1, Math.round(max_extent / rt_aspect)) : max_extent
1991
+ const margin = 10
1992
+ const canvas_w = ui_state.canvas.width / ui_state.devicePixelRatio
1993
+ const canvas_h = ui_state.canvas.height / ui_state.devicePixelRatio
1994
+ const x = canvas_w - overlay_w - margin
1995
+ const prev_autoClear = ui_state.renderer.autoClear
1996
+ ui_state.renderer.autoClear = false
1997
+ ui_state.renderer.setScissorTest(true)
1998
+ ui_state.renderer.setViewport(x, margin, overlay_w, overlay_h)
1999
+ ui_state.renderer.setScissor(x, margin, overlay_w, overlay_h)
2000
+ ui_state.renderer.clearDepth()
2001
+ if(ui_state.onboard_obs_resolution && ui_state.onboard_render_target){
2002
+ if(!ui_state.onboard_overlay_quad){
2003
+ const geo = new THREE.PlaneGeometry(2, 2)
2004
+ const mat = new THREE.MeshBasicMaterial({map: ui_state.onboard_render_target.texture, depthTest: false})
2005
+ mat.map.magFilter = THREE.NearestFilter
2006
+ ui_state.onboard_overlay_quad = new THREE.Mesh(geo, mat)
2007
+ ui_state.onboard_overlay_blit_scene = new THREE.Scene()
2008
+ ui_state.onboard_overlay_blit_scene.add(ui_state.onboard_overlay_quad)
2009
+ ui_state.onboard_overlay_blit_camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1)
2010
+ }
2011
+ ui_state.renderer.render(ui_state.onboard_overlay_blit_scene, ui_state.onboard_overlay_blit_camera)
2012
+ } else {
2013
+ ui_state.renderer.render(ui_state.onboard_scene, ui_state.onboard_camera)
2014
+ }
2015
+ ui_state.renderer.setScissorTest(false)
2016
+ ui_state.renderer.setViewport(0, 0, canvas_w, canvas_h)
2017
+ ui_state.renderer.autoClear = prev_autoClear
2018
+ }
2019
+
2020
+ export async function setup_onboard_scene(ui_state, scene_hash, cam_w, cam_h, fov_degrees){
2021
+ const aspect = cam_w / cam_h
2022
+ const vfov_deg = onboard_vertical_fov_degrees(fov_degrees, aspect)
2023
+ ui_state.onboard_camera = new THREE.PerspectiveCamera(vfov_deg, aspect, 0.05, 100)
2024
+ ui_state.onboard_scene = new THREE.Scene()
2025
+ ui_state.onboard_scene.background = new THREE.Color(0x87CEEB)
2026
+ ui_state.onboard_scene.add(new THREE.AmbientLight(0xffffff, 0.6))
2027
+ const dir_light = new THREE.DirectionalLight(0xffffff, 0.8)
2028
+ dir_light.position.set(5, 10, 5)
2029
+ ui_state.onboard_scene.add(dir_light)
2030
+ if(scene_hash && scene_hash !== 'none'){
2031
+ const scene_url = `${ui_state.conta_url}${scene_hash}`
2032
+ try {
2033
+ const prev_enabled = THREE.ColorManagement.enabled
2034
+ THREE.ColorManagement.enabled = false
2035
+ const gltf = await new GLTFLoader().loadAsync(scene_url)
2036
+ THREE.ColorManagement.enabled = prev_enabled
2037
+ ui_state.onboard_scene.add(gltf.scene)
2038
+ } catch(e) {
2039
+ console.error('Failed to load scene GLB:', e)
2040
+ }
2041
+ }
2042
+ ui_state.onboard_scene_translation = [0, 0, 0]
2043
+ ensure_onboard_render_state(ui_state, cam_w, cam_h, fov_degrees)
2044
+ }
2045
+
2046
+ export function render_onboard_pixels(ui_state, state, parameters){
2047
+ if(!ui_state.onboard_camera || !ui_state.onboard_scene || !ui_state.renderer) return null
2048
+ const dims = get_desired_onboard_dims(parameters)
2049
+ ensure_onboard_render_state(ui_state, dims.cam_w, dims.cam_h, dims.fov)
2050
+ if(!ui_state.onboard_render_target) return null
2051
+ update_onboard_camera(ui_state, state, parameters)
2052
+ ui_state.renderer.setRenderTarget(ui_state.onboard_render_target)
2053
+ ui_state.renderer.render(ui_state.onboard_scene, ui_state.onboard_camera)
2054
+ ui_state.renderer.setRenderTarget(null)
2055
+ const w = ui_state.onboard_render_target.width, h = ui_state.onboard_render_target.height
2056
+ ui_state.renderer.readRenderTargetPixels(ui_state.onboard_render_target, 0, 0, w, h, ui_state.onboard_pixel_buffer)
2057
+ const rgb = new Float32Array(w * h * 3)
2058
+ for(let y = 0; y < h; y++){
2059
+ const src_y = h - 1 - y
2060
+ for(let x = 0; x < w; x++){
2061
+ const dst = (y * w + x) * 3
2062
+ const src = (src_y * w + x) * 4
2063
+ rgb[dst + 0] = ui_state.onboard_pixel_buffer[src + 0] / 255
2064
+ rgb[dst + 1] = ui_state.onboard_pixel_buffer[src + 1] / 255
2065
+ rgb[dst + 2] = ui_state.onboard_pixel_buffer[src + 2] / 255
2066
+ }
2067
+ }
2068
+ return rgb
2069
+ }
2070
+
2071
+ function update_camera(ui_state){
2072
+ const currentWidth = ui_state.canvas.width
2073
+ const currentHeight = ui_state.canvas.height
2074
+ const hasResized = currentWidth !== ui_state.lastCanvasWidth || currentHeight !== ui_state.lastCanvasHeight
2075
+
2076
+ if (hasResized) {
2077
+ const width = currentWidth / ui_state.devicePixelRatio;
2078
+ const height = currentHeight / ui_state.devicePixelRatio;
2079
+
2080
+ if (ui_state.camera.aspect !== width / height) {
2081
+ ui_state.camera.aspect = width / height;
2082
+ ui_state.camera.updateProjectionMatrix();
2083
+ }
2084
+
2085
+ if (ui_state.renderer) {
2086
+ ui_state.renderer.setPixelRatio(ui_state.devicePixelRatio);
2087
+ ui_state.renderer.setSize(width, height, false);
2088
+ }
2089
+
2090
+ ui_state.lastCanvasWidth = currentWidth
2091
+ ui_state.lastCanvasHeight = currentHeight
2092
+ }
2093
+
2094
+ if(ui_state.interactive && ui_state.controls){
2095
+ ui_state.controls.update()
2096
+ }
2097
+ if(ui_state.renderer){
2098
+ ui_state.renderer.render(ui_state.scene, ui_state.camera);
2099
+ }
2100
+ ui_state.render_tick += 1
2101
+ }
2102
+
2103
+ function clip_position(scale, position){
2104
+ const extent = Math.cbrt(scale) * 300 // to maybe prevent threejs from exploding
2105
+ const max_position = extent
2106
+ const min_position = -extent
2107
+ return position.map((p) => {
2108
+ if(p > max_position){
2109
+ return max_position
2110
+ }
2111
+ else if(p < min_position){
2112
+ return min_position
2113
+ }
2114
+ else{
2115
+ return p
2116
+ }
2117
+ })
2118
+ }
2119
+
2120
+ function get_trajectory_index(trajectory_step, trajectory_length){
2121
+ const full_step = trajectory_step
2122
+ const interval = Math.floor(full_step / trajectory_length)
2123
+ const forward = interval % 2 === 0
2124
+ const progress = full_step % trajectory_length
2125
+ const position = forward ? progress : (trajectory_length - progress - 1)
2126
+ return position
2127
+ }
2128
+
2129
+ function create_trajectory_visualization(parameters, scale){
2130
+ if(!parameters.trajectory || !parameters.trajectory.steps){
2131
+ return null
2132
+ }
2133
+ const trajectory = parameters.trajectory
2134
+ const steps = trajectory.steps
2135
+ if(steps.length < 2){
2136
+ return null
2137
+ }
2138
+
2139
+ const group = new THREE.Group()
2140
+
2141
+ // Create trajectory line
2142
+ const points = steps.map(step => new THREE.Vector3(step.position[0], step.position[1], step.position[2]))
2143
+ const curve = new THREE.CatmullRomCurve3(points, false)
2144
+ const lineThickness = Math.cbrt(scale) * 0.02
2145
+ const tubeGeometry = new THREE.TubeGeometry(curve, steps.length * 4, lineThickness, 8, false)
2146
+ const lineMaterial = new THREE.MeshLambertMaterial({color: 0x4488FF, transparent: true, opacity: 0.6})
2147
+ const trajectoryMesh = new THREE.Mesh(tubeGeometry, lineMaterial)
2148
+ group.add(trajectoryMesh)
2149
+
2150
+ // Create bug (target indicator sphere)
2151
+ const bugRadius = Math.cbrt(scale) * 0.05
2152
+ const bugGeometry = new THREE.SphereGeometry(bugRadius, 16, 16)
2153
+ const bugMaterial = new THREE.MeshLambertMaterial({color: 0xFF4444, emissive: 0x441111})
2154
+ const bug = new THREE.Mesh(bugGeometry, bugMaterial)
2155
+ bug.position.set(steps[0].position[0], steps[0].position[1], steps[0].position[2])
2156
+ group.add(bug)
2157
+
2158
+ return {
2159
+ group: group,
2160
+ bug: bug,
2161
+ steps: steps,
2162
+ length: trajectory.LENGTH || steps.length
2163
+ }
2164
+ }
2165
+
2166
+ function update_trajectory_bug(trajectoryVis, trajectory_step){
2167
+ if(!trajectoryVis || !trajectoryVis.bug || trajectory_step === undefined){
2168
+ return
2169
+ }
2170
+ const index = get_trajectory_index(trajectory_step, trajectoryVis.length)
2171
+ const step = trajectoryVis.steps[index]
2172
+ if(step){
2173
+ trajectoryVis.bug.position.set(step.position[0], step.position[1], step.position[2])
2174
+ }
2175
+ }
2176
+
2177
+ export async function render(ui_state, parameters, state, action) {
2178
+ if(ui_state.drone){
2179
+ ui_state.drone.get().position.set(...clip_position(parameters.dynamics.mass, state.position))
2180
+ ui_state.drone.get().quaternion.copy(new THREE.Quaternion(state.orientation[1], state.orientation[2], state.orientation[3], state.orientation[0]).normalize())
2181
+ }
2182
+ if(ui_state.trajectoryVis && state.trajectory && state.trajectory.trajectory_step !== undefined){
2183
+ update_trajectory_bug(ui_state.trajectoryVis, state.trajectory.trajectory_step)
2184
+ }
2185
+ if(ui_state.show_onboard_preview && ui_state.onboard_scene){
2186
+ const dims = get_desired_onboard_dims(parameters)
2187
+ ensure_onboard_render_state(ui_state, dims.cam_w, dims.cam_h, dims.fov)
2188
+ if(ui_state.onboard_obs_resolution && ui_state.onboard_render_target){
2189
+ render_onboard_pixels(ui_state, state, parameters)
2190
+ } else {
2191
+ update_onboard_camera(ui_state, state, parameters)
2192
+ }
2193
+ }
2194
+ update_camera(ui_state)
2195
+ if(ui_state.show_onboard_preview && ui_state.onboard_scene) render_onboard_overlay(ui_state)
2196
+ }
2197
+
2198
+ export async function render_multi(ui_state, parameters, states, actions){
2199
+ if(ui_state.drones && ui_state.drones.length == states.length){
2200
+ states.map((state, i) => {
2201
+ const action = actions[i]
2202
+ const current_parameters = parameters[i]
2203
+ ui_state.drones[i].get().position.set(...clip_position(current_parameters.dynamics.mass, state.position))
2204
+ ui_state.drones[i].get().quaternion.copy(new THREE.Quaternion(state.orientation[1], state.orientation[2], state.orientation[3], state.orientation[0]).normalize())
2205
+ ui_state.drones[i].set_action(action)
2206
+ if(ui_state.trajectoryVisArray && ui_state.trajectoryVisArray[i] && state.trajectory && state.trajectory.trajectory_step !== undefined){
2207
+ update_trajectory_bug(ui_state.trajectoryVisArray[i], state.trajectory.trajectory_step)
2208
+ }
2209
+ })
2210
+ if(ui_state.show_onboard_preview && ui_state.onboard_scene){
2211
+ const dims = get_desired_onboard_dims(parameters[0])
2212
+ ensure_onboard_render_state(ui_state, dims.cam_w, dims.cam_h, dims.fov)
2213
+ if(ui_state.onboard_obs_resolution && ui_state.onboard_render_target){
2214
+ render_onboard_pixels(ui_state, states[0], parameters[0])
2215
+ } else {
2216
+ update_onboard_camera(ui_state, states[0], parameters[0])
2217
+ }
2218
+ }
2219
+ }
2220
+ update_camera(ui_state)
2221
+ if(ui_state.show_onboard_preview && ui_state.onboard_scene) render_onboard_overlay(ui_state)
2222
+ }
2223
+
2224
+
2225
+
2226
+
2227
+
2228
+
2229
+
2230
+
2231
+
2232
+
2233
+
2234
+
2235
+
2236
+
2237
+
2238
+
2239
+
2240
+
2241
+
2242
+
2243
+ )RL_TOOLS_LITERAL";
2244
+ #else
2245
+ std::string ui = "";
2246
+ #endif
2247
+ return ui;
2248
+ }
2249
+ }
2250
+ RL_TOOLS_NAMESPACE_WRAPPER_END
2251
+
2252
+ #endif