From 7891a0b1380306d980cdbb519cb0206bc3029683 Mon Sep 17 00:00:00 2001 From: nsubiron Date: Sat, 3 Nov 2018 12:28:14 +0100 Subject: [PATCH] Add --safe argument to spawn_npc.py --- PythonAPI/spawn_npc.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/PythonAPI/spawn_npc.py b/PythonAPI/spawn_npc.py index bb4e9a721..470a6f1b6 100755 --- a/PythonAPI/spawn_npc.py +++ b/PythonAPI/spawn_npc.py @@ -53,6 +53,10 @@ def main(): default=2.0, type=float, help='delay in seconds between spawns (default: 2.0)') + argparser.add_argument( + '--safe', + action='store_true', + help='avoid spawning vehicles prone to accidents') args = argparser.parse_args() actor_list = [] @@ -64,6 +68,10 @@ def main(): world = client.get_world() blueprints = world.get_blueprint_library().filter('vehicle.*') + if args.safe: + blueprints = [x for x in blueprints if int(x.get_attribute('number_of_wheels')) == 4] + blueprints = [x for x in blueprints if not x.id.endswith('isetta')] + def try_spawn_random_vehicle_at(transform): blueprint = random.choice(blueprints) if blueprint.has_attribute('color'):