Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ dmypy.json
# Cython debug symbols
cython_debug/
.idea
*.json
#*.json
*.csv
output/
outputs
Expand Down
4 changes: 2 additions & 2 deletions opencda.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def arg_parse():
action='store_true',
help='whether ml/dl framework such as sklearn/pytorch is needed in the testing. '
'Set it to true only when you have installed the pytorch/sklearn package.')
parser.add_argument('-v', "--version", type=str, default='0.9.11',
parser.add_argument('-v', "--version", type=str, default='0.9.14',
help='Specify the CARLA simulator version, default'
'is 0.9.11, 0.9.12 is also supported.')
'is 0.9.14')
# parse the arguments and return the result
opt = parser.parse_args()
return opt
Expand Down
89 changes: 89 additions & 0 deletions opencda/assets/blueprint_meta/bbx_stats_0914.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"vehicle.audi.a2": {
"class": "car"
},
"vehicle.audi.tt": {
"class": "car"
},
"vehicle.ford.ambulance": {
"class": "truck"
},
"vehicle.ford.crown": {
"class": "car"
},
"vehicle.mini.cooper_s_2021": {
"class": "car"
},
"vehicle.nissan.micra": {
"class": "car"
},
"vehicle.nissan.patrol": {
"class": "suv"
},
"vehicle.nissan.patrol_2021": {
"class": "suv"
},
"vehicle.tesla.cybertruck": {
"class": "truck"
},
"vehicle.volkswagen.t2": {
"class": "bus"
},
"vehicle.volkswagen.t2_2021": {
"class": "bus"
},
"vehicle.micro.microlino": {
"class": "car"
},
"vehicle.dodge.charger_police": {
"class": "car"
},
"vehicle.dodge.charger_police_2020": {
"class": "car"
},
"vehicle.dodge.charger_2020": {
"class": "car"
},
"vehicle.jeep.wrangler_rubicon": {
"class": "suv"
},
"vehicle.chevrolet.impala": {
"class": "car"
},
"vehicle.mini.cooper_s": {
"class": "car"
},
"vehicle.audi.etron": {
"class": "suv"
},
"vehicle.mercedes.coupe": {
"class": "car"
},
"vehicle.mercedes.coupe_2020": {
"class": "car"
},
"vehicle.bmw.grandtourer": {
"class": "car"
},
"vehicle.toyota.prius": {
"class": "car"
},
"vehicle.citroen.c3": {
"class": "car"
},
"vehicle.ford.mustang": {
"class": "car"
},
"vehicle.tesla.model3": {
"class": "car"
},
"vehicle.lincoln.mkz_2017": {
"class": "car"
},
"vehicle.lincoln.mkz_2020": {
"class": "car"
},
"vehicle.seat.leon": {
"class": "car"
}
}
6 changes: 5 additions & 1 deletion opencda/core/map/map_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,11 @@ def generate_lane_cross_info(self):
while nxt.road_id == waypoint.road_id \
and nxt.lane_id == waypoint.lane_id:
waypoints.append(nxt)
nxt = nxt.next(self.lane_sample_resolution)[0]
nxt = nxt.next(self.lane_sample_resolution)
if len(nxt) > 0:
nxt = nxt[0]
else:
break

