]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/commitdiff
Add gen slot at procedure
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Tue, 14 Mar 2023 08:28:50 +0000 (09:28 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Tue, 14 Mar 2023 14:38:08 +0000 (15:38 +0100)
scripts/generate_simple_json_scenario.py

index d8bfb2e54602e8dfbc69075eb3c5cb2bfeb11b43..d6d3359b528cd59a09d0434f3c3bf7b0d917e7d4 100644 (file)
@@ -30,6 +30,54 @@ def gen_init():
     return (0, 0, 0)
 
 
+def gen_slot_at(x, y, h, parallel=True):
+    """Generate slot at specified coordinates."""
+    length = 5.3
+    width = 2.4
+    if parallel:
+        length = 6.5
+        width = 2.2
+    right = 1
+    if parallel:
+        return [
+            [
+                x + length/2 * cos(h - pi/2 * right),
+                y + length/2 * sin(h - pi/2 * right),
+            ],
+            [
+                x + width * cos(h) + length/2 * cos(h - pi/2 * right),
+                y + width * sin(h) + length/2 * sin(h - pi/2 * right),
+            ],
+            [
+                x + width * cos(h) + length/2 * cos(h + pi/2 * right),
+                y + width * sin(h) + length/2 * sin(h + pi/2 * right),
+            ],
+            [
+                x + length/2 * cos(h + pi/2 * right),
+                y + length/2 * sin(h + pi/2 * right),
+            ],
+        ]
+    else:
+        return [
+            [
+                x + width/2 * cos(h - pi/2 * right),
+                y + width/2 * sin(h - pi/2 * right),
+            ],
+            [
+                x + length * cos(h) + width/2 * cos(h - pi/2 * right),
+                y + length * sin(h) + width/2 * sin(h - pi/2 * right),
+            ],
+            [
+                x + length * cos(h) + width/2 * cos(h + pi/2 * right),
+                y + length * sin(h) + width/2 * sin(h + pi/2 * right),
+            ],
+            [
+                x + width/2 * cos(h + pi/2 * right),
+                y + width/2 * sin(h + pi/2 * right),
+            ],
+        ]
+
+
 def gen_slot(l=5.3, w=2.4):
     """Generate parking slot."""
     parallel = True if random() < 0.5 else False