Skip to content

Commit

Permalink
Fix unit test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
TayYim committed Jun 7, 2024
1 parent 1bd6d09 commit 58656a3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions srunner/scenarioconfigs/openscenario_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def _extract_vehicle_information(self, obj, rolename, vehicle, args):

speed = self._get_actor_speed(rolename)
new_actor = ActorConfigurationData(
model, None, rolename, speed, color=color, category=category, args=args)
model, carla.Transform(), rolename, speed, color=color, category=category, args=args)

if ego_vehicle:
self.ego_vehicles.append(new_actor)
Expand All @@ -321,7 +321,7 @@ def _extract_pedestrian_information(self, obj, rolename, pedestrian, args):
model = pedestrian.attrib.get('model', "walker.*")

speed = self._get_actor_speed(rolename)
new_actor = ActorConfigurationData(model, None, rolename, speed, category="pedestrian", args=args)
new_actor = ActorConfigurationData(model, carla.Transform(), rolename, speed, category="pedestrian", args=args)

self.other_actors.append(new_actor)

Expand All @@ -336,7 +336,7 @@ def _extract_misc_information(self, obj, rolename, misc, args):
model = "static.prop.chainbarrier"
else:
model = misc.attrib.get('name')
new_actor = ActorConfigurationData(model, None, rolename, category="misc", args=args)
new_actor = ActorConfigurationData(model, carla.Transform(), rolename, category="misc", args=args)

self.other_actors.append(new_actor)

Expand Down
10 changes: 9 additions & 1 deletion srunner/tests/carla_mocks/carla.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class Waypoint():
class Map:
name = ""

def __init__(self, name='Town01'):
self.name = name

def get_spawn_points(self):
return []

Expand Down Expand Up @@ -263,12 +266,16 @@ class Vehicle(Actor):

class World:
actors = []
map = Map()

def get_settings(self):
return WorldSettings()

def get_map(self):
return Map()
return self.map

def set_map(self, map):
self.map = map

def get_blueprint_library(self):
return CarlaBluePrintLibrary()
Expand Down Expand Up @@ -300,6 +307,7 @@ class Client:
world = World()

def load_world(self, name):
self.world.set_map(Map(name))
return None

def get_world(self):
Expand Down
4 changes: 2 additions & 2 deletions srunner/tools/openscenario_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def get_traffic_light_from_osc_name(name):
elif name.startswith("pos="):
tl_pos = name[4:]
pos = tl_pos.split(",")
for carla_tl in CCarlaDataProvider.get_all_actors().filter('traffic.traffic_light'):
for carla_tl in CarlaDataProvider.get_all_actors().filter('traffic.traffic_light'):
carla_tl_location = carla_tl.get_transform().location
distance = carla_tl_location.distance(carla.Location(float(pos[0]),
float(pos[1]),
Expand Down Expand Up @@ -1278,7 +1278,7 @@ def convert_maneuver_to_atomic(action, actor, actor_list, catalogs, config):
atomic = ActorDestroy(entity_ref_actor)
elif entity_action.find('AddEntityAction') is not None:
position = entity_action.find('AddEntityAction').find("Position")
actor_transform = OpenScenarioParser.convert_position_to_transform(position)
actor_transform = OpenScenarioParser.convert_position_to_transform(position, config.other_actors + config.ego_vehicles)
entity_ref_actor = None
for _actor in config.other_actors:
if _actor.rolename == entity_ref:
Expand Down

0 comments on commit 58656a3

Please sign in to comment.