目标

将carla中的OpenDrive地图(carla\Unreal\CarlaUE4\Content\Carla\Maps\OpenDrive)转换为Apollo中可识别的地图格式(bin与txt文件)

用到的软件

python的imap_box包、apollov5、unity、 SVL SIMULATOR

安装

Unity

  1. Download and Install Unity Hub(需要代理)

    • Ubuntu: You may need to allow the downloaded AppImage to be run as an executable

      • Right-click the AppImage
      • Select Properties
      • Go to the Permissions tab
      • Check Allow executing file as program
      • Alternatively, in the terminal run sudo chmod +x UnityHub.AppImage
  2. Download and Install Unity 2020.3.3f1 from the Unity Download Archive: (需要代理)

SVL SIMULATOR

安装文档地址:https://www.svlsimulator.com/docs/installation-guide/build-instructions/

  • Installing Git LFS top

    Make sure you have git-lfs installed before cloning the Simulator repository.

    • Instructions for installation are here
    • Verify installation
      • In a terminal enter git lfs install
      • Git LFS initialized. should print out
  • Building a standalone executable
    1. Clone simulator project from GitHub (open-source) release branch.

      • Open a terminal and navigate to where you want the Simulator to be downloaded to

        • If you want the Simulator in your Documents folder, use cd in the terminal so that the input for the terminal is similar to /Documents$
      • Open-source user: git clone https://github.com/lgsvl/simulator.git
      • Verify download
        • Above clone will create a Simulator folder
        • Open a File Explorer and navigate to where the Simulator folder is
        • Navigate to Simulator/Assets/Materials/EnvironmentMaterials/
        • There should be a EnvironmentDamageAlbedo.png in this folder
        • Open the image, it should look like the image below
        • If the image cannot be opened, Git LFS was not installed before cloning the repository
          • Install Git LFS following step 4
          • In a terminal, navigate to the Simulator folder so that the terminal is similar to /Simulator$
          • git lfs pull
          • Check the image again
    2. Note: Please checkout the "release-*" branches or release tags for stable (ready features) and "master" branch for unstable (preview of work in progress).

    3. Run Unity Hub

    4. In the Projects tab, click Add and select the Simulator folder that was created by git clone in Step 5

    5. In the Projects tab, verify that the Simulator is using Unity Version 2020.3.3f1 from the dropdown

    6. Double-click the name of the project to launch Unity Editor

    7. Note: On Ubuntu 18.04, create an empty sample project before adding an existing project as mentioned in step 1.

    8. Open the Simulator menu from the top toolbar and select Build... to open the build window (shown below with a red outline)

    9. Select the target OS for the build using the Executable Platform dropdown menu

    10. Verify Build Simulator is checked for the Simulator to be built

    11. Select a folder that the simulator will be built in

    12. (Optional) Check Development Build to create a Development Build that includes debug symbols and enables the Profiler

    13. Click Build

      Once the build process is complete a simulator executable will be available at the specified location.

imap_box

imap_box包用于读取转换出来的bin文件,导出txt文件,git地址:https://github.com/daohu527/imap

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple  imap_box

在windows中安装时要使用powershell命令行安装,否则会报错

使用

将carla地图导出apollo的bin文件

  • 点击上方simulator-> Import HD Map,在弹出的HD Map Import中Import 选择carla地图路径,导入地图(这里以carla\Unreal\CarlaUE4\Content\Carla\Maps\OpenDrive\Town01.xodr为例)

    [图片]
  • 单击左边界面中新出现的MapOrigin,在右边出现的设置中,将Origin Easting设置为0,Origin Northing设置为0

  • 鼠标左键按住MapTown01,将其拖拽到MapOrigin上,成为其子节点。拖拽后点击MapTown01,将右边属性中的Rotation->Y设置为0

  • 选择simulator->Build HD Map Mesh, 在弹出的HD Map Mesh Builder中点击Build Mesh

  • 选择simulator->Export HD Map, 在弹出的HD Map Export中选择Apollo 5 HD Map格式,选择路径后点击Export,成功时可以看到左下界面提示(Carla地图1-10中,只有Town03没有导出成功)

使用imap_box包从bin文件导出txt文件

  • 创建新的工程,python环境选择的是python3.9.12(理论上3.6以上都可以).
  • 创建文件convert_bin_to_txt.py文件,内容为
