-
Notifications
You must be signed in to change notification settings - Fork 36
/
CarlaDataAcquisition.m
33 lines (27 loc) · 1.16 KB
/
CarlaDataAcquisition.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
port = int16(2000);
client = py.carla.Client('localhost', port);
client.set_timeout(10.0);
world = client.get_world();
% Spawn Vehicle
blueprint_library = world.get_blueprint_library();
car_list = py.list(blueprint_library.filter("model3"));
car_bp = car_list{1};
spawn_point = py.random.choice(world.get_map().get_spawn_points());
tesla = world.spawn_actor(car_bp, spawn_point);
tesla.set_autopilot(true);
% Lidar
blueprint = world.get_blueprint_library().find('sensor.lidar.ray_cast');
blueprint.set_attribute('points_per_second', '140000');
blueprint.set_attribute('range', '25');
blueprint.set_attribute('upper_fov', '45.0')
blueprint.set_attribute('lower_fov', '-30.0')
transform = py.carla.Transform(py.carla.Location(pyargs('x',0.8, 'z',1.7)));
sensor = world.spawn_actor(blueprint, transform, pyargs('attach_to',tesla));
moduleLidar = sensorBind(sensor, 'lidar_file', 'lidar', 'array');
player = pcplayer([-25 25],[-25 25],[-10 10]);
while isOpen(player)
lidarData = single(py.getattr(moduleLidar, 'array'));
view(player, lidarData(:, 1:3));
end
fprintf('Destroyed tesla: %s\n', mat2str(tesla.destroy()));
fprintf('Destroyed sensor: %s\n', mat2str(sensor.destroy()));