当前位置: 首页 > news >正文

建站一条龙网站开发概要设计书模板

建站一条龙,网站开发概要设计书模板,网站建设者属于广告经营者吗,宝安沙井房价CARLA的使用逻辑#xff1a; 首先创建客户端 设置如果2秒没有从服务器返回任何内容#xff0c;则终止 client carla.Client(127.0.0.1, 2000) client.set_timeout(2.0) 从客户端中get world world client.get_world() 设置setting并应用 这里使用固定时…CARLA的使用逻辑 首先创建客户端 设置如果2秒没有从服务器返回任何内容则终止 client carla.Client(127.0.0.1, 2000) client.set_timeout(2.0) 从客户端中get world world client.get_world() 设置setting并应用 这里使用固定时间步长的异步模式 settings world.get_settings() settings.synchronous_mode False # Enables synchronous mode settings.fixed_delta_seconds None delta 0.05 settings.fixed_delta_seconds delta world.apply_settings(settings)设置traffic manager traffic_manager client.get_trafficmanager(8000) traffic_manager.set_synchronous_mode(False) traffic_manager.set_random_device_seed(0) random.seed(0) 创建一个观察视角 spectator是我们观察的视角在后面的循环中我们让视角始终跟随车显示从上往下看的车的俯视图 spectator world.get_spectator() 从map中获得所有可行的出生点 spawn_points是所有可行的出生点在后面生成车的时候要指定一个出生点。 spawn_points world.get_map().get_spawn_points() carla中添加任何东西车辆相机激光雷达等的逻辑是 以车为例添加车的逻辑是先从world中get所有东西的blueprint库从所有blueprint库中filter车的blueprint再将车的blueprint与出生点结合生成一个车。 blueprint_library world.get_blueprint_library() vehicle_bp blueprint_library.filter(model3)[0] vehicle world.try_spawn_actor(vehicle_bp, spawn_points[0]) blueprint_library是所有blueprint的库vehicle_bp是车的blueprint与一个出生点结合生成车的实例vehicle。 相机也是同样的逻辑 camera_init_trans carla.Transform(carla.Location(x1, y-1, z2), carla.Rotation(pitch0)) camera_bp blueprint_library.find(sensor.camera.rgb) camera_bp.set_attribute(image_size_x, str(1280)) camera_bp.set_attribute(image_size_y, str(720)) camera_bp.set_attribute(fov, str(105)) camera world.spawn_actor(camera_bp, camera_init_trans, attach_tovehicle) 相机要设置附着在车上面carla.Location是固定在车身的随车坐标系原点的高度在车轮与地面接触的平面俯视图看原点在车的中心。x轴正方向指向车头y轴指向车辆右舷z轴指向天空单位是米。 相机监听回调函数 # Get camera dimensions image_w camera_bp.get_attribute(image_size_x).as_int() image_h camera_bp.get_attribute(image_size_y).as_int()# Instantiate objects for rendering and vehicle control renderObject RenderObject(image_w, image_h) controlObject ControlObject(vehicle)camera.listen(lambda image: pygame_callback1(image, renderObject)) carla中没有双目相机需要自己添加两个rgb相机实现双目相机的效果。 如何理解CARLA中相机的焦距的概念 定义相机的时候没有焦距这个概念首先定义窗口的大小也就是相当于相机的传感器横竖各有多少像素再定义fov视角范围单位是度定义好这两个概念相机的焦距f根据这两个数来算如果双目相机恢复深度需要这样去算f。假如相机的归一化平面即距离相机z1米的位置这个z是slam相机坐标系不是carla坐标系有一根横棒那么多长的横棒可以正好横向填满相机传感器根据视角范围fov解相似三角形求出slam中定义的相机内参概念f窗口大小的一般也就是slam中相机内参的c 键盘控制器 见完整代码 ControlObject类 每一步循环中 world.tick() # 获取服务器结果 # 获取观察视角 transform vehicle.get_transform() # we get the transform of vehicle spectator.set_transform(carla.Transform(transform.location carla.Location(z50),carla.Rotation(pitch-90)))for event in pygame.event.get(): # 获取键盘操作 完整代码 import carla import random import time import sys import pygame import datetime import numpy as np import open3d as o3d from matplotlib import cmVIDIDIS np.array(cm.get_cmap(plasma).colors) VID_RANGE np.linspace(0.0, 1.0, VIDIDIS.shape[0])# Render object to keep and pass the PyGame surface class RenderObject(object):def __init__(self, width, height):init_image np.random.randint(0,255,(height, width, 3),dtypeuint8)self.surface pygame.surfarray.make_surface(init_image.swapaxes(0,1))# Control object to manage vehicle controls class ControlObject(object):def __init__(self, veh):# Conrol parameters to store the control stateself._vehicle vehself._steer 0self._throttle Falseself._brake Falseself._steer Noneself._steer_cache 0# A carla.VehicleControl object is needed to alter the# vehicles control stateself._control carla.VehicleControl()# Check for key press events in the PyGame window# and define the control statedef parse_control(self, event):if event.type pygame.KEYDOWN:if event.key pygame.K_RETURN:self._vehicle.set_autopilot(True)if event.key pygame.K_UP:self._throttle Trueif event.key pygame.K_DOWN:self._brake Trueif event.key pygame.K_RIGHT:self._steer 1if event.key pygame.K_LEFT:self._steer -1if event.type pygame.KEYUP:if event.key pygame.K_UP:self._throttle Falseif event.key pygame.K_DOWN:self._brake Falseself._control.reverse Falseif event.key pygame.K_RIGHT:self._steer Noneif event.key pygame.K_LEFT:self._steer None# Process the current control state, change the control parameter# if the key remains presseddef process_control(self):if self._throttle:self._control.throttle min(self._control.throttle 0.01, 1)self._control.gear 1self._control.brake Falseelif not self._brake:self._control.throttle 0.0if self._brake:# If the down arrow is held down when the car is stationary, switch to reverseif self._vehicle.get_velocity().length() 0.01 and not self._control.reverse:self._control.brake 0.0self._control.gear 1self._control.reverse Trueself._control.throttle min(self._control.throttle 0.1, 1)elif self._control.reverse:self._control.throttle min(self._control.throttle 0.1, 1)else:self._control.throttle 0.0self._control.brake min(self._control.brake 0.3, 1)else:self._control.brake 0.0if self._steer is not None:if self._steer 1:self._steer_cache 0.03if self._steer -1:self._steer_cache - 0.03min(0.7, max(-0.7, self._steer_cache))self._control.steer round(self._steer_cache,1)else:if self._steer_cache 0.0:self._steer_cache * 0.2if self._steer_cache 0.0:self._steer_cache * 0.2if 0.01 self._steer_cache -0.01:self._steer_cache 0.0self._control.steer round(self._steer_cache,1)# Ápply the control parameters to the ego vehicleself._vehicle.apply_control(self._control)def generate_lidar_bp(blueprint_library, delta):To get lidar bp:param blueprint_library: the world blueprint_library:param delta: update rate(s):return: lidar bplidar_bp blueprint_library.find(sensor.lidar.ray_cast)lidar_bp.set_attribute(dropoff_general_rate, 0.0)lidar_bp.set_attribute(dropoff_intensity_limit, 1.0)lidar_bp.set_attribute(dropoff_zero_intensity, 0.0)lidar_bp.set_attribute(upper_fov, str(15.0))lidar_bp.set_attribute(lower_fov, str(-25.0))lidar_bp.set_attribute(channels, str(64.0))lidar_bp.set_attribute(range, str(100.0))lidar_bp.set_attribute(rotation_frequency, str(1.0 / delta))lidar_bp.set_attribute(points_per_second, str(500000))return lidar_bpdef lidar_callback(point_cloud, point_list):# We need to convert point cloud(carla-format) into numpy.ndarraydata np.copy(np.frombuffer(point_cloud.raw_data, dtype np.dtype(f4)))data np.reshape(data, (int(data.shape[0] / 4), 4))intensity data[:, -1]intensity_col 1.0 - np.log(intensity) / np.log(np.exp(-0.004 * 100))int_color np.c_[np.interp(intensity_col, VID_RANGE, VIDIDIS[:, 0]),np.interp(intensity_col, VID_RANGE, VIDIDIS[:, 1]),np.interp(intensity_col, VID_RANGE, VIDIDIS[:, 2])]points data[:, :-1] # we only use x, y, z coordinatespoints[:, 1] -points[:, 1] # This is different from official scriptpoint_list.points o3d.utility.Vector3dVector(points)point_list.colors o3d.utility.Vector3dVector(int_color)# Camera sensor callback, reshapes raw data from camera into 2D RGB and applies to PyGame surface def pygame_callback1(data, obj):img np.reshape(np.copy(data.raw_data), (data.height, data.width, 4))img img[:, :, :3]img img[:, :, ::-1]# msg bridge.cv2_to_imgmsg(img, encodingbgr8)obj.surface pygame.surfarray.make_surface(img.swapaxes(0, 1))# pub.publish(msg)print(taking photos1)def pygame_callback2(data, obj):img np.reshape(np.copy(data.raw_data), (data.height, data.width, 4))img img[:, :, :3]img img[:, :, ::-1]# msg bridge.cv2_to_imgmsg(img, encodingbgr8)# pub2.publish(msg)print(taking photos2)client carla.Client(127.0.0.1, 2000) client.set_timeout(2.0) world client.get_world()settings world.get_settings() settings.synchronous_mode False # Enables synchronous mode settings.fixed_delta_seconds None delta 0.05 settings.fixed_delta_seconds delta world.apply_settings(settings)traffic_manager client.get_trafficmanager(8000) traffic_manager.set_synchronous_mode(False) traffic_manager.set_random_device_seed(0) random.seed(0)# We will set up the spectator so we can see what we do spectator world.get_spectator() # Retrieve the maps spawn points spawn_points world.get_map().get_spawn_points()blueprint_library world.get_blueprint_library() vehicle_bp blueprint_library.filter(model3)[0] vehicle world.try_spawn_actor(vehicle_bp, spawn_points[0]) vehicle.set_autopilot(False)# Initialise the camera floating behind the vehicle camera_init_trans carla.Transform(carla.Location(x1, y-1, z2), carla.Rotation(pitch0)) camera_bp blueprint_library.find(sensor.camera.rgb) camera_bp.set_attribute(image_size_x, str(1280)) camera_bp.set_attribute(image_size_y, str(720)) camera_bp.set_attribute(fov, str(105)) camera world.spawn_actor(camera_bp, camera_init_trans, attach_tovehicle) # Start camera with PyGame callbackcamera2_init_trans carla.Transform(carla.Location(x1, y1, z2), carla.Rotation(pitch0)) camera2_bp blueprint_library.find(sensor.camera.rgb) camera2_bp.set_attribute(image_size_x, str(1280)) camera2_bp.set_attribute(image_size_y, str(720)) camera2_bp.set_attribute(fov, str(105)) camera2 world.spawn_actor(camera2_bp, camera2_init_trans, attach_tovehicle)# Get camera dimensions image_w camera_bp.get_attribute(image_size_x).as_int() image_h camera_bp.get_attribute(image_size_y).as_int()# Instantiate objects for rendering and vehicle control renderObject RenderObject(image_w, image_h) controlObject ControlObject(vehicle)camera.listen(lambda image: pygame_callback1(image, renderObject))lidar_bp generate_lidar_bp(blueprint_library, delta) lidar_transform carla.Transform(carla.Location(x-0.5, z1.8)) lidar world.spawn_actor(lidar_bp, lidar_transform, attach_tovehicle)point_list o3d.geometry.PointCloud()lidar.listen(lambda data: lidar_callback(data, point_list))vis o3d.visualization.Visualizer() vis.create_window(window_name Display Point Cloud,width 960,height 540,left 480,top 270)vis.get_render_option().background_color [0.05, 0.05, 0.05] vis.get_render_option().point_size 1 vis.get_render_option().show_coordinate_frame Trueframe 0 dt0 datetime.datetime.now()# Initialise the display pygame.init() gameDisplay pygame.display.set_mode((image_w,image_h), pygame.HWSURFACE | pygame.DOUBLEBUF) # Draw black to the display gameDisplay.fill((0,0,0)) gameDisplay.blit(renderObject.surface, (0,0)) pygame.display.flip()crashed False while not crashed:# if frame 2:# vis.add_geometry(point_list)## vis.update_geometry(point_list)# vis.poll_events()# vis.update_renderer()# time.sleep(0.005)world.tick()transform vehicle.get_transform() # we get the transform of vehiclespectator.set_transform(carla.Transform(transform.location carla.Location(z50),carla.Rotation(pitch-90)))# Update the displaygameDisplay.blit(renderObject.surface, (0, 0))pygame.display.flip()controlObject.process_control()for event in pygame.event.get():if event.type pygame.QUIT:crashed TruecontrolObject.parse_control(event)process_time datetime.datetime.now() - dt0sys.stdout.write(\r FPS: str(1.0 / process_time.total_seconds()) Current Frame: str(frame))sys.stdout.flush()dt0 datetime.datetime.now()frame 1# Stop camera and quit PyGame after exiting game loop camera.stop() camera2.stop() pygame.quit()这里有一个bug我的代码里分别有Lidar点云可视化的代码和相机照片可视化的代码可是这两个可视化不能共存如果Lidar的点云可视化更新相机图片可视化就不更新相机更新Lidar就不更新。不知道为什么知道的大神欢迎留言。
http://www.hkea.cn/news/14287595/

