drawtonomy-commonroad 0.1.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.
- drawtonomy_commonroad-0.1.0/.gitignore +5 -0
- drawtonomy_commonroad-0.1.0/LICENSE +190 -0
- drawtonomy_commonroad-0.1.0/PKG-INFO +205 -0
- drawtonomy_commonroad-0.1.0/README.ja.md +177 -0
- drawtonomy_commonroad-0.1.0/README.md +176 -0
- drawtonomy_commonroad-0.1.0/docs/open-server-protocol.ja.md +256 -0
- drawtonomy_commonroad-0.1.0/docs/open-server-protocol.md +272 -0
- drawtonomy_commonroad-0.1.0/docs/planning-trace-format.ja.md +349 -0
- drawtonomy_commonroad-0.1.0/docs/planning-trace-format.md +350 -0
- drawtonomy_commonroad-0.1.0/docs/verdict-sidecar.ja.md +177 -0
- drawtonomy_commonroad-0.1.0/docs/verdict-sidecar.md +180 -0
- drawtonomy_commonroad-0.1.0/examples/idm_planner/README.ja.md +53 -0
- drawtonomy_commonroad-0.1.0/examples/idm_planner/README.md +56 -0
- drawtonomy_commonroad-0.1.0/examples/idm_planner/idm_planner.py +254 -0
- drawtonomy_commonroad-0.1.0/examples/reactive_planner/Dockerfile +25 -0
- drawtonomy_commonroad-0.1.0/examples/reactive_planner/run_planner.py +437 -0
- drawtonomy_commonroad-0.1.0/pyproject.toml +95 -0
- drawtonomy_commonroad-0.1.0/src/drawtonomy_cr/__init__.py +12 -0
- drawtonomy_commonroad-0.1.0/src/drawtonomy_cr/cli.py +345 -0
- drawtonomy_commonroad-0.1.0/src/drawtonomy_cr/serve.py +720 -0
- drawtonomy_commonroad-0.1.0/src/drawtonomy_cr/trace.py +381 -0
- drawtonomy_commonroad-0.1.0/src/drawtonomy_cr/verdict.py +435 -0
- drawtonomy_commonroad-0.1.0/tests/conftest.py +15 -0
- drawtonomy_commonroad-0.1.0/tests/fixtures/cutin_commonroad.xml +13635 -0
- drawtonomy_commonroad-0.1.0/tests/fixtures/cutin_solution.verdict.json +37 -0
- drawtonomy_commonroad-0.1.0/tests/fixtures/cutin_solution.xml +1531 -0
- drawtonomy_commonroad-0.1.0/tests/fixtures/planner_solution.planning-trace.json +28564 -0
- drawtonomy_commonroad-0.1.0/tests/fixtures/planner_solution.verdict.json +30 -0
- drawtonomy_commonroad-0.1.0/tests/fixtures/planner_solution.xml +1525 -0
- drawtonomy_commonroad-0.1.0/tests/test_example_idm.py +63 -0
- drawtonomy_commonroad-0.1.0/tests/test_open.py +730 -0
- drawtonomy_commonroad-0.1.0/tests/test_trace.py +299 -0
- drawtonomy_commonroad-0.1.0/tests/test_verdict.py +314 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 drawtonomy
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: drawtonomy-commonroad
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CommonRoad connector for drawtonomy: official checker verdict sidecars and planning traces
|
|
5
|
+
Project-URL: Homepage, https://drawtonomy.com
|
|
6
|
+
Project-URL: Documentation, https://docs.drawtonomy.com/integrations/commonroad/
|
|
7
|
+
Project-URL: Source, https://github.com/kosuke55/drawtonomy/tree/main/packages/drawtonomy-commonroad
|
|
8
|
+
Project-URL: Issues, https://github.com/kosuke55/drawtonomy/issues
|
|
9
|
+
Author: drawtonomy
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: autonomous-driving,commonroad,motion-planning,scenario,simulation,verification
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: commonroad-io<2026,>=2024.1
|
|
21
|
+
Provides-Extra: boundary
|
|
22
|
+
Requires-Dist: triangle; extra == 'boundary'
|
|
23
|
+
Provides-Extra: checker
|
|
24
|
+
Requires-Dist: commonroad-drivability-checker>=2024.1; extra == 'checker'
|
|
25
|
+
Requires-Dist: commonroad-io<2026,>=2024.1; extra == 'checker'
|
|
26
|
+
Provides-Extra: test
|
|
27
|
+
Requires-Dist: pytest>=8.0.0; extra == 'test'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# drawtonomy-cr
|
|
31
|
+
|
|
32
|
+
[日本語](README.ja.md)
|
|
33
|
+
|
|
34
|
+
CommonRoad connector for [drawtonomy](https://drawtonomy.com). Bring your own planner.
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
scenario.xml (CommonRoad 2020a, exported from drawtonomy)
|
|
38
|
+
|
|
|
39
|
+
v
|
|
40
|
+
[your planner] -- required --> solution.xml (CommonRoadSolution, commonroad-io)
|
|
41
|
+
|
|
|
42
|
+
+-- optional --> solution.planning-trace.json (drawtonomy_cr.trace.TraceWriter)
|
|
43
|
+
|
|
|
44
|
+
v (drawtonomy-cr post-processes)
|
|
45
|
+
solution.verdict.json (drawtonomy-verdict/1, the official checker's 4 verdicts)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The **solution XML is the only required file**. Everything else is optional: replay
|
|
49
|
+
and drawtonomy's own collision badge work without them.
|
|
50
|
+
|
|
51
|
+
## Install
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install drawtonomy-commonroad # TraceWriter and `open`
|
|
55
|
+
pip install "drawtonomy-commonroad[checker]" # + verdict, needs Linux x86_64
|
|
56
|
+
pip install "drawtonomy-commonroad[boundary]" # + the road boundary check
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The `[boundary]` extra adds Shewchuk's Triangle, which `boundary_collision`
|
|
60
|
+
triangulates the road with. It is not a default dependency because Triangle is
|
|
61
|
+
free for non-commercial use but needs the author's permission for commercial use.
|
|
62
|
+
Without it `boundary_collision` is reported as SKIP rather than FAIL and the other
|
|
63
|
+
three checks still run.
|
|
64
|
+
|
|
65
|
+
## `drawtonomy-cr verdict`
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
drawtonomy-cr verdict scenario.xml solution.xml [-o out.json]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Runs the official checker's four tests (`obstacle_collision`, `boundary_collision`,
|
|
72
|
+
`goal_reached`, `solution_feasible`) and writes the result as a
|
|
73
|
+
`drawtonomy-verdict/1` sidecar next to the solution (`<solution stem>.verdict.json`
|
|
74
|
+
when `-o` is omitted). Drop it into drawtonomy together with the solution to see
|
|
75
|
+
PASS / FAIL badges, the colliding time steps and the obstacle involved.
|
|
76
|
+
|
|
77
|
+
Exit codes: `0` when the sidecar was written (a FAIL verdict lives inside the JSON,
|
|
78
|
+
it is not an error), `3` when the checker is not installed.
|
|
79
|
+
|
|
80
|
+
Format: [`docs/verdict-sidecar.md`](docs/verdict-sidecar.md).
|
|
81
|
+
|
|
82
|
+
## `drawtonomy_cr.trace.TraceWriter`
|
|
83
|
+
|
|
84
|
+
A **planning trace** records what the planner intended at every replanning cycle,
|
|
85
|
+
not just the trajectory it ended up driving. Only the planner's author can produce
|
|
86
|
+
one, so it is a library, not a command.
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from drawtonomy_cr.trace import TraceWriter
|
|
90
|
+
|
|
91
|
+
w = TraceWriter(dt=0.1, vehicle=dict(length=4.508, width=1.61, refToCenter=1.4227,
|
|
92
|
+
type="BMW_320i"))
|
|
93
|
+
for cycle in my_planner_loop():
|
|
94
|
+
w.plan(t=cycle.t, states=cycle.trajectory) # one entry per replanning cycle
|
|
95
|
+
w.driven(executed_states) # what the ego actually drove
|
|
96
|
+
w.write("solution.planning-trace.json", solution="solution.xml")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`vehicle` is the body the planner planned with. Only `length`, `width` and
|
|
100
|
+
`refToCenter` are used; `type` is a free label shown in the replay tooltip. Use
|
|
101
|
+
whatever body your planner uses, or omit `vehicle` to fall back to the size the ego
|
|
102
|
+
was drawn with.
|
|
103
|
+
|
|
104
|
+
`states` accepts commonroad-io `State` objects and plain
|
|
105
|
+
`{"x":, "y":, "orientation":, "v":, "time_step":}` dicts alike.
|
|
106
|
+
|
|
107
|
+
`write()` verifies two identities before writing anything: `driven` matches the
|
|
108
|
+
solution's trajectory within 1e-6 m, and each plan's executed head matches `driven`
|
|
109
|
+
at the same time steps. A failure raises instead of writing a trace that would
|
|
110
|
+
replay differently from the solution it claims to describe.
|
|
111
|
+
|
|
112
|
+
Format: [`docs/planning-trace-format.md`](docs/planning-trace-format.md).
|
|
113
|
+
|
|
114
|
+
## `drawtonomy-cr open`
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
drawtonomy-cr open ./results # a directory, or the scenario XML inside it
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Sniffs the directory for the four files by **content** (`<commonRoad`,
|
|
121
|
+
`<CommonRoadSolution`, `drawtonomy-verdict/1`, `drawtonomy-planning-trace-v1`),
|
|
122
|
+
computes the verdict if it is missing and the checker is installed, serves the
|
|
123
|
+
directory on `http://127.0.0.1:<port>`, prints the drawtonomy URL and opens it.
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
solution: planner_solution.xml
|
|
127
|
+
serving /home/me/results at http://127.0.0.1:53101
|
|
128
|
+
https://drawtonomy.com/?open=http%3A%2F%2F127.0.0.1%3A53101%2Fscenario.xml&solution=planner_solution.xml
|
|
129
|
+
Open the URL in Chrome or Firefox (Safari blocks http://127.0.0.1 from an https page).
|
|
130
|
+
Watching for changes. Press Ctrl+C to stop.
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Then it **watches**: rerun your planner and the open tab reloads the solution,
|
|
134
|
+
verdict and trace on its own (the scenario is not reloaded, the drawing is
|
|
135
|
+
drawtonomy's side). The page subscribes to `/events` (Server-Sent Events); the
|
|
136
|
+
CLI waits until a file's size and mtime hold still for 500 ms so a half-written
|
|
137
|
+
solution is never served. A verdict the CLI computed is recomputed after every
|
|
138
|
+
solution change; a verdict you placed yourself is never touched, so when only the
|
|
139
|
+
solution changes the page drops the old checker result (it belonged to the previous
|
|
140
|
+
solution) and shows it again once your verdict file is updated.
|
|
141
|
+
|
|
142
|
+
Only `127.0.0.1` is bound, only `GET` / `HEAD` / `OPTIONS` are answered, only the
|
|
143
|
+
served directory is reachable (`..` and absolute paths give 404), and
|
|
144
|
+
`Access-Control-Allow-Origin` names one origin, never `*`.
|
|
145
|
+
|
|
146
|
+
| flag | |
|
|
147
|
+
|---|---|
|
|
148
|
+
| `--solution` / `--verdict` / `--trace` | override the sniffed pick |
|
|
149
|
+
| `--port N` | fixed port (default: a free one) |
|
|
150
|
+
| `--no-browser` | print the URL without opening a browser |
|
|
151
|
+
| `--copy` | print the file paths instead of serving them, for browsers that block `http://127.0.0.1` from an https page (Safari); drop those files onto drawtonomy.com |
|
|
152
|
+
| `--app-origin URL` | the origin allowed to read the files (default `https://drawtonomy.com`) |
|
|
153
|
+
|
|
154
|
+
Without the checker there is simply no verdict: one line says so and the scenario
|
|
155
|
+
opens with drawtonomy's own collision badge.
|
|
156
|
+
|
|
157
|
+
Protocol: [`docs/open-server-protocol.md`](docs/open-server-protocol.md).
|
|
158
|
+
|
|
159
|
+
## Examples
|
|
160
|
+
|
|
161
|
+
`examples/idm_planner/` is a one-file planner written for this package: the ego
|
|
162
|
+
follows the centreline of its starting lanelet and IDM car-following sets its
|
|
163
|
+
speed, with commonroad-io and numpy as the only dependencies. It is the smallest
|
|
164
|
+
thing that can be connected, and its README explains the two modes it ships with.
|
|
165
|
+
|
|
166
|
+
`examples/reactive_planner/` connects commonroad-reactive-planner end to end.
|
|
167
|
+
Both are examples: replace the planner half with yours and keep the hand-off half.
|
|
168
|
+
|
|
169
|
+
## Contract documents
|
|
170
|
+
|
|
171
|
+
| document | what it specifies |
|
|
172
|
+
|---|---|
|
|
173
|
+
| [`docs/verdict-sidecar.md`](docs/verdict-sidecar.md) | the `drawtonomy-verdict/1` sidecar written by `drawtonomy-cr verdict` |
|
|
174
|
+
| [`docs/planning-trace-format.md`](docs/planning-trace-format.md) | the `drawtonomy-planning-trace-v1` file written by `TraceWriter` |
|
|
175
|
+
| [`docs/open-server-protocol.md`](docs/open-server-protocol.md) | what `drawtonomy-cr open` serves, the URL it prints, and the `/events` stream |
|
|
176
|
+
|
|
177
|
+
## Development
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
pip install "drawtonomy-commonroad[test]"
|
|
181
|
+
pytest
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Tests that need the official checker are skipped where it cannot be installed, so
|
|
185
|
+
the suite runs everywhere. No Node toolchain is involved.
|
|
186
|
+
|
|
187
|
+
## When the checker cannot be installed
|
|
188
|
+
|
|
189
|
+
If the `[checker]` extra cannot be installed on your machine, run the verdict step
|
|
190
|
+
in a Linux x86_64 container:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
docker run --rm --platform linux/amd64 -v "$PWD:/work" -w /work python:3.11 sh -c \
|
|
194
|
+
'pip install "drawtonomy-commonroad[checker]" &&
|
|
195
|
+
drawtonomy-cr verdict scenario.xml planner_solution.xml'
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Without the checker, `drawtonomy-cr verdict` exits with code 3 and one line saying
|
|
199
|
+
so, and `drawtonomy-cr open` serves the scenario without a verdict. `open` keeps
|
|
200
|
+
watching for the verdict file under its expected name, so writing it from a
|
|
201
|
+
container after `open` has started makes it appear in the tab.
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
Apache-2.0. See [`LICENSE`](LICENSE).
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# drawtonomy-cr
|
|
2
|
+
|
|
3
|
+
[English](README.md)
|
|
4
|
+
|
|
5
|
+
[drawtonomy](https://drawtonomy.com) 用の CommonRoad コネクタ。プランナはご自身のものをお使いください。
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
scenario.xml (CommonRoad 2020a, exported from drawtonomy)
|
|
9
|
+
|
|
|
10
|
+
v
|
|
11
|
+
[your planner] -- required --> solution.xml (CommonRoadSolution, commonroad-io)
|
|
12
|
+
|
|
|
13
|
+
+-- optional --> solution.planning-trace.json (drawtonomy_cr.trace.TraceWriter)
|
|
14
|
+
|
|
|
15
|
+
v (drawtonomy-cr post-processes)
|
|
16
|
+
solution.verdict.json (drawtonomy-verdict/1, the official checker's 4 verdicts)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**必須のファイルは solution XML だけ**です。それ以外はすべて任意で、リプレイと
|
|
20
|
+
drawtonomy 自身の衝突バッジはそれらが無くても動作します。
|
|
21
|
+
|
|
22
|
+
## インストール
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install drawtonomy-commonroad # TraceWriter and `open`
|
|
26
|
+
pip install "drawtonomy-commonroad[checker]" # + verdict, needs Linux x86_64
|
|
27
|
+
pip install "drawtonomy-commonroad[boundary]" # + the road boundary check
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`[boundary]` の extra は Shewchuk の Triangle を追加します。`boundary_collision` は
|
|
31
|
+
これを使って道路を三角形分割します。Triangle は非商用利用は無償ですが商用利用には
|
|
32
|
+
作者の許諾が必要なため、既定の依存関係には入れていません。無い場合 `boundary_collision`
|
|
33
|
+
は FAIL ではなく SKIP として報告され、残り 3 つのチェックは実行されます。
|
|
34
|
+
|
|
35
|
+
## `drawtonomy-cr verdict`
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
drawtonomy-cr verdict scenario.xml solution.xml [-o out.json]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
公式チェッカの 4 つのテスト (`obstacle_collision`, `boundary_collision`,
|
|
42
|
+
`goal_reached`, `solution_feasible`) を実行し、結果を `drawtonomy-verdict/1`
|
|
43
|
+
サイドカーとして solution の隣に書き出します (`-o` を省略した場合は
|
|
44
|
+
`<solution stem>.verdict.json`)。solution と一緒に drawtonomy へドロップすると、
|
|
45
|
+
PASS / FAIL バッジ、衝突したタイムステップ、関与した障害物を確認できます。
|
|
46
|
+
|
|
47
|
+
終了コード: サイドカーを書き出せたときは `0` (FAIL の verdict は JSON の中身であり、
|
|
48
|
+
エラーではありません)、チェッカが未インストールのときは `3` です。
|
|
49
|
+
|
|
50
|
+
フォーマット: [`docs/verdict-sidecar.ja.md`](docs/verdict-sidecar.ja.md)。
|
|
51
|
+
|
|
52
|
+
## `drawtonomy_cr.trace.TraceWriter`
|
|
53
|
+
|
|
54
|
+
**planning trace** は、最終的に走行した軌跡だけでなく、各再計画サイクルで
|
|
55
|
+
プランナが何を意図していたかを記録します。これを生成できるのはプランナの作者だけ
|
|
56
|
+
なので、コマンドではなくライブラリとして提供しています。
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from drawtonomy_cr.trace import TraceWriter
|
|
60
|
+
|
|
61
|
+
w = TraceWriter(dt=0.1, vehicle=dict(length=4.508, width=1.61, refToCenter=1.4227,
|
|
62
|
+
type="BMW_320i"))
|
|
63
|
+
for cycle in my_planner_loop():
|
|
64
|
+
w.plan(t=cycle.t, states=cycle.trajectory) # one entry per replanning cycle
|
|
65
|
+
w.driven(executed_states) # what the ego actually drove
|
|
66
|
+
w.write("solution.planning-trace.json", solution="solution.xml")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`vehicle` はプランナが計画に使った車体です。使われるのは `length` / `width` /
|
|
70
|
+
`refToCenter` だけで、`type` は再生時のツールチップに表示される自由なラベルです。
|
|
71
|
+
お使いのプランナの車体をそのまま書くか、`vehicle` を省略すれば ego を描いたときの
|
|
72
|
+
サイズにフォールバックします。
|
|
73
|
+
|
|
74
|
+
`states` は commonroad-io の `State` オブジェクトでも、素の
|
|
75
|
+
`{"x":, "y":, "orientation":, "v":, "time_step":}` の dict でも受け付けます。
|
|
76
|
+
|
|
77
|
+
`write()` は何かを書き出す前に 2 つの同一性を検証します。`driven` が solution の
|
|
78
|
+
軌跡と 1e-6 m 以内で一致すること、そして各 plan の実行済み先頭部分が同じ
|
|
79
|
+
タイムステップの `driven` と一致することです。検証に失敗した場合は、記述対象と
|
|
80
|
+
主張している solution と異なる再生になる trace を書き出さずに例外を送出します。
|
|
81
|
+
|
|
82
|
+
フォーマット: [`docs/planning-trace-format.ja.md`](docs/planning-trace-format.ja.md)。
|
|
83
|
+
|
|
84
|
+
## `drawtonomy-cr open`
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
drawtonomy-cr open ./results # a directory, or the scenario XML inside it
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
ディレクトリを走査して 4 種類のファイルを**内容**で判別し (`<commonRoad`,
|
|
91
|
+
`<CommonRoadSolution`, `drawtonomy-verdict/1`, `drawtonomy-planning-trace-v1`)、
|
|
92
|
+
verdict が無くチェッカがインストールされていれば計算し、ディレクトリを
|
|
93
|
+
`http://127.0.0.1:<port>` で配信し、drawtonomy の URL を表示してそれを開きます。
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
solution: planner_solution.xml
|
|
97
|
+
serving /home/me/results at http://127.0.0.1:53101
|
|
98
|
+
https://drawtonomy.com/?open=http%3A%2F%2F127.0.0.1%3A53101%2Fscenario.xml&solution=planner_solution.xml
|
|
99
|
+
Open the URL in Chrome or Firefox (Safari blocks http://127.0.0.1 from an https page).
|
|
100
|
+
Watching for changes. Press Ctrl+C to stop.
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
その後は**監視**を続けます。プランナを再実行すると、開いているタブが solution、
|
|
104
|
+
verdict、trace を自動で再読み込みします (シナリオは再読み込みしません。描画は
|
|
105
|
+
drawtonomy 側の担当です)。ページは `/events` (Server-Sent Events) を購読します。CLI は
|
|
106
|
+
ファイルのサイズと mtime が 500 ms 静止するまで待つので、書き込み途中の solution が
|
|
107
|
+
配信されることはありません。CLI が計算した verdict は solution が変わるたびに
|
|
108
|
+
再計算されます。自分で置いた verdict は一切触られません。そのため solution だけが
|
|
109
|
+
変わった場合、ページは古いチェッカ結果 (前の solution のものです) を取り下げ、
|
|
110
|
+
verdict ファイルが更新され次第また表示します。
|
|
111
|
+
|
|
112
|
+
バインドするのは `127.0.0.1` のみ、応答するのは `GET` / `HEAD` / `OPTIONS` のみ、
|
|
113
|
+
到達できるのは配信対象ディレクトリのみ (`..` と絶対パスは 404)、
|
|
114
|
+
`Access-Control-Allow-Origin` は 1 つの origin だけを指定し、`*` は決して使いません。
|
|
115
|
+
|
|
116
|
+
| フラグ | |
|
|
117
|
+
|---|---|
|
|
118
|
+
| `--solution` / `--verdict` / `--trace` | 自動判別の結果を上書きする |
|
|
119
|
+
| `--port N` | ポートを固定する (既定: 空きポート) |
|
|
120
|
+
| `--no-browser` | ブラウザを開かず URL を表示するだけにする |
|
|
121
|
+
| `--copy` | 配信せずファイルパスを表示する。https ページから `http://127.0.0.1` をブロックするブラウザ (Safari) 向け。表示されたファイルを drawtonomy.com にドロップする |
|
|
122
|
+
| `--app-origin URL` | ファイルの読み取りを許可する origin (既定 `https://drawtonomy.com`) |
|
|
123
|
+
|
|
124
|
+
チェッカが無い場合は単に verdict が付かないだけです。1 行その旨が表示され、
|
|
125
|
+
シナリオは drawtonomy 自身の衝突バッジ付きで開きます。
|
|
126
|
+
|
|
127
|
+
プロトコル: [`docs/open-server-protocol.ja.md`](docs/open-server-protocol.ja.md)。
|
|
128
|
+
|
|
129
|
+
## サンプル
|
|
130
|
+
|
|
131
|
+
`examples/idm_planner/` は、このパッケージ向けに書かれた 1 ファイルのプランナです。
|
|
132
|
+
ego は開始した lanelet の中心線をたどり、速度は IDM の追従モデルが決めます。依存は
|
|
133
|
+
commonroad-io と numpy だけです。接続できる最小の構成であり、同梱の 2 つのモードに
|
|
134
|
+
ついては README で説明しています。
|
|
135
|
+
|
|
136
|
+
`examples/reactive_planner/` は commonroad-reactive-planner を端から端まで
|
|
137
|
+
つないだ例です。どちらもあくまで例なので、プランナ側をご自身のものに差し替え、
|
|
138
|
+
受け渡し側はそのまま使ってください。
|
|
139
|
+
|
|
140
|
+
## 契約ドキュメント
|
|
141
|
+
|
|
142
|
+
| ドキュメント | 規定している内容 |
|
|
143
|
+
|---|---|
|
|
144
|
+
| [`docs/verdict-sidecar.ja.md`](docs/verdict-sidecar.ja.md) | `drawtonomy-cr verdict` が書き出す `drawtonomy-verdict/1` サイドカー |
|
|
145
|
+
| [`docs/planning-trace-format.ja.md`](docs/planning-trace-format.ja.md) | `TraceWriter` が書き出す `drawtonomy-planning-trace-v1` ファイル |
|
|
146
|
+
| [`docs/open-server-protocol.ja.md`](docs/open-server-protocol.ja.md) | `drawtonomy-cr open` が配信するもの、表示する URL、`/events` ストリーム |
|
|
147
|
+
|
|
148
|
+
## 開発
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
pip install "drawtonomy-commonroad[test]"
|
|
152
|
+
pytest
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
公式チェッカが必要なテストは、それをインストールできない環境ではスキップされる
|
|
156
|
+
ので、テストスイートはどこでも実行できます。Node のツールチェーンは使いません。
|
|
157
|
+
|
|
158
|
+
## checker を入れられない環境
|
|
159
|
+
|
|
160
|
+
`commonroad-drivability-checker` が公開している wheel は manylinux x86_64 だけなので、
|
|
161
|
+
`[checker]` の extra はすべての環境に入れられるわけではありません。入らない環境では、
|
|
162
|
+
verdict の実行だけを Linux x86_64 のコンテナで行ってください。
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
docker run --rm --platform linux/amd64 -v "$PWD:/work" -w /work python:3.11 sh -c \
|
|
166
|
+
'pip install "drawtonomy-commonroad[checker]" &&
|
|
167
|
+
drawtonomy-cr verdict scenario.xml planner_solution.xml'
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
チェッカが無い場合、`drawtonomy-cr verdict` は終了コード 3 でその旨を 1 行だけ表示し、
|
|
171
|
+
`drawtonomy-cr open` は verdict の無いままシナリオを配信します。`open` は想定される
|
|
172
|
+
名前の verdict ファイルを監視し続けるので、`open` の起動後にコンテナから書き出せば、
|
|
173
|
+
そのままタブに反映されます。
|
|
174
|
+
|
|
175
|
+
## ライセンス
|
|
176
|
+
|
|
177
|
+
Apache-2.0。[`LICENSE`](LICENSE) を参照してください。
|