-
Notifications
You must be signed in to change notification settings - Fork 377
/
Copy pathscenario_configuration.py
87 lines (66 loc) · 2.4 KB
/
scenario_configuration.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
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python
# Copyright (c) 2019 Intel Corporation
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
"""
This module provides the key configuration parameters for an XML-based scenario
"""
import carla
class ActorConfigurationData(object):
"""
This is a configuration base class to hold model and transform attributes
"""
def __init__(self, model, transform, rolename='other', speed=0, autopilot=False,
random=False, color=None, category="car", args=None, controller=None):
self.model = model
self.rolename = rolename
self.transform = transform
self.speed = speed
self.autopilot = autopilot
self.random_location = random
self.color = color
self.category = category
self.args = args
self.controller = controller
@staticmethod
def parse_from_node(node, rolename):
"""
static method to initialize an ActorConfigurationData from a given ET tree
"""
model = node.attrib.get('model', 'vehicle.*')
pos_x = float(node.attrib.get('x', 0))
pos_y = float(node.attrib.get('y', 0))
pos_z = float(node.attrib.get('z', 0))
yaw = float(node.attrib.get('yaw', 0))
transform = carla.Transform(carla.Location(x=pos_x, y=pos_y, z=pos_z), carla.Rotation(yaw=yaw))
rolename = node.attrib.get('rolename', rolename)
speed = node.attrib.get('speed', 0)
autopilot = False
if 'autopilot' in node.keys():
autopilot = True
random_location = False
if 'random_location' in node.keys():
random_location = True
color = node.attrib.get('color', None)
return ActorConfigurationData(model, transform, rolename, speed, autopilot, random_location, color)
class ScenarioConfiguration(object):
"""
This class provides a basic scenario configuration incl.:
- configurations for all actors
- town, where the scenario should be executed
- name of the scenario (e.g. ControlLoss_1)
- type is the class of scenario (e.g. ControlLoss)
"""
trigger_points = []
ego_vehicles = []
other_actors = []
town = None
name = None
type = None
route = None
agent = None
weather = carla.WeatherParameters()
friction = None
subtype = None
route_var_name = None