# waypoint is the centerline, we need to calculate left lane mark
left_marking = [lateral_shift(w.transform, -w.lane_width * 0.5) for
Expand Down
7 changes: 5 additions & 2 deletions opencda/core/sensing/perception/perception_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,14 +613,14 @@ def deactivate_mode(self, objects):
objects.update({'vehicles': vehicle_list})

if self.camera_visualize:
while self.rgb_camera[0].image is None:
continue

names = ['front', 'right', 'left', 'back']

for (i, rgb_camera) in enumerate(self.rgb_camera):
if i > self.camera_num - 1 or i > self.camera_visualize - 1:
break
while rgb_camera.image is None:
continue
# we only visualiz the frontal camera
rgb_image = np.array(rgb_camera.image)
# draw the ground truth bbx on the camera image
Expand Down Expand Up @@ -675,6 +675,9 @@ def filter_vehicle_out_sensor(self, vehicle_list):
semantic_idx = self.semantic_lidar.obj_idx
semantic_tag = self.semantic_lidar.obj_tag

if semantic_tag is None or semantic_idx is None:
print('none')
return vehicle_list
# label 10 is the vehicle
vehicle_idx = semantic_idx[semantic_tag == 10]
# each individual instance id
Expand Down
9 changes: 7 additions & 2 deletions opencda/scenario_testing/config_yaml/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ world:
fixed_delta_seconds: 0.05
seed: 11 # seed for numpy and random
weather:
sun_altitude_angle: 15 # 90 is the midday and -90 is the midnight
sun_altitude_angle: 50 # 90 is the midday and -90 is the midnight
cloudiness: 0 # 0 is the clean sky and 100 is the thickest cloud
precipitation: 0 # rain, 100 is the heaviest rain
precipitation_deposits: 0 # Determines the creation of puddles. Values range from 0 to 100, being 0 none at all and 100 a road completely capped with water.
Expand Down Expand Up @@ -105,7 +105,7 @@ vehicle_base:
history_size: 30
col_thresh: 1
stuck_dector:
len_thresh: 500
len_thresh: 1000
speed_thresh: 0.5
offroad_dector: [ ]
traffic_light_detector: # whether the vehicle violate the traffic light
Expand Down Expand Up @@ -164,6 +164,11 @@ carla_traffic_manager:
set_osm_mode: true # Enables or disables the OSM mode.
auto_lane_change: false
ignore_lights_percentage: 0 # whether set the traffic ignore traffic lights
ignore_signs_percentage: 0 # whether the cars will ignore stop signs
ignore_vehicles_percentage: 0 # whether the cars will ignore other cars and cause collisions
ignore_walkers_percentage: 0 # whether the cars will ingore walkers
random_left_lanechange_percentage: 0 # Adjust probability that in each timestep the actor will perform a left lane change, dependent on lane change availability.
random_right_lanechange_percentage: 0 # Adjust probability that in each timestep the actor will perform a right lane change, dependent on lane change availability.
random: false # whether to random select vehicles' color and model
vehicle_list: [] # define in each scenario. If set to ~, then the vehicles be spawned in a certain range
# Used only when vehicle_list is ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ scenario:
spawn_position: [-380, 4.8, 0.3, 0, 0, 0]
# when this is defined, the above parameter will be ignored, and a special map function will
# be used to define the spawn position based on the argument
spawn_special: [0.625]
spawn_special: [0.700]
destination: [300, 12.0, 0]
sensing:
perception:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ carla_traffic_manager:
# Carla default speed is 30 km/h, so -100 represents 60 km/h,
# and 20 represents 24 km/h
global_speed_perc: -50
ignore_lights_percentage: 0 # whether set the traffic ignore traffic lights
vehicle_list:
- spawn_position: [101.7194, 136.51, 0.3, 0, 0, 0]
vehicle_speed_perc: -200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ world:

# First define the basic parameters of the vehicles
vehicle_base:
behavior:
max_speed: 101 # maximum speed, km/h

map_manager:
visualize: false
activate: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ vehicle_base:
# define the background traffic control by carla
carla_traffic_manager:
random: true # whether to random select vehicles' color and model
global_speed_perc: 0
vehicle_list: ~ # a number or a list
# Used only when vehicle_list is a number.
# x_min, x_max, y_min, y_max, x_step, y_step, veh_num
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ vehicle_base:
# define the background traffic control by carla
carla_traffic_manager:
random: true # whether to random select vehicles' color and model
ignore_lights_percentage: 0 # whether set the traffic ignore traffic lights
vehicle_list: ~ # a number or a list
# Used only when vehicle_list is a number.
# x_min, x_max, y_min, y_max, x_step, y_step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ description: |-
# Comment out this chunk of code or set use_multi_class_bp to be False if you don't want to spawn multi-class actors
blueprint:
use_multi_class_bp: true
bp_meta_path: "opencda/assets/blueprint_meta/bbx_stats_0912.json" # Define the path for loading the blueprint metadata for defining the class of each blueprint
bp_meta_path: "opencda/assets/blueprint_meta/bbx_stats_0914.json" # Define the path for loading the blueprint metadata for defining the class of each blueprint
# Define blueprint type sample probabilities
bp_class_sample_prob:
car: 0.5
truck: 0.1
bus: 0.1
bicycle: 0.1
motorcycle: 0.1
suv: 0.2


# Define the basic parameters of the vehicles
Expand Down Expand Up @@ -46,7 +45,7 @@ vehicle_base:
visualize: false
activate: false
behavior:
max_speed: 30 # maximum speed, km/h
max_speed: 25 # maximum speed, km/h
tailgate_speed: 34 # when a vehicles needs to be close to another vehicle asap
overtake_allowed: false # whether overtake allowed, typically false for platoon leader

Expand Down Expand Up @@ -80,12 +79,3 @@ scenario:
local_planner:
debug_trajectory: false
debug: false
- name: cav2
spawn_position: [-5.51, 110.24, 0.3, 0, 90, 0]
destination: [-2.43, 263, 0.3]
v2x:
communication_range: 45
behavior:
local_planner:
debug_trajectory: false
debug: false
71 changes: 36 additions & 35 deletions opencda/scenario_testing/utils/sim_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,21 @@ def car_blueprint_filter(blueprint_library, carla_version='0.9.11'):
The list of suitable blueprints for vehicles.
"""

if carla_version == '0.9.11':
print('old version')
if carla_version == '0.9.14':
print('CARLA 0914 version is selected')
blueprints = [
blueprint_library.find('vehicle.audi.a2'),
blueprint_library.find('vehicle.audi.tt'),
blueprint_library.find('vehicle.dodge_charger.police'),
blueprint_library.find('vehicle.jeep.wrangler_rubicon'),
blueprint_library.find('vehicle.chevrolet.impala'),
blueprint_library.find('vehicle.mini.cooperst'),
blueprint_library.find('vehicle.audi.etron'),
blueprint_library.find('vehicle.mercedes-benz.coupe'),
blueprint_library.find('vehicle.bmw.grandtourer'),
blueprint_library.find('vehicle.toyota.prius'),
blueprint_library.find('vehicle.citroen.c3'),
blueprint_library.find('vehicle.mustang.mustang'),
blueprint_library.find('vehicle.tesla.model3'),
blueprint_library.find('vehicle.lincoln.mkz2017'),
blueprint_library.find('vehicle.seat.leon'),
blueprint_library.find('vehicle.nissan.patrol'),
blueprint_library.find('vehicle.ford.ambulance'),
blueprint_library.find('vehicle.ford.crown'),
blueprint_library.find('vehicle.mini.cooper_s_2021'),
blueprint_library.find('vehicle.nissan.micra'),
]

else:
blueprints = [
blueprint_library.find('vehicle.audi.a2'),
blueprint_library.find('vehicle.audi.tt'),
blueprint_library.find('vehicle.nissan.patrol'),
blueprint_library.find('vehicle.nissan.patrol_2021'),
blueprint_library.find('vehicle.tesla.cybertruck'),
blueprint_library.find('vehicle.volkswagen.t2'),
blueprint_library.find('vehicle.volkswagen.t2_2021'),
blueprint_library.find('vehicle.micro.microlino'),
blueprint_library.find('vehicle.dodge.charger_police'),
blueprint_library.find('vehicle.dodge.charger_police_2020'),
blueprint_library.find('vehicle.dodge.charger_2020'),
Expand All @@ -91,8 +80,12 @@ def car_blueprint_filter(blueprint_library, carla_version='0.9.11'):
blueprint_library.find('vehicle.lincoln.mkz_2020'),
blueprint_library.find('vehicle.seat.leon'),
blueprint_library.find('vehicle.nissan.patrol'),
blueprint_library.find('vehicle.nissan.micra'),
blueprint_library.find('vehicle.nissan.micra')
]
else:
sys.exit("Since v0.1.4, we do not support version earlier than "
"CARLA v0.9.14. If you want to use early CARLA version including"
"0.9.11 and 0.9.12, please use OpenCDA v0.1.3.")

return blueprints

Expand Down Expand Up @@ -290,9 +283,7 @@ def create_vehicle_manager(self, application,
"""
print('Creating single CAVs.')
# By default, we use lincoln as our cav model.
default_model = 'vehicle.lincoln.mkz2017' \
if self.carla_version == '0.9.11' else 'vehicle.lincoln.mkz_2017'

default_model = 'vehicle.lincoln.mkz_2017'
cav_vehicle_bp = \
self.world.get_blueprint_library().find(default_model)
single_cav_list = []
Expand Down Expand Up @@ -372,8 +363,7 @@ def create_platoon_manager(self, map_helper=None, data_dump=False):

# we use lincoln as default choice since our UCLA mobility lab use the
# same car
default_model = 'vehicle.lincoln.mkz2017' \
if self.carla_version == '0.9.11' else 'vehicle.lincoln.mkz_2017'
default_model = 'vehicle.lincoln.mkz_2017'

cav_vehicle_bp = \
self.world.get_blueprint_library().find(default_model)
Expand Down Expand Up @@ -493,8 +483,7 @@ def spawn_vehicles_by_list(self, tm, traffic_config, bg_list):

# if not random select, we always choose lincoln.mkz with green color
color = '0, 255, 0'
default_model = 'vehicle.lincoln.mkz2017' \
if self.carla_version == '0.9.11' else 'vehicle.lincoln.mkz_2017'
default_model = 'vehicle.lincoln.mkz_2020'
ego_vehicle_bp = blueprint_library.find(default_model)

for i, vehicle_config in enumerate(traffic_config['vehicle_list']):
Expand Down Expand Up @@ -568,8 +557,7 @@ def spawn_vehicle_by_range(self, tm, traffic_config, bg_list):

# if not random select, we always choose lincoln.mkz with green color
color = '0, 255, 0'
default_model = 'vehicle.lincoln.mkz2017' \
if self.carla_version == '0.9.11' else 'vehicle.lincoln.mkz_2017'
default_model = 'vehicle.lincoln.mkz_2020'
ego_vehicle_bp = blueprint_library.find(default_model)

spawn_ranges = traffic_config['range']
Expand Down Expand Up @@ -638,10 +626,23 @@ def spawn_vehicle_by_range(self, tm, traffic_config, bg_list):
vehicle.set_autopilot(True, 8000)
tm.auto_lane_change(vehicle, traffic_config['auto_lane_change'])

if 'ignore_lights_percentage' in traffic_config:
tm.ignore_lights_percentage(vehicle,
traffic_config[
# hazard behavior for traffic
tm.ignore_lights_percentage(vehicle, traffic_config[
'ignore_lights_percentage'])
tm.ignore_signs_percentage(vehicle, traffic_config[
'ignore_signs_percentage'])
tm.ignore_vehicles_percentage(vehicle, traffic_config[
'ignore_vehicles_percentage'])
tm.ignore_walkers_percentage(vehicle, traffic_config[
'ignore_walkers_percentage'])

# left/right lane change
if traffic_config['random_left_lanechange_percentage'] != 0:
tm.random_left_lanechange_percentage(vehicle,
traffic_config['random_left_lanechange_percentage'])
if traffic_config['random_right_lanechange_percentage'] != 0:
tm.random_right_lanechange_percentage(vehicle,
traffic_config['random_right_lanechange_percentage'])

# each vehicle have slight different speed
tm.vehicle_percentage_speed_difference(
Expand Down
2 changes: 1 addition & 1 deletion opencda/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Specifies the current version number of OpenCDA."""

__version__ = "0.1.2"
__version__ = "0.1.4"