From 74401ba8c7b86ba5923ef505cf4720eb5aee7ca1 Mon Sep 17 00:00:00 2001 From: Jiri Vlasak Date: Thu, 30 Jan 2020 15:31:16 +0100 Subject: [PATCH] Add generate simple json scenario script draft --- scripts/generate_simple_json_scenario.py | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 scripts/generate_simple_json_scenario.py diff --git a/scripts/generate_simple_json_scenario.py b/scripts/generate_simple_json_scenario.py new file mode 100644 index 0000000..92c18fc --- /dev/null +++ b/scripts/generate_simple_json_scenario.py @@ -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, + })) -- 2.39.2