-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtarang_test_normal.scenic
54 lines (43 loc) · 1.65 KB
/
tarang_test_normal.scenic
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
import sys
try:
# sys.path.append("./libs/carla-0.9.9-py3.7-linux-x86_64.egg")
sys.path.append("./libs/carla-0.9.11-py3.7-linux-x86_64.egg")
except IndexError:
pass
## SET MAP AND MODEL (i.e. definitions of all referenceable vehicle types, road library, etc)
param map = localPath('maps/CARLA/Town03.xodr')
param carla_map = 'Town03'
param weather = 'ClearNoon'
model scenic.simulators.carla.model #located in scenic/simulators/carla/model.scenic
## CONSTANTS
MAX_BREAK_THRESHOLD = 1
SAFETY_DISTANCE = 15
LIGHT_DIST = 5
BYPASS_DIST = 18
CAR_SPEED = 7
roads = network.roads
## DEFINING BEHAVIORS
behavior CollisionAvoidance():
while withinDistanceToAnyObjs(self, SAFETY_DISTANCE):
take SetBrakeAction(MAX_BREAK_THRESHOLD)
behavior NormalCarBehavior():
try:
do FollowLaneBehavior(CAR_SPEED)
interrupt when withinDistanceToRedYellowTrafficLight(self,LIGHT_DIST):
while withinDistanceToRedYellowTrafficLight(self, LIGHT_DIST):
take SetBrakeAction(MAX_BREAK_THRESHOLD)
# interrupt when withinDistanceToObjsInLane(self, SAFETY_DISTANCE):
# while withinDistanceToObjsInLane(self, SAFETY_DISTANCE):
# take SetBrakeAction(MAX_BREAK_THRESHOLD)
# make sure to put '*' to uniformly randomly select from all elements of the list of roads
select_road = Uniform(*roads)
ego_lane = select_road.lanes[0]
start = OrientedPoint on ego_lane.centerline
ego = Car at start,
with behavior NormalCarBehavior()
for i in range(10):
select_road2 = Uniform(*roads)
ego_lane2 = select_road2.lanes[0]
start = OrientedPoint on ego_lane2.centerline
Car at start,
with behavior NormalCarBehavior()