版权声明:本文为博主原创文章,遵循Creative Commons — Attribution-ShareAlike 4.0 International — CC BY-SA 4.0版权协议,转载请附上原文出处链接和本声明。

本文链接:AirSim学习和踩坑记录(不定时更新)_Duge1024的博客-CSDN博客_airsim


目录

1. AirSim官方介绍

2. AirSim的安装及使用

3. 问题汇总

3.1 如何使用AirSim提供的城市地图?

3.2 运行官方PythonCline中的demo出现TypeError:unsupported oprand type(s) for *: 'AsyncIOLoop' and 'float'

3.3 运行虚幻引擎出现Error: CDO Constructor (PIPCamera): Failed to find Material '/AirSim/HUDAssets/CameraDistortion.CameraDistortion'

3.4 Record无法保存未压缩的图片

3.5 Landscape Mountains环境中没有输电线(用于UAV强化学习)

3.6 获取深度图并生成点云图


1. AirSim官方介绍

Github: https://github.com/microsoft/AirSim

详细文档:Home - AirSim

论文地址:https://arxiv.org/abs/1705.05065


AirSim is a simulator for drones, cars and more, built on Unreal Engine (we now also have an experimental Unity release). It is open-source, cross platform, and supports software-in-the-loop simulation with popular flight controllers such as PX4 & ArduPilot and hardware-in-loop with PX4 for physically and visually realistic simulations. It is developed as an Unreal plugin that can simply be dropped into any Unreal environment. Similarly, we have an experimental release for a Unity plugin.

Our goal is to develop AirSim as a platform for AI research to experiment with deep learning, computer vision and reinforcement learning algorithms for autonomous vehicles. For this purpose, AirSim also exposes APIs to retrieve data and control vehicles in a platform independent way.


AirSim是一款基于虚幻引擎的无人机、汽车等模拟器。 它是开源和跨平台的,并支持在环软件仿真中使用流行的飞行控制器,例如PX4和ArduPilot,也可通过PX4进行硬件在环仿真,以进行物理和视觉逼真的仿真。 AirSim是作为虚幻引擎插件开发的,可以直接放入任何Unreal环境中。 同样,我们有一个Unity插件的实验版本。我们的目标是将AirSim开发为AI研究的平台,以对自动驾驶汽车的深度学习,计算机视觉和强化学习算法进行实验。 为此,AirSim还公开API以平台无关的方式检索数据和控制车辆。

无人机仿真

小车仿真

2. AirSim的安装及使用

网上已经有很多教程,安利一波专栏:airsim & unreal 仿真平台 - 知乎,截止2021/7/8作者已经更新13个系列,目前仍在持续更新。

3. 问题汇总

3.1 如何使用AirSim提供的城市地图?

1) City场景截图:

2)下载地址:https://github.com/microsoft/AirSim/releases,查找对应系统和版本的Assets,如下图:

3)下载City.zip.001和City.zip.002并解压,如下图:

4)点击CityEnviron.exe直接运行仿真环境,仿真模式以及其他配置信息则自己根据需要在settings.josn文件中修改(路径:C:\Users\用户名\Documents\AirSim\settings.json),如下图:

5) 同理,我们也可以尝试其他封装好的环境,官方还提供了室内(Building_99.zip)、海岸线(Coastline.zip.001-002)、山脉(LandscapeMountains.zip)、球场(Soccer_Field.zip)等场景。但目前这些场景无法用UE4再次编辑(如果有人知道如何操作,欢迎留言)。

3.2 运行官方PythonCline中的demo出现TypeError:unsupported oprand type(s) for *: 'AsyncIOLoop' and 'float'

查看错误提示,发现是msgpackrpc调用出错,解决方法:重新安装包:

pip install msgpack-rpc-python
pip install airsim

3.3 运行虚幻引擎出现Error: CDO Constructor (PIPCamera): Failed to find Material '/AirSim/HUDAssets/CameraDistortion.CameraDistortion'

issues:3238 

我用的版本为4.24.3,issue中提供的解决方法为将UE4升级到最新版本(4.25)。

3.4 Record无法保存未压缩的图片

issues:3214

3.5 Landscape Mountains环境中没有输电线(用于UAV强化学习)

官方提供的PythonClient中有关于强化学习的demo,无人机的任务的跟踪电线移动的尽可能远,但v1.3.1 - Windows中提供的地图并没有电线。

解决方法:使用1.2版本中的Landscape Mountains environment,同时需要注意1.2版本后添加的API将无法调用。

