]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/commitdiff
Randomized slot at 20m radius
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 3 Feb 2020 13:53:07 +0000 (14:53 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Tue, 4 Feb 2020 17:11:27 +0000 (18:11 +0100)
scripts/generate_simple_json_scenario.py

index 5eb0a88e3a7f6610b359267af49df03759a8d24d..0e7f629dac0449e00e58136fa4318a3537e1541f 100644 (file)
@@ -10,7 +10,7 @@ The scenario contains at least:
 """
 from json import dumps, loads
 from math import cos, pi, sin
-from random import random
+from random import random, uniform
 
 W = 1.625
 WB = 2.450
@@ -32,14 +32,11 @@ def gen_slot(l=5.3, w=2.4):
         ol = l
         l = w
         w = ol
-    coord_min = 2 * MTR
-    coord_max = 20
-    coord_dif = coord_max - coord_min
-    x = random() * coord_dif + coord_min
-    x *= -1 if random() < 0.5 else 1
-    y = random() * coord_dif + coord_min
-    y *= -1 if random() < 0.5 else 1
-    h = random() * 2 * pi
+    r = 20
+    angl = uniform(0, 2 * pi)
+    x = r * cos(angl)
+    y = r * sin(angl)
+    h = uniform(0, 2 * pi)
     if parallel:
         return [[
             [