ros2-http-gateway 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. ros2_http_gateway-0.2.0/LICENSE +202 -0
  2. ros2_http_gateway-0.2.0/MANIFEST.in +27 -0
  3. ros2_http_gateway-0.2.0/PKG-INFO +343 -0
  4. ros2_http_gateway-0.2.0/README.md +294 -0
  5. ros2_http_gateway-0.2.0/bench/README.md +72 -0
  6. ros2_http_gateway-0.2.0/bench/RESULTS.md +62 -0
  7. ros2_http_gateway-0.2.0/bench/harness.py +429 -0
  8. ros2_http_gateway-0.2.0/bench/ros_side.py +77 -0
  9. ros2_http_gateway-0.2.0/bench/run.py +153 -0
  10. ros2_http_gateway-0.2.0/bench/scenarios.py +361 -0
  11. ros2_http_gateway-0.2.0/docs/configuration.md +345 -0
  12. ros2_http_gateway-0.2.0/docs/deployment.md +93 -0
  13. ros2_http_gateway-0.2.0/docs/protocol.md +357 -0
  14. ros2_http_gateway-0.2.0/docs/security.md +148 -0
  15. ros2_http_gateway-0.2.0/examples/demo.yaml +84 -0
  16. ros2_http_gateway-0.2.0/examples/dev.yaml +93 -0
  17. ros2_http_gateway-0.2.0/examples/locked_down.yaml +72 -0
  18. ros2_http_gateway-0.2.0/package.xml +37 -0
  19. ros2_http_gateway-0.2.0/pyproject.toml +178 -0
  20. ros2_http_gateway-0.2.0/resource/ros2_http_gateway +0 -0
  21. ros2_http_gateway-0.2.0/ros2_http_gateway/__init__.py +9 -0
  22. ros2_http_gateway-0.2.0/ros2_http_gateway/__main__.py +5 -0
  23. ros2_http_gateway-0.2.0/ros2_http_gateway/_version.py +8 -0
  24. ros2_http_gateway-0.2.0/ros2_http_gateway/actions.py +256 -0
  25. ros2_http_gateway-0.2.0/ros2_http_gateway/app.py +865 -0
  26. ros2_http_gateway-0.2.0/ros2_http_gateway/audit.py +154 -0
  27. ros2_http_gateway-0.2.0/ros2_http_gateway/auth.py +96 -0
  28. ros2_http_gateway-0.2.0/ros2_http_gateway/cache.py +172 -0
  29. ros2_http_gateway-0.2.0/ros2_http_gateway/cli.py +182 -0
  30. ros2_http_gateway-0.2.0/ros2_http_gateway/codegen.py +604 -0
  31. ros2_http_gateway-0.2.0/ros2_http_gateway/config.py +712 -0
  32. ros2_http_gateway-0.2.0/ros2_http_gateway/config.schema.json +231 -0
  33. ros2_http_gateway-0.2.0/ros2_http_gateway/console.py +153 -0
  34. ros2_http_gateway-0.2.0/ros2_http_gateway/demo_node.py +163 -0
  35. ros2_http_gateway-0.2.0/ros2_http_gateway/openapi.py +672 -0
  36. ros2_http_gateway-0.2.0/ros2_http_gateway/params.py +137 -0
  37. ros2_http_gateway-0.2.0/ros2_http_gateway/policy.py +153 -0
  38. ros2_http_gateway-0.2.0/ros2_http_gateway/py.typed +0 -0
  39. ros2_http_gateway-0.2.0/ros2_http_gateway/resolve.py +417 -0
  40. ros2_http_gateway-0.2.0/ros2_http_gateway/ros_env.py +33 -0
  41. ros2_http_gateway-0.2.0/ros2_http_gateway/runtime.py +428 -0
  42. ros2_http_gateway-0.2.0/ros2_http_gateway/schemagen.py +192 -0
  43. ros2_http_gateway-0.2.0/ros2_http_gateway/server.py +125 -0
  44. ros2_http_gateway-0.2.0/ros2_http_gateway/sse.py +234 -0
  45. ros2_http_gateway-0.2.0/ros2_http_gateway/static/console/console.css +265 -0
  46. ros2_http_gateway-0.2.0/ros2_http_gateway/static/console/console.js +1344 -0
  47. ros2_http_gateway-0.2.0/ros2_http_gateway/static/console/index.html +47 -0
  48. ros2_http_gateway-0.2.0/ros2_http_gateway/static/swagger/LICENSE +202 -0
  49. ros2_http_gateway-0.2.0/ros2_http_gateway/static/swagger/README.md +7 -0
  50. ros2_http_gateway-0.2.0/ros2_http_gateway/static/swagger/index.html +95 -0
  51. ros2_http_gateway-0.2.0/ros2_http_gateway/static/swagger/swagger-ui-bundle.js +2 -0
  52. ros2_http_gateway-0.2.0/ros2_http_gateway/static/swagger/swagger-ui-bundle.js.LICENSE.txt +106 -0
  53. ros2_http_gateway-0.2.0/ros2_http_gateway/static/swagger/swagger-ui.css +3 -0
  54. ros2_http_gateway-0.2.0/ros2_http_gateway.egg-info/PKG-INFO +343 -0
  55. ros2_http_gateway-0.2.0/ros2_http_gateway.egg-info/SOURCES.txt +94 -0
  56. ros2_http_gateway-0.2.0/ros2_http_gateway.egg-info/dependency_links.txt +1 -0
  57. ros2_http_gateway-0.2.0/ros2_http_gateway.egg-info/entry_points.txt +3 -0
  58. ros2_http_gateway-0.2.0/ros2_http_gateway.egg-info/requires.txt +23 -0
  59. ros2_http_gateway-0.2.0/ros2_http_gateway.egg-info/top_level.txt +1 -0
  60. ros2_http_gateway-0.2.0/scripts/update_golden.py +51 -0
  61. ros2_http_gateway-0.2.0/setup.cfg +10 -0
  62. ros2_http_gateway-0.2.0/setup.py +59 -0
  63. ros2_http_gateway-0.2.0/test/conftest.py +73 -0
  64. ros2_http_gateway-0.2.0/test/console_logic.mjs +110 -0
  65. ros2_http_gateway-0.2.0/test/gateway_fixtures.py +199 -0
  66. ros2_http_gateway-0.2.0/test/golden/builtin_interfaces__msg__Time.py.txt +23 -0
  67. ros2_http_gateway-0.2.0/test/golden/geometry_msgs__msg__Twist.py.txt +63 -0
  68. ros2_http_gateway-0.2.0/test/golden/openapi.json +972 -0
  69. ros2_http_gateway-0.2.0/test/golden/std_msgs__msg__Header.py.txt +40 -0
  70. ros2_http_gateway-0.2.0/test/golden/test_msgs__msg__Arrays.py.txt +221 -0
  71. ros2_http_gateway-0.2.0/test/golden/test_msgs__msg__BoundedSequences.py.txt +221 -0
  72. ros2_http_gateway-0.2.0/test/openapi-3.1-schema.json +1440 -0
  73. ros2_http_gateway-0.2.0/test/ros_fixtures.py +192 -0
  74. ros2_http_gateway-0.2.0/test/test_actions.py +583 -0
  75. ros2_http_gateway-0.2.0/test/test_app.py +418 -0
  76. ros2_http_gateway-0.2.0/test/test_audit.py +198 -0
  77. ros2_http_gateway-0.2.0/test/test_auth.py +144 -0
  78. ros2_http_gateway-0.2.0/test/test_cache.py +187 -0
  79. ros2_http_gateway-0.2.0/test/test_cli.py +83 -0
  80. ros2_http_gateway-0.2.0/test/test_codegen.py +726 -0
  81. ros2_http_gateway-0.2.0/test/test_config.py +837 -0
  82. ros2_http_gateway-0.2.0/test/test_console.py +651 -0
  83. ros2_http_gateway-0.2.0/test/test_console_e2e.py +507 -0
  84. ros2_http_gateway-0.2.0/test/test_console_logic.py +509 -0
  85. ros2_http_gateway-0.2.0/test/test_events.py +476 -0
  86. ros2_http_gateway-0.2.0/test/test_examples.py +62 -0
  87. ros2_http_gateway-0.2.0/test/test_openapi.py +581 -0
  88. ros2_http_gateway-0.2.0/test/test_packaging.py +136 -0
  89. ros2_http_gateway-0.2.0/test/test_resolve.py +430 -0
  90. ros2_http_gateway-0.2.0/test/test_ros_guard.py +51 -0
  91. ros2_http_gateway-0.2.0/test/test_runtime.py +339 -0
  92. ros2_http_gateway-0.2.0/test/test_schemagen.py +205 -0
  93. ros2_http_gateway-0.2.0/test/test_serve.py +340 -0
  94. ros2_http_gateway-0.2.0/test/test_services.py +534 -0
  95. ros2_http_gateway-0.2.0/test/test_sse.py +264 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,27 @@