issues:3292

3.6 获取深度图并生成点云图

深度图包含以下三种格式:

1) DepthVis深度图将每个像素值从黑色插值为白色,纯白色像素表示深度为100米或以上,纯黑色像素表示深度为0米;

2) DepthPerspective深度图根据离相机的距离计算深度;

3)DepthPlanner深度图摄影机平面平行的所有点具有相同的深度。

通过下面的函数可以获得三种格式的深度图(ImageRequest中的第一个参数需要根据自己的相机名字修改):

def save_depth_image(client):depth1_filename = "./DepthPlanner.png"depth2_filename = "./DepthVis.png"depth3_filename = "./Perspective.png"responses = client.simGetImages([airsim.ImageRequest("bottom", airsim.ImageType.DepthPlanner, False, False),airsim.ImageRequest("bottom", airsim.ImageType.DepthVis, False, False),airsim.ImageRequest("bottom", airsim.ImageType.Perspective, False, False)]) img1d = np.frombuffer(responses[0].image_data_uint8, dtype=np.uint8)img_rgb = img1d.reshape(responses[0].height, responses[0].width, 3)cv2.imwrite(os.path.normpath(depth1_filename), img_rgb)img1d = np.frombuffer(responses[1].image_data_uint8, dtype=np.uint8)img_rgb = img1d.reshape(responses[1].height, responses[1].width, 3)cv2.imwrite(os.path.normpath(depth2_filename), img_rgb)img1d = np.frombuffer(responses[2].image_data_uint8, dtype=np.uint8)img_rgb = img1d.reshape(responses[2].height, responses[2].width, 3)cv2.imwrite(os.path.normpath(depth3_filename), img_rgb)

原图

DepthPlanner深度图​​​​

通过下面的代码将深度图转化为点云文件cloud.asc:

代码参考issues:3316

def save_point_cloud(image, fileName):color = (0, 255, 0)rgb = "%d %d %d" % colorf = open(fileName, "w")for x in range(image.shape[0]):for y in range(image.shape[1]):pt = image[x, y]if math.isinf(pt[0]) or math.isnan(pt[0]) or pt[0] > 10000 or pt[1] > 10000 or pt[2] > 10000:# skip itNoneelse:f.write("%f %f %f %s\n" % (pt[0], pt[1], pt[2] - 1, rgb))f.close()def depth_conversion(point_depth, f):height = point_depth.shape[0]width = point_depth.shape[1]i_c = float(height) / 2 - 1j_c = float(width) / 2 - 1columns, rows = np.meshgrid(np.linspace(0, width - 1, num=width), np.linspace(0, height - 1, num=height))distance_from_center = ((rows - i_c) ** 2 + (columns - j_c) ** 2) ** 0.5point_depth = point_depth / (1 + (distance_from_center / f) ** 2) ** 0.5return point_depthdef generate_point_cloud(depth, Fx, Fy, Cx, Cy):rows, cols = depth.shapec, r = np.meshgrid(np.arange(cols), np.arange(rows), sparse=True)valid = (depth > 0) & (depth < 255)z = 1000 * np.where(valid, depth / 256.0, np.nan)x = np.where(valid, z * (c - Cx) / Fx, 0)y = np.where(valid, z * (r - Cy) / Fy, 0)return np.dstack((x, y, z))def main():source = "./DepthPerspective.png"output_file = "cloud.asc"width = 256  height = 144camera_fov = 90Fx = Fy = width / (2 * math.tan(camera_fov * math.pi / 360))depth_map = Image.open(source).convert('L') img1d = np.array(depth_map, dtype=np.float)img1d[img1d > 255] = 255img2d = np.reshape(img1d, (depth_map.height, depth_map.width))# 如果depth_map是DepthPerspective格式则需要先用depth_conversion函数转化成DepthPlanner格式,是DepthPlanner格式则不需要img2d_converted = depth_conversion(img2d, Fx)  pcl = generate_point_cloud(img2d_converted, Fx, Fy, Cx, Cy)# pcl = generate_point_cloud(img2d, Fx, Fy, Cx, Cy)save_point_cloud(pcl, output_file)sys.exit(0)if __name__ == "__main__":main()

用CloudCompare软件可以查看生成的点云图:

