-
Notifications
You must be signed in to change notification settings - Fork 0
/
topviewangle.py
71 lines (55 loc) · 2.37 KB
/
topviewangle.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import glob
import os
import sys
import time
try:
sys.path.append(glob.glob('./PythonAPI/carla/dist/carla-*%d.%d-%s.egg' % (
sys.version_info.major,
sys.version_info.minor,
'win-amd64' if os.name == 'nt' else 'linux-x86_64'))[0])
except IndexError:
pass
#Import Carla
import carla
client = carla.Client('localhost', 2000)
client.set_timeout(2.0)
world = client.get_world()
blueprint_library = world.get_blueprint_library()
bp = blueprint_library.filter('vehicle.*')[4]
bp.set_attribute('role_name','ego')
world = client.get_world()
#Spawn Point for vehicle
#spawnPoint=carla.Transform(carla.Location(x=38.6,y=5.8, z=0.598),carla.Rotation(pitch=0.0, yaw=0.0, roll=0.000000))
#vehicle = world.spawn_actor(bp, spawnPoint)
spawnPoint=carla.Transform(carla.Location(x=20.6, y = 13, z= 0.598),carla.Rotation(pitch=0.0, yaw=0.0, roll=0.000000))
vehicle = world.spawn_actor(bp, spawnPoint)
# Camera Manager
cam_bp = None
cam_bp = world.get_blueprint_library().find('sensor.camera.rgb')
#Image Size in term of X and Y
cam_bp.set_attribute("image_size_x",str(640))
cam_bp.set_attribute("image_size_y",str(480))
# Field of view
cam_bp.set_attribute("fov",str(105))
# X_Y_Z Position of Camera
cam_location = carla.Location(0,0,15)
#Pitch_Yaw_Roll Rotation of Camera
cam_rotation = carla.Rotation(-90,90,-90)
cam_transform = carla.Transform(cam_location,cam_rotation)
ego_cam = world.spawn_actor(cam_bp,cam_transform,attach_to=vehicle, attachment_type=carla.AttachmentType.Rigid)
#ego_cam = world.spawn_actor(cam_bp,attach_to=vehicle, attachment_type=carla.AttachmentType.Rigid)
ego_cam.listen(lambda image: image.save_to_disk('tutorial/output/%.6d.jpg' % image.frame))
# GNSS Sensor
gnss_bp = world.get_blueprint_library().find('sensor.other.gnss')
gnss_location = carla.Location(1,0,2)
gnss_rotation = carla.Rotation(0,0,0)
gnss_transform = carla.Transform(gnss_location,gnss_rotation)
gnss = world.spawn_actor(gnss_bp,gnss_transform,attach_to=vehicle, attachment_type=carla.AttachmentType.Rigid)
#Attaching Lidar
lidar_bp = world.get_blueprint_library().find('sensor.lidar.ray_cast')
lidar_location = carla.Location(0,0,2.4)
lidar_rotation = carla.Rotation(0,0,0)
lidar_transform = carla.Transform(lidar_location,lidar_rotation)
lidar =world.spawn_actor(lidar_bp,lidar_transform,attach_to=vehicle, attachment_type=carla.AttachmentType.Rigid)
time.sleep(40)
vehicle.destroy()