from modules.map.proto import map_pb2

from imap.lib.proto_utils import get_pb_from_bin_file
from imap.lib.proto_utils import write_pb_to_text_file def convert_bin_to_txt(input_file: str):
map = map_pb2.Map()
pb = get_pb_from_bin_file(filename=input_file, pb_value=map)
write_pb_to_text_file(pb, input_file.split('.')[0]) if __name__ == '__main__':
convert_bin_to_txt(r"D:\tmp\base_map.bin")
  • 执行convert_bin_to_txt.py, 查看到D:\tmp下会出现base_map.txt。里面有可读的地图信息

生成sim_map与routing_map

将base_map.bin拷贝到安装了apollov5的容器内,在 /apollo/modules/map/data内创建新的文件夹,并将base_map.bin移动到新创建的文件夹中;然后运行脚本生成文件

# 将文件拷贝到docker容器的/apollo目录下
docker cp base_map.bin apollo_dev_ubuntu:/apollo
# 进入docker容器
/apollo/docker/scripts/dev_into.sh
# 创建文件夹
mkdir /apollo/modules/map/data/town01_example
# 移动文件
mv /apollo/base_map.bin /apollo/modules/map/data/town01_example/
# 执行脚本生成文件
/apollo/scripts/generate_maps.sh /apollo/modules/map/data/town01_example/

最后一步时执行会有两处报错,那是通过xml生成bin和txt的脚本命令,不影响直接用bin生成sim_map与routing_map

ubuntu@in_dev_docker:/apollo$ /apollo/scripts/generate_maps.sh /apollo/modules/map/data/town01_example/
I0906 10:10:26.932503 2935423 topo_creator.cc:32] [routing] Conf file: /apollo/modules/routing/conf/routing_config.pb.txt is loaded.
I0906 10:10:26.941069 2935423 graph_creator.cc:78] [routing] Number of lanes: 124
I0906 10:10:26.942127 2935423 graph_creator.cc:111] [routing] Current lane id: lane_0
.....
.....
I0906 10:10:26.983175 2935423 graph_creator.cc:158] [routing] Txt file is dumped successfully. Path: /apollo/modules/map/data/town01_example//routing_map.txt
I0906 10:10:26.984313 2935423 graph_creator.cc:163] [routing] Bin file is dumped successfully. Path: /apollo/modules/map/data/town01_example//routing_map.bin
I0906 10:10:26.984656 2935423 topo_creator.cc:40] [routing] Create routing topo successfully from /apollo/modules/map/data/town01_example//base_map.bin to /apollo/modules/map/data/town01_example//routing_map.bin
I0906 10:10:27.100512 2935439 sim_map_generator.cc:86] [] Downsampling lane lane_0
I0906 10:10:27.100884 2935439 sim_map_generator.cc:74] [] Lane curve downsampled from 8 points to 2 points
I0906 10:10:27.100904 2935439 sim_map_generator.cc:74] [] Lane curve downsampled from 8 points to 2 points
I0906 10:10:27.100915 2935439 sim_map_generator.cc:74] [] Lane curve downsampled from 8 points to 2 points
.....
.....
I0906 10:10:27.112815 2935439 sim_map_generator.cc:74] [] Lane curve downsampled from 5 points to 2 points.
I0906 10:10:27.164212 2935439 sim_map_generator.cc:122] [] sim_map generated at:/apollo/modules/map/data/town01_example/
# 下面的报错并不影响
E0906 10:10:27.247184 2935455 opendrive_adapter.cc:33] [] fail to load file /apollo/modules/map/data/town01_example//base_map.xml
F0906 10:10:27.247690 2935455 proto_map_generator.cc:39] Check failed: apollo::hdmap::adapter::OpendriveAdapter::LoadData(map_filename, &pb_map) fail to load data from : /apollo/modules/map/data/town01_example//base_map.xml
*** Check failure stack trace: ***
@ 0x7fb3a918aec0 google::LogMessage::Fail()
@ 0x7fb3a918ae07 google::LogMessage::SendToLog()
@ 0x7fb3a918a7de google::LogMessage::Flush()
@ 0x7fb3a918d83b google::LogMessageFatal::~LogMessageFatal()
@ 0x45d1a9 main
@ 0x7fb3a6b09f45 __libc_start_main
@ 0x45cf89 (unknown)
/apollo/scripts/generate_maps.sh: line 8: 2935455 Aborted (core dumped) bazel-bin/modules/map/tools/proto_map_generator --map_dir=$1 --output_dir=$1
E0906 10:10:28.046296 2935471 file.cc:73] [] Failed to open file /apollo/modules/map/data/town01_example//base_map.txt in text mode.
E0906 10:10:28.051890 2935471 file.cc:99] [] Failed to open file /apollo/modules/map/data/town01_example//base_map.txt in binary mode.
F0906 10:10:28.051970 2935471 bin_map_generator.cc:38] Check failed: apollo::cyber::common::GetProtoFromFile(map_filename, &pb_map) fail to load data from : /apollo/modules/map/data/town01_example//base_map.txt
*** Check failure stack trace: ***
@ 0x7f1fed03fec0 google::LogMessage::Fail()
@ 0x7f1fed03fe07 google::LogMessage::SendToLog()
@ 0x7f1fed03f7de google::LogMessage::Flush()
@ 0x7f1fed04283b google::LogMessageFatal::~LogMessageFatal()
@ 0x45bd29 main
@ 0x7f1fea9bef45 __libc_start_main
@ 0x45bb09 (unknown)
/apollo/scripts/generate_maps.sh: line 9: 2935471 Aborted (core dumped) bazel-bin/modules/map/tools/bin_map_generator --map_dir=$1 --output_dir=$1

