camera_location.py程序说明
- 用于获取相机相对于ego_vehicle的位置,可在carla城市中绘制点位
- 关键参数:camera_height表示相机相对于ego_vehicle中心点的高度
camera_length表示相机相对于ego_vehicle中心点的纵向距离
- 由于相机需要保持横向中心位置,所以相机相对与ego-vehicle的横向距离为0,这里不在设置参数,默认为0
- 添加了键盘检测程序,可以更换观察ego_vehicl的角度,目前设置观察角度为五个,分别为前后左右及俯视,具体观察角度可在Camera_transform_list中更改,注意观察角度的的z设置为ego-vehicle到相机的中间位置,为camera_height的一半,可以减小观察视角畸形
- tab :更换观察角度
esc : 退出程序
效果图
程序
import time
import carla
import random
import keyboard
from pynput.keyboard import Key, Listener
global pressed
pressed = 'aaa'
client = carla.Client("127.0.0.1", 2000)
client.set_timeout(20.0)
world = client.get_world()
world = client.load_world('Town03')
class Actor:
def __init__(self,world,bp_name,location,rotation,options=None,attach_to=None):
self.bp_name = bp_name
self.world = world
self.blueprint = world.get_blueprint_library().find(bp_name)
if options is not None:
for key in options:
self.blueprint.set_attribute(key, options[key])
self.transform &#