1
+ # setuptools puts `test/test_*.py` in the sdist by default but not what those files import, so
2
+ # without this the shipped tests cannot run: the fixtures, the golden files and the vendored
3
+ # OpenAPI meta-schema would all be absent. A source distribution whose tests do not run is a
4
+ # source distribution nobody can verify.
5
+ include MANIFEST.in
6
+ include LICENSE
7
+ include setup.cfg
8
+ include package.xml
9
+
10
+ recursive-include test *.py *.mjs *.json *.txt
11
+ recursive-include docs *.md
12
+ recursive-include bench *.py *.md
13
+ recursive-include examples *.yaml
14
+ recursive-include scripts *.py
15
+ include resource/ros2_http_gateway
16
+
17
+ # Package data is declared in pyproject as well; repeated here so an sdist built by a setuptools
18
+ # old enough to ignore `[tool.setuptools.package-data]` still carries it.
19
+ recursive-include ros2_http_gateway/static *
20
+ include ros2_http_gateway/config.schema.json
21
+ include ros2_http_gateway/py.typed
22
+
23
+ # Never ship build or scratch output.
24
+ prune .github
25
+ prune .docs
26
+ exclude .pre-commit-config.yaml
27
+ global-exclude __pycache__ *.py[cod] .DS_Store
@@ -0,0 +1,343 @@
1
+ Metadata-Version: 2.4
2
+ Name: ros2-http-gateway
3
+ Version: 0.2.0
4
+ Summary: Config-driven, authenticated HTTP + SSE gateway for ROS 2
5
+ Author-email: Saif Sidhik <mail@saifsidhik.page>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/justagist/ros2_http_gateway
8
+ Project-URL: Repository, https://github.com/justagist/ros2_http_gateway
9
+ Project-URL: Changelog, https://github.com/justagist/ros2_http_gateway/blob/main/CHANGELOG.md
10
+ Keywords: ros,ros2,http,rest,gateway,sse,openapi,robotics
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Manufacturing
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering
22
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
23
+ Classifier: Operating System :: POSIX :: Linux
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.10
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: starlette>=0.37
29
+ Requires-Dist: uvicorn[standard]>=0.29
30
+ Requires-Dist: orjson>=3.9
31
+ Requires-Dist: pyyaml>=6.0
32
+ Requires-Dist: jsonschema>=4.18
33
+ Requires-Dist: numpy>=1.22
34
+ Provides-Extra: dev
35
+ Requires-Dist: ruff>=0.5; extra == "dev"
36
+ Requires-Dist: mypy>=1.10; extra == "dev"
37
+ Requires-Dist: pytest>=7.4; extra == "dev"
38
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
39
+ Requires-Dist: pytest-benchmark>=4.0; extra == "dev"
40
+ Requires-Dist: httpx>=0.27; extra == "dev"
41
+ Requires-Dist: types-pyyaml; extra == "dev"
42
+ Requires-Dist: types-jsonschema; extra == "dev"
43
+ Requires-Dist: build; extra == "dev"
44
+ Requires-Dist: tomli>=2.0; python_version < "3.11" and extra == "dev"
45
+ Provides-Extra: e2e
46
+ Requires-Dist: playwright>=1.40; extra == "e2e"
47
+ Dynamic: license-file
48
+ Dynamic: requires-python
49
+
50
+ # ros2_http_gateway
51
+
52
+ **A YAML file in, an authenticated HTTP API out.** No code to write, no client to build.
53
+
54
+ [![CI](https://github.com/justagist/ros2_http_gateway/actions/workflows/ci.yml/badge.svg)](https://github.com/justagist/ros2_http_gateway/actions/workflows/ci.yml)
55
+ [![PyPI](https://img.shields.io/pypi/v/ros2-http-gateway.svg)](https://pypi.org/project/ros2-http-gateway/)
56
+ [![Python versions](https://img.shields.io/pypi/pyversions/ros2-http-gateway.svg)](https://pypi.org/project/ros2-http-gateway/)
57
+ [![ROS 2 Humble | Jazzy | Kilted | Lyrical | Rolling](https://img.shields.io/badge/ROS%202-Humble%20%7C%20Jazzy%20%7C%20Kilted%20%7C%20Lyrical%20%7C%20Rolling-22314E.svg)](#supported-versions)
58
+ [![Licence: Apache-2.0](https://img.shields.io/badge/licence-Apache--2.0-green.svg)](LICENSE)
59
+ [![mypy: strict](https://img.shields.io/badge/mypy-strict-2a6db2.svg)](pyproject.toml)
60
+ [![lint: ruff](https://img.shields.io/badge/lint-ruff-d7ff64.svg)](pyproject.toml)
61
+
62
+ One config file decides exactly which ROS 2 topics, services and actions are reachable over HTTP --
63
+ with per-endpoint roles, state-based preconditions, audit logging, server-sent events and a
64
+ generated OpenAPI 3.1 document. Nothing is exposed unless you name it.
65
+
66
+ ## No code, only config
67
+
68
+ Serve the file and you get the endpoints, an OpenAPI document describing them and a built-in
69
+ console for exercising them straight away. Below is [`examples/demo.yaml`](examples/demo.yaml),
70
+ trimmed; the screenshot under it is that console rendering itself from exactly this config --
71
+ forms, live tiles, gates, goal cards:
72
+
73
+ ```yaml
74
+ endpoints:
75
+ /mission/status: # GET the newest sample, flagged stale after 3 s
76
+ topic: /mission/state
77
+ type: example_interfaces/msg/String
78
+ roles: [viewer, operator]
79
+ stale_after_ms: 3000
80
+
81
+ /chatter/say: # POST publishes the body
82
+ topic: /chatter
83
+ type: example_interfaces/msg/String
84
+ method: POST
85
+ roles: [operator]
86
+
87
+ /mission/{command}: # POST calls a service, gated on live state
88
+ service: /mission_control
89
+ type: std_srvs/srv/Trigger
90
+ method: POST
91
+ roles: [operator]
92
+ timeout_ms: 2000
93
+ preconditions:
94
+ - state_endpoint: /mission/status
95
+ field: data
96
+ allow: { start: [IDLE], abort: [RUNNING], reset: ["*"] }
97
+
98
+ /pick: # POST submits a goal; status, feedback and cancel follow
99
+ action: /fibonacci
100
+ type: example_interfaces/action/Fibonacci
101
+ roles: [operator]
102
+
103
+ auth:
104
+ tokens:
105
+ - token_sha256: "61112491d046c3f6f8ab801f170d9b2d0c734a17ceff60dee92123fb507cfc3f" # sha256 of 'demo-operator-token'
106
+ user: demo-operator
107
+ roles: [operator]
108
+
109
+ sse: { path: /events, include: [/mission/status, /chatter] }
110
+ http: { bind: 127.0.0.1, port: 8080, base_path: /api/v1, console: true }
111
+ ```
112
+
113
+ ![The built-in console, rendered from the config above](https://raw.githubusercontent.com/justagist/ros2_http_gateway/main/docs/console.png)
114
+
115
+ Reading down that screenshot: a topic tile counting down to its staleness bound; a service showing
116
+ the live state it is gated on (`data = "IDLE" -- allowed`) beside the button, with the audit line
117
+ the call produced; a goal card mid-flight with feedback; and the event stream, with its two
118
+ transports and a slow-consumer switch. [Full page](https://raw.githubusercontent.com/justagist/ros2_http_gateway/main/docs/console-full.png).
119
+
120
+ ## Try it in two terminals
121
+
122
+ The demo publishes `example_interfaces` messages, which a `ros-base` install does not carry
123
+ (`std_srvs` and the rest come with it already):
124
+
125
+ ```bash
126
+ sudo apt install ros-$ROS_DISTRO-example-interfaces
127
+ ```
128
+
129
+ ```bash
130
+ # terminal 1 -- a demo node: mission state cycling IDLE/RUNNING, a 2 Hz topic, a service, an action
131
+ ros2 run ros2_http_gateway ros2-http-gateway-demo
132
+
133
+ # terminal 2
134
+ ros2-http-gateway examples/demo.yaml
135
+ ```
136
+
137
+ `examples/demo.yaml` is the checkout path; an installed copy sits at
138
+ `$(ros2 pkg prefix ros2_http_gateway)/share/ros2_http_gateway/examples/demo.yaml`.
139
+
140
+ Open <http://127.0.0.1:8080/api/v1/console> and paste `demo-operator-token`. Or stay in the shell:
141
+
142
+ ```bash
143
+ curl -H 'Authorization: Bearer demo-operator-token' \
144
+ http://127.0.0.1:8080/api/v1/mission/status
145
+ ```
146
+
147
+ Paste `demo-viewer-token` instead and the write, the service and the action disappear from the
148
+ page: the console is built from a manifest filtered to the token's roles. The service is gated on
149
+ live mission state, so `POST /api/v1/mission/start` flips between success and
150
+ `PRECONDITION_FAILED` every eight seconds as the demo cycles.
151
+
152
+ Interactive API docs are at `/api/v1/docs`, the OpenAPI document at `/api/v1/openapi.json`.
153
+
154
+ ## Validate a config without starting anything
155
+
156
+ ```bash
157
+ ros2-http-gateway --check examples/demo.yaml # exit 0/1
158
+ ros2-http-gateway --check --dump-openapi api.json examples/demo.yaml
159
+ ```
160
+
161
+ `--check` resolves every interface type, compiles every converter and checks every precondition
162
+ field against the real message definition, then prints one line per endpoint. It needs no running
163
+ system when the config pins its types, which is what makes it usable as a CI gate; add `--online`
164
+ on the robot to verify those pinned types against the live graph too.
165
+
166
+ ## Why not rosbridge
167
+
168
+ `rosbridge_suite` exposes the whole ROS graph over a WebSocket with, at best, a shared secret.
169
+ That is the right tool for a debugging UI on a bench, and the wrong tool for a machine that has to
170
+ pass a security review.
171
+
172
+ | | rosbridge | ros2_http_gateway |
173
+ | --------------- | ---------------------------------- | --------------------------------------- |
174
+ | Exposed surface | whole graph, discovered at runtime | only what the config names |
175
+ | Transport | WebSocket, custom protocol | plain HTTP + SSE, described in OpenAPI |
176
+ | Auth | optional shared secret | per-token identity, per-endpoint roles |
177
+ | Authorisation | none | roles plus state-based preconditions |
178
+ | Audit | none | one JSON line per authenticated request |
179
+
180
+ ## Install
181
+
182
+ ```bash
183
+ pip install ros2-http-gateway
184
+ ```
185
+
186
+ `rclpy` is deliberately not a pip dependency; it comes from your sourced ROS 2 environment.
187
+ `--help` and `--version` work without one, everything else needs
188
+ `source /opt/ros/$ROS_DISTRO/setup.bash`.
189
+
190
+ On a Debian-managed Python -- which is what a ROS container gives you -- install into a virtualenv
191
+ rather than fighting PEP 668. `--system-site-packages` is what keeps `rclpy` and the interface
192
+ packages importable, and upgrading pip inside the venv matters on Humble, where pip 22 installs an
193
+ editable package with `setup.py develop` and so ignores `pyproject.toml` metadata entirely:
194
+
195
+ ```bash
196
+ sudo apt install python3-venv # not present in a ros-base image
197
+ python3 -m venv --system-site-packages .venv
198
+ .venv/bin/python -m pip install --upgrade pip
199
+ .venv/bin/python -m pip install ros2-http-gateway
200
+ ```
201
+
202
+ In a colcon workspace, where `rosdep` covers the runtime dependencies:
203
+
204
+ ```bash
205
+ cd ~/ws/src && git clone https://github.com/justagist/ros2_http_gateway.git
206
+ cd ~/ws && rosdep install --from-paths src -y --ignore-src
207
+ colcon build --packages-select ros2_http_gateway
208
+ source install/setup.bash
209
+ ros2 run ros2_http_gateway ros2-http-gateway --help
210
+ ```
211
+
212
+ `example_interfaces` and `test_msgs` are declared as test dependencies rather than runtime ones, so
213
+ `rosdep install` picks them up but a deployment install does not: the gateway itself needs neither,
214
+ only the demo node and the test suite do. That is why the demo names the one `apt install` it
215
+ needs, and says so again in its own error message if you forget.
216
+
217
+ ## Documentation
218
+
219
+ | | |
220
+ | ---------------------------------------------- | ------------------------------------------------------- |
221
+ | [docs/configuration.md](docs/configuration.md) | every config key, and the rule each one enforces |
222
+ | [docs/protocol.md](docs/protocol.md) | the wire protocol: bodies, status codes, streams, audit |
223
+ | [docs/security.md](docs/security.md) | the security model and its known gaps |
224
+ | [docs/deployment.md](docs/deployment.md) | TLS, and several cells behind one nginx |
225
+ | [bench/RESULTS.md](bench/RESULTS.md) | benchmark numbers, and how to reproduce them |
226
+ | [CHANGELOG.md](CHANGELOG.md) | what is real in each version |
227
+
228
+ ## The test console
229
+
230
+ Off unless `http.console: true`, and a testing tool rather than an HMI: every widget maps to one
231
+ protocol feature, and there is no dashboard, chart or saved layout in it. Everything comes from
232
+ `<base>/console/manifest` and the schemas in the OpenAPI document, so no endpoint is hardcoded.
233
+
234
+ - A **token wallet** -- several labelled tokens, one active, switchable in place.
235
+ - An **auth matrix** per endpoint: fire as nobody, as a bad token, and as each saved token, then
236
+ read the 401/401/403/2xx grid. Anything that is not a GET is probed with a body no converter
237
+ accepts, so an authorised token shows 400 -- proof the roles passed, with nothing published,
238
+ called or submitted.
239
+ - **Topic tiles** with the sample, its `seq` and stamp, and a countdown that visibly flips the tile
240
+ when it expires. Manual GET or auto-poll.
241
+ - **Schema-driven forms** for writes and services. Flat fields and one nesting level get widgets;
242
+ arrays and anything deeper fall back to a raw JSON editor validated in the browser against the
243
+ same schema the gateway will apply.
244
+ - **The protocol taxonomy, visibly**: a 4xx that never reached ROS, a 503 capacity limit, a 200
245
+ refused by a state gate, a 200 carrying a ROS-side error, and a plain success all look different.
246
+ - **Goal cards**: status by polling, feedback over the goal's own stream, cancel, the result, a
247
+ countdown to `result_ttl_s`, then the 404 once evicted. Several at once.
248
+ - **An event-stream panel**: per-endpoint filter, faint heartbeats, a seq-gap detector, and a
249
+ transport toggle between `fetch` with header auth and `EventSource` with the query token -- which
250
+ also makes visible that `EventSource` cannot show you a heartbeat.
251
+ - **An audit hint** under every response: the decision, outcome and reason that request wrote to
252
+ the audit log.
253
+
254
+ ## Supported versions
255
+
256
+ Python 3.10+, ROS 2 Humble, Jazzy, Kilted, Lyrical and Rolling. Humble is the feature floor:
257
+ `ros.executor: auto` uses `rclpy.experimental.EventsExecutor` where it exists and falls back to
258
+ `MultiThreadedExecutor` where it does not.
259
+
260
+ One caveat, measured rather than assumed: on Humble a 1 kHz topic costs about 80% of a core,
261
+ against under 5% on Jazzy and newer. That is rclpy's per-message dispatch on that distro -- an idle
262
+ gateway still costs ~1%, and the cost is paid before any code here runs -- so nothing here can
263
+ avoid it. Everything works on Humble; if you intend to stream kilohertz topics, budget for it or
264
+ use a newer distro.
265
+
266
+ ## Design in one picture
267
+
268
+ ```
269
+ +- rclpy thread(s) -----------------+ +- asyncio thread -----------------+
270
+ | MultiThreadedExecutor / Events | | Starlette + uvicorn + uvloop |
271
+ | raw=True subscriptions (CDR) | | auth -> policy -> handler |
272
+ | -> atomic ref swap into caches |=====>| SSE broadcaster (encode once, |
273
+ | service clients / action clients |queue | fan out bytes) |
274
+ +-----------------------------------+ +----------------------------------+
275
+ ```
276
+
277
+ ROS callbacks never run on the asyncio loop, and the loop never blocks on ROS. All expensive work
278
+ -- config validation, type resolution, converter code generation, route and policy tables, the
279
+ OpenAPI document -- happens at startup, so a request is lookups and precompiled code.
280
+
281
+ ## Performance
282
+
283
+ Measured with `python3 bench/run.py` on a 24-core i7-14650HX, Jazzy, `rmw_fastrtps_cpp`. Full
284
+ table and caveats in [bench/RESULTS.md](bench/RESULTS.md).
285
+
286
+ | | |
287
+ | --------------------------------- | -------------------------------------------- |
288
+ | Cached topic `GET` | 11.8k req/s, p99 3.8 ms |
289
+ | Service round trip | p50 0.91 ms, p99 1.65 ms |
290
+ | State precondition | +10 us end to end, 1.1 us p99 measured alone |
291
+ | `msg -> dict` (`sensor_msgs/Imu`) | 1.2 us, 44x `rosidl_runtime_py` |
292
+ | Event stream, 32 clients | 6.2k events/s for 18.7% of one core |
293
+ | Idle, no traffic | 0.5% of one core |
294
+
295
+ The stream row is the point of "encode once, fan out bytes": 32 clients cost 1.7x the CPU of one,
296
+ because a sample is converted and framed once and the same `bytes` object goes to every queue.
297
+ Throughput is a floor -- the load driver shares the machine with the gateway.
298
+
299
+ ## JSON representation
300
+
301
+ - `uint8[]` and `byte[]` become base64 strings. Large-blob topics -- images, point clouds -- are
302
+ out of scope: this is a JSON gateway, not a data plane.
303
+ - `int64`/`uint64` become JSON strings by default (`int64_as_string`), because values above 2^53
304
+ do not survive a JavaScript `number`.
305
+ - Numeric arrays serialise straight from numpy, with no intermediate list. Numeric sequences,
306
+ which rclpy hands over as `array.array`, become a zero-copy numpy view once they are long enough
307
+ for that to pay (measured crossover: 64 elements).
308
+
309
+ ## Status codes
310
+
311
+ 4xx means the request never reached ROS: 401/403 auth, 400 a malformed body or an out-of-range
312
+ value, 404 an unknown route or goal. 503 means a capacity limit was hit. 200 means it did reach
313
+ ROS, and `error_code` carries the outcome -- because "the service timed out" is a result, not a
314
+ protocol error. One envelope shape for all of them; the detail is in
315
+ [docs/protocol.md](docs/protocol.md).
316
+
317
+ ## Security model
318
+
319
+ Deny by default: an endpoint that is not in the config does not exist, and there is no discovery
320
+ path that could add one at runtime.
321
+
322
+ - **Tokens** are compared as SHA-256 digests with `hmac.compare_digest`, and every configured
323
+ digest is compared even after a match, so neither the token nor its position in the file can be
324
+ timed. Prefer `token_sha256:`; a plaintext `token:` is hashed on load, warned about, and refused
325
+ outright if the config file is world-readable.
326
+ - **Roles** are per endpoint. Authentication and the role check both run before any state
327
+ precondition, so a caller who may not use an endpoint learns nothing about the robot from being
328
+ refused.
329
+ - **Roles gate action, not description.** An authenticated caller can already enumerate the routes
330
+ by asking -- unknown paths answer 404, forbidden ones 403 -- so the OpenAPI document is served
331
+ whole to any of them. The console manifest does filter by role, but that is defence in depth, not
332
+ a boundary.
333
+ - **Audit**: one JSON line per authenticated request -- who, what, the decision and its reason, the
334
+ outcome, the latency. Never tokens, never bodies, never the query string.
335
+ - **No TLS, no rate limit, no body size limit.** The gateway binds localhost unless told otherwise;
336
+ all three belong in a reverse proxy. See [docs/deployment.md](docs/deployment.md).
337
+
338
+ Known gaps, and why, are in [docs/security.md](docs/security.md) -- including the one place a
339
+ credential may appear in a URL, and what that costs you.
340
+
341
+ ## Licence
342
+
343
+ Apache-2.0. See [LICENSE](LICENSE).