查看生成的文件

ubuntu@in_dev_docker:/apollo$ ls /apollo/modules/map/data/town01_example/
base_map.bin routing_map.bin routing_map.txt sim_map.bin sim_map.txt

其他

使用SVL SIMULATOR而放弃RoadRunner的原因

在使用SVL SIMULATOR前首先调研的是使用RoadRunner导出地图。使用过程中遇到的主要问题有:

  • 地图中心点的设置问题

    在设置SVL SIMULATOR与RoadRunner中都有MapOrigin设置的能力,但是RoadRunner中将MapOrigin设置为0后,导出的文件坐标依然不是以地图中心为原点的坐标系,这样就需要将MapOrigin中的参数设置为负数来抵消坐标系带来的影响,这需要反复试验
  • 红绿灯和停止线的问题

    在生成的场景中,能够看到场景中的红绿灯高度不足,停止线缺失的现象,需要手动进行调整
  • 红绿灯id不对应问题

    生成的txt文件中可以看出,生成的信号灯的id并不能与carla中的灯的id对应上,这样就无法用carla进行模拟

    结论:

    RoadRunner可以在自定义场景时使用,如果想将已经完成的地图转换成apollo地图,考虑SVL SIMULATOR更合适一些

高清地图转换(xord转apollo的bin文件)的更多相关文章

  1. python爬虫王者荣耀高清皮肤大图背景故事通用爬虫

    wzry-spider python通用爬虫-通用爬虫爬取静态网页,面向小白 基本上纯python语法切片索引,少用到第三方爬虫网络库 这是一只小巧方便,强大的爬虫,由python编写 主要实现了: ...

  2. Cocos2D瓦块地图高清屏(retina)显示比例问题的解决

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 在Cocos2D的游戏编程里,常用到瓦块地图.而cocos2D ...

  3. 广州高清卫星地图 用百度卫星地图server下载 含标签、道路数据叠加 可商用

    广州高清卫星地图的地图展示图片各自是15级别.17级别.19级别的地图.一般来说17级别的地图图片就行用于商用.地图包包括一整张高级别的图片,如要全图浏览请用专业图片处理软件PS等打开. 一般来说互联 ...

  4. java 库 pdfbox 将 pdf 文件转换成高清图片方法

    近期需要将 pdf 文件转成高清图片,使用库是 pdfbox.fontbox.可以使用 renderImageWithDPI 方法指定转换的清晰度,当然清晰度越高,转换需要的时间越长,转换出来的图片越 ...

  5. 【Apollo自动驾驶源码解读】车道线的感知和高精地图融合

    模式选择 在modules/map/relative_map/conf/relative_map_config.pb.txt文件中对模式进行修改: lane_source: OFFLINE_GENER ...

  6. 移动端H5页面高清多屏适配方案

    背景 开发移动端H5页面 面对不同分辨率的手机 面对不同屏幕尺寸的手机 视觉稿 在前端开发之前,视觉MM会给我们一个psd文件,称之为视觉稿. 对于移动端开发而言,为了做到页面高清的效果,视觉稿的规范 ...

  7. Hawk: 无编程抓取淘女郎的所有高清照片

    1.这是什么鬼? 哦?美女? 最近看了这一篇文章:http://cuiqingcai.com/1001.html 大概说的是用Python和Pyspider(这货好像是我的一位师兄写的,吓尿),抓取淘 ...

  8. Android 高清加载巨图方案 拒绝压缩图片

    Android 高清加载巨图方案 拒绝压缩图片 转载请标明出处: http://blog.csdn.net/lmj623565791/article/details/49300989: 本文出自:[张 ...

  9. webapp:移动端高清、多屏适配方案(zz)

    来源: http://sentsin.com/web/1212.html 移动端高清.多屏适配方案 背景 开发移动端H5页面 面对不同分辨率的手机 面对不同屏幕尺寸的手机 视觉稿 在前端开发之前,视觉 ...