相关文章:

  • 怎样从用户体现提高网站的搜索引擎信任度在线查企业
  • 跟我学做纸艺花网站网站底部 设计
  • 虚拟主机管理怎么做网站网站内容维护有哪些方面
  • 周口学做网站购物网站开发 需求分析
  • 从做系统找不到以前的网站网站设计 论坛
  • 朔州怀仁网站建设wordpress国旗按钮
  • 网站上的图片带店面是怎么做的门户一号wordpress主题
  • 做神马网站优化排大连建设工程集团有限公司
  • 做图片可以卖给那些网站新手学做网站 下载
  • 网站推广方式的策划wordpress seo插件
  • 门户网站含义潍坊的网站建设
  • 北京常用网站网页设计作品田田田田田田田田田田田田田田
  • 中国门户网站建设重要性网站开发语言html5 php
  • 池州网站建设兼职微信官网登陆
  • 什么是网站改版做网站的为什么不给域名和密码
  • 运城做网站要多少钱本科电子商务专业就业方向
  • 网站开发哪家好网站建设项目验收付款
  • 微信自创小程序网站优化意见
  • 龙岩市官方网站服装公司网站首页
  • wordpress可以建立多个站点网站建站四种方案
  • 多少钱才算有钱人360优化大师官方下载
  • 怎样创建自己公司网站企业网站上的二维码怎么获得
  • 那个网站上有打码的任务做株洲网站建设兼职
  • 中山如何制作网站优设网字体
  • 南宁网站建设软件销售
  • 无锡装修公司哪家口碑最好重庆怎么站seo
  • 山东济南市网站建设中国网络营销网站
  • seo算法入门教程无线网络优化工程师
  • 网站不做icp备案网页设计与制作模板免费
  • 企业建站官网运营网络营销与网站推广的区别