AirSim学习和踩坑记录(不定时更新)相关推荐

  1. Laya小游戏上架Vivo平台踩坑记录(持续更新)

    Laya小游戏上架Vivo平台踩坑记录(持续更新) 个人踩坑的一些记录,大佬留情! 一些快捷键: Ctrl+P 搜索脚本文件 Ctrl+Y 恢复操作 Ctrl+Z 撤回操作 Ctrl+F 搜索字段 C ...

  2. Laya小游戏上架Oppo平台踩坑记录(持续更新)

    Laya小游戏上架Oppo平台踩坑记录(持续更新) 个人踩坑的一些记录,大佬留情! 一些快捷键: Ctrl+P 搜索脚本文件 Ctrl+Y 恢复操作 Ctrl+Z 撤回操作 Ctrl+F 搜索字段 C ...

  3. mybatis学习与踩坑记录

    mybatis resultmap高级映射 应用场景:如果sql查询的列名和pojo的属性名不一致,可以使用resultMap将列名和pojo的属性名作一个对应关系,就可以映射成功了.(如果返回值为i ...

  4. python打包exe之打包深度学习模型踩坑记录及其解决办法。

    在现实生活中,有时候我们写的程序需要发给小伙伴用,而小伙伴没有python,这时候我们需要将程序打包成exe文件发给小伙伴用. 今天讲下打包深度学习模型 打包一般要用到cmd命令行,要求cmd能执行p ...

  5. AffordaceNet属性学习网络踩坑记录(二)

    1.在编译代码网络下的caffe时,要注意是在root权限还是用户权限下,需要在同一权限下执行caffe编译和训练网络.推荐在root目录下执行 2.在运行测试网络时,使用的python路径为代码路径 ...

  6. yolov5 训练时报错踩坑(不定时更新)

    yolov5运行train.py 问题描述 问题:TypeError: bad operand type for unary -: 'list' 解决方案: 将[384,384]列表改成单一数值即可, ...

  7. flutter boost使用简介(踩坑记录,持续更新)

    前言 最近在研究android和flutter的混合开发.插件模式调用原生的混合模式已经在项目中使用,也暴露出一些问题, 最突出的问题就是flutter中对webview的支持,会出现各种各样奇怪的问 ...

  8. 西柚的大数据从踩坑到放弃-zookeeper:四、一些ZK的踩坑记录

    zookeeper踩坑记录 后续不断更新,希望能多积累一点以后方便自己维护的时候查询吧 Java api不能创建zk客户端,屏幕log提示超时,并伴随典型报错KeeperErrorCode = Con ...

  9. 【学习记录】QT5界面设计的踩坑记录

    学习记录:QT5 界面设计的踩坑记录 前言 一.Qlabel显示视频与图片 1. 图片显示 1.1 显示格式 1.2 label随界面缩放 1.3 界面刷新 2. 视频显示 二.常见控件的StyleS ...

最新文章

  1. Python 基础语法(四)
  2. Android-源码剖析CountDownTimer(倒计时类)
  3. 将图片处理成圆形_如何把图片批量处理成指定/固定的文件大小/体积以内?
  4. C# 利用系统剪贴板 保存 自定义对象
  5. 客官,.NETCore无代码侵入的模型验证了解下
  6. 【双指针】Square Pasture G(P7153)
  7. 使用sklearn优雅地进行数据挖掘
  8. android pdf重排软件,PDF拆分重排(paper for kindle)
  9. javascript中的isNaN()
  10. linux运维好书《高性能Linux服务器构建实战Ⅱ》已出版发售,附封面照!
  11. Tushare的安装及使用介绍
  12. PMP练习199题答案解析版
  13. LibEvent中文帮助文档
  14. js怎么识别图片中的文字,js图片文字识别代码
  15. 7-7 浪漫的表白 (10 分) 计算生日差据天数
  16. 阿里云香港服务器带宽太贵怎么办?香港节点全球CDN加速你值得拥有
  17. Tesla M40 下Ubuntu anaconda pycharm pytorch安装
  18. 深度学习--滑动平均模型
  19. cpplint中filter参数的每个可选项的含义
  20. Windows系统下CMD命令

热门文章

  1. cesium--绘制多边形polygon
  2. 手把手教你写保研简历|计算机保研|保研夏令营文书写作|简历模板
  3. 【极简教程】Linux Shell 脚本编程
  4. 【Gas优化】GasChecker
  5. Excel怎么批量设置行高
  6. ubuntu20.04如何录制屏幕
  7. 房屋装修选择自装,如何寻找砌墙工人,比价并施工(砌墙阶段)
  8. QPSK调制解调仿真matlab
  9. U-Net: Convolutional Networks for Biomedical Image Segmentation 解析
  10. JSON解析基础使用知识-Java