]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/commitdiff
Add generate simple json scenario script draft
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 30 Jan 2020 14:31:16 +0000 (15:31 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Tue, 4 Feb 2020 17:11:27 +0000 (18:11 +0100)
scripts/generate_simple_json_scenario.py [new file with mode: 0644]

diff --git a/scripts/generate_simple_json_scenario.py b/scripts/generate_simple_json_scenario.py
new file mode 100644 (file)
index 0000000..92c18fc
--- /dev/null
@@ -0,0 +1,44 @@
+"""Generate simple JSON scenario.
+
+The scenario contains at least:
+
+- `init` -- the init car position,
+
+- `slot` -- the parking slot,
+
+- `obst` -- the list of (convex polygon) obstacles.
+"""
+from json import dumps, loads
+from random import random
+
+W = 1.625
+WB = 2.450
+CTC = 10.820
+MTR = ((CTC / 2)**2 - WB**2)**0.5 - W / 2
+
+def gen_init():
+    """Generate car init position."""
+    return (0, 0, 0)
+
+def gen_slot():
+    """Generate parking slot."""
+    return [[
+        [10, 10],
+        [13, 10],
+        [13, 17],
+        [10, 17],
+    ]]
+
+def gen_obst():
+    """Generate obstacles array."""
+    return []
+
+if __name__ == "__main__":
+    init = gen_init()
+    slot = gen_slot()
+    obst = gen_obst()
+    print(dumps({
+        "init": init,
+        "slot": slot,
+        "obst": obst,
+    }))