首页 > 其他分享 >高清地图转换(xord转apollo的bin文件)

高清地图转换(xord转apollo的bin文件)

时间:2022-09-06 10:58:16浏览次数:87  
标签:bin map 10 modules xord apollo data

目标

将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更合适一些

标签:bin,map,10,modules,xord,apollo,data
From: https://www.cnblogs.com/luslin/p/16660988.html

相关文章

  • Binding的使用
    在build.gradle中加入android{ viewBinding{enabled=true}}在对应Activity如下定义(e.g.MainActivity)privateActivityMainBindingbinding......
  • leetcode 104. Maximum Depth of Binary Tree 二叉树的最大深度(简单)
    一、题目大意给定一个二叉树,找出其最大深度。二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。说明:叶子节点是指没有子节点的节点。示例:给定二叉树[3,9,......
  • linux下开启mysql的binlog
    一、场景mysql数据库的备份、恢复需要用到binlog二、操作步骤1、查看binlog是否开启,为off则未开启  2、找到cnf文件,一般在/etc/目录下面,并且做好备份   ......
  • Pybind11 揭秘。 Ch 4.1:仅位置参数
    Pybind11揭秘。Ch4.1:仅位置参数Python不支持C++中的函数重载(具有相同函数名称的不同函数签名)。尽管如此,Python确实提供了一组少数语法,包括默认值和kwargs,以允许根......
  • 1530 bingo 不是题解
    *2600的死活卡住出不来,想啊,很想啊(指remake21*21的方阵,每个位置有一个概率是1,求凑出来bingo的概率这种题目先考虑容斥,那就是1-凑不出bingo的概率。直接做是2^44的,我做牛......
  • CentOS-6.5-x86_64-bin-DVD1.iso 下载
    CentOS-6.5-x86_64-bin-DVD1.iso下载_gz153016的博客-CSDN博客_centos-6.5-i386-bin-dvd1.iso https://blog.csdn.net/gz153016/article/details/50557077 ......
  • call、apply、bind三者的用法和区别
    call、apply、bind三者的用法和区别call非严格模式如果不传参数,或者第一个参数是null或nudefined,this都指向window严格模式第一个参数是谁,this就指向谁,包括null和unde......
  • 9am 个人智能电动升降桌 Robin Pro 使用体验和评测 All In One
    9am个人智能电动升降桌RobinPro使用体验和评测AllInOne9am智能电动升降桌米家版RobinPro办公桌工作台电脑桌电竞桌白色桌面+白色桌腿1600*700mmhttps://ite......
  • nested exception is org.apache.ibatis.binding
    Mybatis传list参数出现nestedexceptionisorg.apache.ibatis.binding.BindingException:Parameter‘xxx’notfound.一、问题描述:nestedexceptionisorg.apac......
  • 105.construct-binary-tree-from-preorder-and-inorder-traversal 从前序与中序遍历序
    原理参照从中序与后序遍历序列构造二叉树,这里直接给出基于vector索引优化之后的版本:classSolution{private:TreeNode*get_root(vector<int>&preorder,intpr......