You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
808 B
29 lines
808 B
import carla
|
|
import argparse
|
|
|
|
def spawn_here():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--model", default="vehicle.nissan.micra")
|
|
args = parser.parse_args()
|
|
|
|
client = carla.Client("localhost", 2000)
|
|
client.set_timeout(10.0)
|
|
world = client.get_world()
|
|
|
|
spectator = world.get_spectator()
|
|
t = spectator.get_transform()
|
|
|
|
# Lower it slightly so it doesn't drop from the sky,
|
|
# but stays above ground
|
|
t.location.z -= 1.0
|
|
|
|
bp = world.get_blueprint_library().filter(args.model)[0]
|
|
actor = world.try_spawn_actor(bp, t)
|
|
|
|
if actor:
|
|
print(f"[SUCCESS] Spawned {args.model} at spectator location.")
|
|
else:
|
|
print("[ERROR] Spawn failed. Collision or invalid location.")
|
|
|
|
if __name__ == "__main__":
|
|
spawn_here()
|