-
Notifications
You must be signed in to change notification settings - Fork 1
/
StaticGeometricMaps.py
77 lines (66 loc) · 1.81 KB
/
StaticGeometricMaps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
## @file StaticGeometricMaps.py
#
import numpy as np
import Vector
import Geometry
import os
import sys
from DynamicObstacles import DynamicObstacle
import MovementPattern
from Polygon import Polygon
import json
def _create_map_1(env):
#obs_movement = MovementPattern.StaticMovement((0,0))
#obs = DynamicObstacle(obs_movement)
#obs.fillcolor = (0x55, 0x55, 0x55)
#obs.shape = 4
#obs.polygon = Polygon([
# (640, 80),
# (640, 480),
# (445, 450),
# (408, 300),
# (408, 165),
# (460, 108),
# (490, 104),
# (490, 91),
# (640, 80),
#]);
with open('obs2.json') as f:
obslist = json.load(f)
for obs in obslist:
obs_movement = MovementPattern.StaticMovement((0,0))
if obs['type'] == 'circle':
obs_movement = MovementPattern.StaticMovement(obs['center'])
obs2 = DynamicObstacle(obs_movement)
obs2.shape = 1
obs2.radius = obs['radius']
obs2.fillcolor = (0x55, 0x55, 0x55)
env.static_obstacles.append(obs2)
continue
polygon = Polygon(np.array(obs['points']))
obs2 = DynamicObstacle(obs_movement)
obs2.shape = 4
obs2.polygon = polygon
obs2.fillcolor = (0x55, 0x55, 0x55)
env.static_obstacles.append(obs2)
#env.static_obstacles.append(obs)
def _create_map_2(env):
with open('obs2.json') as f:
obslist = json.load(f)
for obs in obslist:
obs_movement = MovementPattern.StaticMovement((0,0))
if obs['type'] == 'circle':
obs_movement = MovementPattern.StaticMovement(obs['center'])
obs2 = DynamicObstacle(obs_movement)
obs2.shape = 1
obs2.radius = obs['radius']
obs2.fillcolor = (0x55, 0x55, 0x55)
env.static_obstacles.append(obs2)
continue
polygon = Polygon(np.array(obs['points']))
obs2 = DynamicObstacle(obs_movement)
obs2.shape = 4
obs2.polygon = polygon
obs2.fillcolor = (0x55, 0x55, 0x55)
env.static_obstacles.append(obs2)
#env.static_obstacles.append(obs)