Add vertical offset to avoid collision when spawning

This commit is contained in:
PabloVD 2024-10-02 18:18:12 +02:00 committed by Blyron
parent 7f51f21ee5
commit 2c7fcd5491
1 changed files with 1 additions and 0 deletions

View File

@ -327,6 +327,7 @@ def main():
ped_bp = random.choice(world.get_blueprint_library().filter("walker.pedestrian.*")) ped_bp = random.choice(world.get_blueprint_library().filter("walker.pedestrian.*"))
trans = carla.Transform() trans = carla.Transform()
trans.location = world.get_random_location_from_navigation() trans.location = world.get_random_location_from_navigation()
trans.location.z += 1 # Apply an offset in vertical axis to avoid collision spawning
ped = world.spawn_actor(ped_bp, trans) ped = world.spawn_actor(ped_bp, trans)
walker_controller_bp = world.get_blueprint_library().find('controller.ai.walker') walker_controller_bp = world.get_blueprint_library().find('controller.ai.walker')
controller = world.spawn_actor(walker_controller_bp, carla.Transform(), ped) controller = world.spawn_actor(walker_controller_bp, carla.Transform(), ped)