CARLA ? C-Shenron based Simualtor for Sensor data generation.
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.
 
 
 
 
 

35 lines
830 B

import carla
import time
client = carla.Client("localhost", 2000)
client.set_timeout(5.0)
world = client.get_world()
blueprint_library = world.get_blueprint_library()
# Spawn vehicle
vehicle_bp = blueprint_library.filter("model3")[0]
spawn_point = world.get_map().get_spawn_points()[0]
vehicle = world.spawn_actor(vehicle_bp, spawn_point)
vehicle.set_autopilot(True)
# Get spectator (this is the simulator camera)
spectator = world.get_spectator()
try:
while True:
transform = vehicle.get_transform()
# Position camera behind and above vehicle
spectator_transform = carla.Transform(
transform.location + carla.Location(x=-6, z=3),
transform.rotation
)
spectator.set_transform(spectator_transform)
time.sleep(0.05)
finally:
vehicle.destroy()