Added filter check to examples
This commit is contained in:
parent
355c47f7ac
commit
a9819fa289
|
@ -145,7 +145,10 @@ class World(object):
|
|||
cam_pos_id = self.camera_manager.transform_index if self.camera_manager is not None else 0
|
||||
|
||||
# Get a random blueprint.
|
||||
blueprint = random.choice(get_actor_blueprints(self.world, self._actor_filter, self._actor_generation))
|
||||
blueprint_list = get_actor_blueprints(self.world, self._actor_filter, self._actor_generation)
|
||||
if not blueprint_list:
|
||||
raise ValueError("Couldn't find any blueprints with the specified filters")
|
||||
blueprint = random.choice(blueprint_list)
|
||||
blueprint.set_attribute('role_name', 'hero')
|
||||
if blueprint.has_attribute('color'):
|
||||
color = random.choice(blueprint.get_attribute('color').recommended_values)
|
||||
|
|
|
@ -193,7 +193,11 @@ def main():
|
|||
world.apply_settings(settings)
|
||||
|
||||
blueprints = get_actor_blueprints(world, args.filterv, args.generationv)
|
||||
if not blueprints:
|
||||
raise ValueError("Couldn't find any vehicles with the specified filters")
|
||||
blueprintsWalkers = get_actor_blueprints(world, args.filterw, args.generationw)
|
||||
if not blueprintsWalkers:
|
||||
raise ValueError("Couldn't find any walkers with the specified filters")
|
||||
|
||||
if args.safe:
|
||||
blueprints = [x for x in blueprints if x.get_attribute('base_type') == 'car']
|
||||
|
|
|
@ -244,7 +244,10 @@ class World(object):
|
|||
cam_index = self.camera_manager.index if self.camera_manager is not None else 0
|
||||
cam_pos_index = self.camera_manager.transform_index if self.camera_manager is not None else 0
|
||||
# Get a random blueprint.
|
||||
blueprint = random.choice(get_actor_blueprints(self.world, self._actor_filter, self._actor_generation))
|
||||
blueprint_list = get_actor_blueprints(self.world, self._actor_filter, self._actor_generation)
|
||||
if not blueprint_list:
|
||||
raise ValueError("Couldn't find any blueprints with the specified filters")
|
||||
blueprint = random.choice(blueprint_list)
|
||||
blueprint.set_attribute('role_name', self.actor_role_name)
|
||||
if blueprint.has_attribute('terramechanics'):
|
||||
blueprint.set_attribute('terramechanics', 'true')
|
||||
|
@ -597,7 +600,7 @@ class KeyboardControl(object):
|
|||
def _parse_vehicle_keys(self, keys, milliseconds):
|
||||
if keys[K_UP] or keys[K_w]:
|
||||
if not self._ackermann_enabled:
|
||||
self._control.throttle = min(self._control.throttle + 0.01, 1.00)
|
||||
self._control.throttle = min(self._control.throttle + 0.1, 1.00)
|
||||
else:
|
||||
self._ackermann_control.speed += round(milliseconds * 0.005, 2) * self._ackermann_reverse
|
||||
else:
|
||||
|
|
|
@ -268,7 +268,10 @@ class World(object):
|
|||
cam_index = self.camera_manager.index if self.camera_manager is not None else 0
|
||||
cam_pos_index = self.camera_manager.transform_index if self.camera_manager is not None else 0
|
||||
# Get a random blueprint.
|
||||
blueprint = random.choice(get_actor_blueprints(self.world, self._actor_filter, self._actor_generation))
|
||||
blueprint_list = get_actor_blueprints(self.world, self._actor_filter, self._actor_generation)
|
||||
if not blueprint_list:
|
||||
raise ValueError("Couldn't find any blueprints with the specified filters")
|
||||
blueprint = random.choice(blueprint_list)
|
||||
blueprint.set_attribute('role_name', self.actor_role_name)
|
||||
if blueprint.has_attribute('color'):
|
||||
color = random.choice(blueprint.get_attribute('color').recommended_values)
|
||||
|
|
Loading…
Reference in New Issue