随机推荐

  1. 使用aggregation API扩展你的kubernetes API

    Overview What is Kubernetes aggregation Kubernetes apiserver aggregation AA 是Kubernetes提供的一种扩展API的方法 ...

  2. Spring Data JPA系列3:JPA项目中核心场景与进阶用法介绍

    大家好,又见面了. 到这里呢,已经是本SpringData JPA系列文档的第三篇了,先来回顾下前面两篇: 在第1篇<Spring Data JPA系列1:JDBC.ORM.JPA.Spring ...

  3. UiPathExcel写入操作

    一.Excel 写操作 1.写一个单元格 (1)控件介绍 Write Cell: 使用Write Cell控件,在指定单元格写入内容     常用属性介绍: Destination: Cell: 要写 ...

  4. bat-windows系统激活

    激活命令 slmgr -ipk M7XTQ-FN8P6-TTKYV-9D4CC-J462D slmgr -skms kms.03k.org slmgr -ato slmgr -dlv 激活异常处理方法 ...

  5. 单片机 MCU 固件打包脚本软件

    ​ 1 前言 开发完 MCU 软件后,通常都会生成 hex 文件或者 bin 文件,用来做固件烧录或者升级,如果用来做产品开发,就涉及到固件版本的问题,初学者通常采用固件文件重命名来区分版本. 如果需 ...

  6. 深入理解Apache Hudi异步索引机制

    在我们之前的文章中,我们讨论了多模式索引的设计,这是一种用于Lakehouse架构的无服务器和高性能索引子系统,以提高查询和写入性能.在这篇博客中,我们讨论了构建如此强大的索引所需的机制,异步索引机制 ...

  7. 002 Redis使用及API

    Redis的使用及相关API 1.作用: 提高查询效率 一定程度上可以减轻数据库服务器的冲击压力,从而保护了数据库 //1.是否包含key redisTemplate.hasKey(key) //2. ...

  8. 二叉排序树的合并(严3.98)--------西工大noj

    二叉排序树的合并有三种方法 先存入数组,然后..... 直接在第二个树上添加第一个数的元素,时间复杂度为O(NlogN) 就像是合并数组一样合并二叉排序树,分别扫描,时间复杂度极低. 第三种我写了一下 ...

  9. 6.4.2 用BFS求最短路

    前面的篇幅占了太多,再次新开一章,讲述BFS求最短路的问题 注意此时DFS就没有BFS好用了,因为DFS更适合求全部解,而BFS适合求最优解 这边再次提醒拓扑变换的思想在图形辨认中的重要作用,需要找寻 ...

  10. 别再用 System.currentTimeMillis 统计耗时了,太 Low,试试 Spring Boot 源码在用的 StopWatch吧,够优雅!

    大家好,我是二哥呀! 昨天,一位球友问我能不能给他解释一下 @SpringBootApplication 注解是什么意思,还有 Spring Boot 的运行原理,于是我就带着他扒拉了一下这个注解的源 ...