use carla::client::{ActorBase, Client};
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Connecting to CARLA simulator...");
let client = Client::connect("localhost", 2000, None)?;
println!("Connected!");
println!("\nGetting current world...");
let mut world = client.world()?;
println!("World ready!");
let blueprint_library = world.blueprint_library()?;
let vehicle_bp = blueprint_library
.find("vehicle.tesla.model3")?
.expect("Tesla Model 3 not found");
println!("Found blueprint: {}", vehicle_bp.id());
let spawn_points = world.map()?.recommended_spawn_points()?;
println!("Available spawn points: {}", spawn_points.len());
let spawn_point = spawn_points.get(0).expect("No spawn points available");
println!("Spawning vehicle at spawn point 0...");
let vehicle = world
.spawn_actor(&vehicle_bp, spawn_point)
.expect("Failed to spawn vehicle");
println!("✓ Vehicle spawned successfully!");
println!(" Type: {}", vehicle.type_id());
println!(" ID: {}", vehicle.id());
println!(" Alive: {}", vehicle.is_alive()?);
let location = vehicle.location()?;
println!(
" Location: x={:.2}, y={:.2}, z={:.2}",
location.x, location.y, location.z
);
println!("\nVehicle will remain in the simulation.");
println!("Restart CARLA to clean up spawned actors.");
Ok(())
}