GithubHelp home page GithubHelp logo

daohu527 / imap Goto Github PK

View Code? Open in Web Editor NEW
199.0 9.0 62.0 3.6 MB

High-resolution map (OpenDrive\Apollo) visualization and conversion tools

License: Apache License 2.0

Python 100.00%
hd-map opendrive apollo

imap's Introduction

imap

Documentation Status

imap is a tool for visualize and convert format of the hd-map. This project was inspired by Apollo.

example

Supported features:

  1. Visualize the hd-map, supported formats: Apollo, OpenDrive.
  2. Find lane by id
  3. Convert format: Opendrive to Apollo format.
os support remark
ubuntu ✔️
mac ✔️
windows ✔️

Related work

  • odrviewer.io is an excellent interactive online OpenDRIVE viewer.
  • esmini is a basic OpenSCENARIO player.
  • apollo_map convert carla map to apollo

Quick start

Install

You can install imap by following cmd.

pip3 install imap_box

Example

1. Visualization

After the installation is complete, you can view the map with the following command.

imap -m data/borregas_ave.txt
// or
imap -m data/town.xodr

Currently supported formats:

  • Apollo map
  • OpenDrive map

2. Find lane by id

You can use below command to find lane by id, Found lane is shown in Red.

imap -m data/borregas_ave.txt -l lane_35

3. Format conversion

Now you can convert OpenDrive map to Apollo map by following command.

imap -f -i data/town.xodr -o data/apollo_map.txt

The following is the display of the hd-map in data\borregas_ave.txt.You can click on the lane you want to display more detail info, which will display the current lane's id, as well as the predecessor and successor lane's id in the upper left corner.

map_show

Questions

  1. After running the command imap -m data/your_map_file, nothing display and no errors!!!

A: Check the permissions of the map file, if the current user does not have permissions, modify the permissions with the following commands.

sudo chmod 777 data/your_map_file
  1. Map data permission checking has no problem, still nothing display and no errors! A: It's better to install imap_box by running "sudo pip3 install imap_box", then run "imap -m xxx.txt".

imap's People

Contributors

bailihua93 avatar daohu527 avatar haodong2000 avatar harrison091124 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imap's Issues

Virtual lane lines and maps

Hello, Mr. Wang. I'd like to ask if the opendrive format is used when generating the virtual lane line file TXT? When I read many articles, I introduced that the high-precision map of Apollo was changed in the format of opendrive. Does the high-precision map refer to virtual lane lines, traffic lights, pedestrian crossings and so on? Or is it a three-dimensional environment generated by lidar records?

Some Detail Considerations on Road Length

We sample according to the step size, but the length of the road is not necessarily exactly divisible by the step size, so we will try to increase it by 1 step, not reduce it, resulting in some line segments exceeding.

Is it possible to try just to the length of the road?

opendrive地图转换成apollo的地图时出错

参考readme里运行样例是可以正常显示地图的。但是换成我用roadrunner导出的opendrive地图转换apollo的地图就报错了,见下图
image

麻烦帮忙看一下是什么原因?谢谢了!

about road_elevation

Has the "road_elevation" been converted?where is the transformed result in the apollo map(.txt)?

您好,xodr地图可视化失败,转换apollo地图失败,有如下报错

imap -m sssssr.xodr
Traceback (most recent call last):
File "/usr/local/bin/imap", line 11, in
load_entry_point('imap-box==0.1.6', 'console_scripts', 'imap')()
File "/usr/local/lib/python3.8/dist-packages/imap_box-0.1.6-py3.8.egg/imap/main.py", line 98, in main
File "/usr/local/lib/python3.8/dist-packages/imap_box-0.1.6-py3.8.egg/imap/main.py", line 39, in show_open_drive_map
File "/usr/local/lib/python3.8/dist-packages/imap_box-0.1.6-py3.8.egg/imap/lib/convertor.py", line 118, in init
File "/usr/local/lib/python3.8/dist-packages/imap_box-0.1.6-py3.8.egg/imap/lib/opendrive/map.py", line 117, in load
File "/usr/local/lib/python3.8/dist-packages/imap_box-0.1.6-py3.8.egg/imap/lib/opendrive/map.py", line 79, in post_process
KeyError: '1837'
chenghong@CNSHA0206L:~/Downloads$ imap -f -i sssssr.xodr -o apollo_map.txt
Traceback (most recent call last):
File "/usr/local/bin/imap", line 11, in
load_entry_point('imap-box==0.1.6', 'console_scripts', 'imap')()
File "/usr/local/lib/python3.8/dist-packages/imap_box-0.1.6-py3.8.egg/imap/main.py", line 108, in main
File "/usr/local/lib/python3.8/dist-packages/imap_box-0.1.6-py3.8.egg/imap/main.py", line 31, in convert_map_format
File "/usr/local/lib/python3.8/dist-packages/imap_box-0.1.6-py3.8.egg/imap/lib/convertor.py", line 118, in init
File "/usr/local/lib/python3.8/dist-packages/imap_box-0.1.6-py3.8.egg/imap/lib/opendrive/map.py", line 117, in load
File "/usr/local/lib/python3.8/dist-packages/imap_box-0.1.6-py3.8.egg/imap/lib/opendrive/map.py", line 79, in post_process
KeyError: '1837'

格式转换失败

你好,我使用pip安装工具后,将按照readme中介绍,将opendrive的地图转apollo的txt地图时,没有输出结果,请问知道啥原因吗?执行输出为
/home/forrest/.local/lib/python3.8/site-packages/imap/lib/opendrive/profile.py:42: FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
if not raw_elevation_profile:
parse_geo_reference is +lat_0=4.9000000000000000e+1 +lon_0=8.0000000000000000e+0:

Missing input length check at `imap.imap.lib.common.calc_length`

Version

$ python3 -m pip show imap_box
Name: imap-box
Version: 0.1.6
Summary: High-resolution map visualization and conversion tool
Home-page: https://github.com/daohu527/imap
Author: daohu527
Author-email: [email protected]
License: UNKNOWN
Location: /usr/local/lib/python3.7/dist-packages
Requires: matplotlib, protobuf, pyproj, record-msg
Required-by: 

Traceback

Traceback (most recent call last):
  File "/usr/local/bin/imap", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/imap/main.py", line 108, in main
    convert_map_format(args.input, args.output)
  File "/usr/local/lib/python3.7/dist-packages/imap/main.py", line 34, in convert_map_format
    opendrive2apollo.convert()
  File "/usr/local/lib/python3.7/dist-packages/imap/lib/convertor.py", line 610, in convert
    self.convert_roads()
  File "/usr/local/lib/python3.7/dist-packages/imap/lib/convertor.py", line 561, in convert_roads
    xodr_road.process_lanes()
  File "/usr/local/lib/python3.7/dist-packages/imap/lib/opendrive/road.py", line 198, in process_lanes
    self.lanes.process_lane_sections(self.reference_line)
  File "/usr/local/lib/python3.7/dist-packages/imap/lib/opendrive/lanes.py", line 426, in process_lane_sections
    lane_section.process_lane(reference_line_in_section)
  File "/usr/local/lib/python3.7/dist-packages/imap/lib/opendrive/lanes.py", line 324, in process_lane
    left_boundary = lane.generate_boundary(left_boundary, self.s)
  File "/usr/local/lib/python3.7/dist-packages/imap/lib/opendrive/lanes.py", line 229, in generate_boundary
    self.length = calc_length(self.center_line)
  File "/usr/local/lib/python3.7/dist-packages/imap/lib/common.py", line 111, in calc_length
    if math.fabs(points[0].yaw - points[-1].yaw) < 0.01:
IndexError: list index out of range

Fix

imap/imap/lib/common.py

Lines 114 to 116 in e4afa8f

def calc_length(points):
length = 0
if math.fabs(points[0].yaw - points[-1].yaw) < 0.01:

Check if len(points) < 2: and return 0 (length) if so.

Suggested fix (+ typehint)

def calc_length(points: List[Point3d]) -> float:
  length = .0
  if len(points) >= 2:
    if math.fabs(points[0].yaw - points[-1].yaw) < 0.01:
      # straight line
      p, q = points[0], points[-1]
      x = q.x - p.x
      y = q.y - p.y
      z = q.z - p.z
      length = math.sqrt(x**2 + y**2 + z**2)
    else:
      for p, q in zip(points, points[1:]):
        x = q.x - p.x
        y = q.y - p.y
        z = q.z - p.z
        length += math.sqrt(x**2 + y**2 + z**2)
  return length

ValueError: not enough values to unpack (expected 2, got 0)

@daohu527 , hi, could you please give me some comments about the issue. I can use the town.xord successfully. But when i using the t1.xord which i generated from roadrunner, i get he issue as shown below:

ll@ubuntu:~/Demo_Project/roadrunnerdemo/Exports$ imap -f -i ./t1.xodr -o ./test.txt
parse_geo_reference is +proj=tmerc +lat_0=31.5193375 +lon_0=120.4537025 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +geoidgrids=egm96_15.gtx +vunits=m +no_defs :
Traceback (most recent call last):
File "/home/ll/.local/bin/imap", line 8, in
sys.exit(main())
File "/home/ll/.local/lib/python3.6/site-packages/imap/main.py", line 82, in main
convert_map_format(args.input, args.output)
File "/home/ll/.local/lib/python3.6/site-packages/imap/main.py", line 31, in convert_map_format
opendrive2apollo.convert()
File "/home/ll/.local/lib/python3.6/site-packages/imap/lib/convertor.py", line 426, in convert
self.convert_junctions()
File "/home/ll/.local/lib/python3.6/site-packages/imap/lib/convertor.py", line 411, in convert_junctions
polygon = self.construct_junction_polygon(xodr_junction)
File "/home/ll/.local/lib/python3.6/site-packages/imap/lib/convertor.py", line 399, in construct_junction_polygon
start, end = road.get_cross_section(relation)
ValueError: not enough values to unpack (expected 2, got 0)


I think the issue may be caused by the incorrect t1.xord, but i didn't know the root cause.


Partial t1.xord information as shown below.


how to use bin_map_generator to generator base_map.bin in Apollo?

Hello DaoHu. I have a question and want to know why . Firstly, use carla_map(Town01.xodr) to genenrate a base_map.txt, and using bin_map_generator to generate base_map.bin file in Apollo docker(R7.0.0). but dreamview can't show it on web. can you tell why? Please

question about Elevation

get_Elevation_by_s

when i read the code about Elevation, i see some strange variable(like: "s"), could you please tell me the answer?
thanks a lot

When I run the command there is an error

when i run the command(imap -m data/borregas_ave.txt) ,the error "Error: Cannot parse %s as binary or text proto data/borregas_ave.txt" come out .Also ,i see the code (/home/mcw/imap-main/imap/lib/proto_utils)。But I don't know what went wrong.

Excuse, ask a question about hdmap

Excuse me, I would like to ask, is there any high precision map visualization currently done in C++? Do you have any relevant material to recommend? I only found a showmap tool in Apollo code, which is similar to your visualization method.

Converted apollo maps from carla's xodr does not work as is with apollo

Hi,
I'm trying to run some simulation on carla -- apollo via the https://github.com/guardstrikelab/carla_apollo_bridge. The default map (carla_town01) works well and I have no problem with it. However, when I attempt to run other maps (e.g. 02 --> 05), I found that the entire map does not show up in dreamview and I cannot provide routing to have the ego car travels around the map. Please help me figure out the cause for this.

Here are the steps that I followed based on suggestions from guardstrikelab/carla_apollo_bridge#62 and guardstrikelab/carla_apollo_bridge#31.

Download map from carla

Download via api, e.g.,

world = client.load_world('Town05')
# save map to .xodr format
world_map = world.get_map()
world_map.save_to_disk('town05/base_map')

Convert via imap instructions here https://github.com/daohu527/imap

The conversion process was successful and when I check via imap -m, the coordinates bounds are roughly the same.

Generate sim & routing map https://github.com/ApolloAuto/apollo/tree/master/modules/map/data

I followed steps here to generate the corresponding map, and put them in apollo/module/map/data and add the corresponding flag in global_flagfile.txt, which the map's name shows up correctly in Dreamview, but the lanes does not show up.

alt text
In this photo here, you can see that the car is on the map.
alt text
Here, we notice that the map is town05, the car is visible and can detect obstacles, yet, the map is not visible, and I cannot set routes.

Maps from https://github.com/Flycars/apollo_map also run into the same problem

One thing I noticed is that for the pre-existing map of carla_town01, the coordinates are different vs. the version I download from carla and convert (especially the x axis).

I have been looking at the coordinates and tried to move it around with no success. Please help me figure out the cause for this.

Traffic Light Availability

Hi @daohu527, thank you for the nice work.

I want to ask if the converted map(.bin and .txt) contains information on traffic lights.
I saw the issue and it seems that you may added traffic light signals.
Is my understanding correct? If not, can I ask your plan to support traffic lights?

建议

1 .\imap\lib\opendrive\map.py 文件中, 为road和junction添加 predecessor、successor信息时,应判断原始xx.xodr文件中对应的信息是否为空,如果为空,则跳过。 某些xx.xodr的信息不完整,如不判断,会产生找不到对应的元素的问题。
2 如果是carla脚本生成的xx.xodr的name有可能是乱码,如果不处理,会出现bug. 需可以增加相关的判断逻辑.
3. 建议在说明文件中明确运行环境和依赖版本。

生成异常

您好,当我使用imap显示地图文件时出现:
D:\ProgramData\Anaconda3\lib\site-packages\imap\lib\proto_utils.py:68: RuntimeWarning: Unexpected end-group tag: Not all data was converted pb_value.ParseFromString(file_in.read())
此地图文件是apollo中map_gen生成出来的文件,为什么会出现显示错误呢

Related to junction

For example, I have a junction with ID 1 that generates a statement similar to the following after transformation. Is this expected?

`

successor_id {
id: "road_1_lane_0_-1"
}
`

TypeError: None has type NoneType, but expected one of: int, long

imap -m cologne_fortiib.xodr
parse_geo_reference is +proj=tmerc +lat_0=50.9961872 +lon_0=6.8882864 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +geoidgrids=egm96_15.gtx +vunits=m +no_defs :
Traceback (most recent call last):
File "/home/xiao/Project/Env/py37/bin/imap", line 8, in
sys.exit(main())
File "/home/xiao/Project/Env/py37/lib/python3.7/site-packages/imap/main.py", line 98, in main
show_open_drive_map(args.map)
File "/home/xiao/Project/Env/py37/lib/python3.7/site-packages/imap/main.py", line 41, in show_open_drive_map
opendrive2apollo.convert()
File "/home/xiao/Project/Env/py37/lib/python3.7/site-packages/imap/lib/convertor.py", line 577, in convert
self.convert_roads()
File "/home/xiao/Project/Env/py37/lib/python3.7/site-packages/imap/lib/convertor.py", line 530, in convert_roads
pb_last_right_section = self.convert_lane(xodr_road, pb_road)
File "/home/xiao/Project/Env/py37/lib/python3.7/site-packages/imap/lib/convertor.py", line 443, in convert_lane
pb_lane = self.create_lane(xodr_road, lane_section, idx, lane)
File "/home/xiao/Project/Env/py37/lib/python3.7/site-packages/imap/lib/convertor.py", line 380, in create_lane
self.add_basic_info(pb_lane, xodr_road, idx, lane)
File "/home/xiao/Project/Env/py37/lib/python3.7/site-packages/imap/lib/convertor.py", line 168, in add_basic_info
pb_lane.type = to_pb_lane_type(lane.lane_type)
TypeError: None has type NoneType, but expected one of: int, long

Non-ASCII error when running main.py

run
python main.py -m data/borregas_ave.txt
got error
File "main.py", line 23 SyntaxError: Non-ASCII character '\xc2' in file main.py on line 23, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Need to add # -*- coding: utf-8 -* at the very beginning of script to solve this error.

xodr转apollo时,s值折叠.

例如: 直线和ParamPoly3相接,第一段是直线(直线长度非整数,例如33.45339495),第二段是ParamPoly3(起始s=33.45339495)时:
程序生成的结果是:
left_sample {
s: 34.0
width: 2.0
}
left_sample {
s: 33.45339495
width: 2.0
}
s:34为直线的最后一个点,s:33.4533是ParamPoly3的第一个点。
由于直线采样时,采样点数是向上取整,导致计算最后一个点的s的时候,absolute_s = self.s + s,s值会等于直线段长度向上取整。此时,ParamPoly3计算s的时候,会以自身起始s开始计算,例如s: 33.45339495,会导致生成的apollo地图的s值在交接处会部分重叠。

Conversion failure

Very useful conversion tool, but I encountered conversion failure for
straight_500m.txt ,Please change the txt suffix to the xodr suffix because of upload restrictions

I used the imap -m straight_500m.xodr command, and the result showed that XXX... AttributeError: 'NoneType' object has no attribute 'encode'

Potential bugs about road conversion

I use imap to convert town.xodr to apollo map and run the sim control simulation. However, I found that the vehicle cannot drive from road_9_lane_0_1 s: 15.5023 x: 129.486 y: -55.733 to road_22_lane_0_-1 s: 26.524 x: 88.7576 y: -94.6779, cause these will be a gap in the planned route.
gap

And I check the generated base_map.txt file, I found that the length of center_line, left_boundary, right_boundary for road_192_lane_0_-1 are the same, which is not as expected.

I try to increase the length of center_line and right_boundary, and the problem can be fixed.

I am not sure whether it is a bug of imap, can could you plz pay attention for this issue and solve it fundamentally? Thx in advance.

cannot use imap

Command 'imap' not found, did you mean:

command 'nmap' from snap nmap (7.93)
command 'umap' from deb libunicode-map8-perl (0.13+dfsg-4build6)
command 'nmap' from deb nmap (7.80+dfsg1-2build1)
command 'imapd' from deb courier-imap (5.0.6+1.0.6-1build2)
command 'amap' from deb amap-align (2.2+git20080214.600fc29+dfsg-1build1)
command 'tmap' from deb emboss (6.6.0+dfsg-7ubuntu2)
command 'jmap' from deb openjdk-16-jdk-headless (16.0.1+9-120.04)
command 'jmap' from deb openjdk-17-jdk-headless (17.0.6+10-0ubuntu1
20.04.1)
command 'jmap' from deb openjdk-8-jdk-headless (8u362-ga-0ubuntu120.04.1)
command 'jmap' from deb openjdk-13-jdk-headless (13.0.7+5-0ubuntu1
20.04)
command 'imgp' from deb imgp (2.7-1)
command 'zmap' from deb zmap (2.1.1-2build3)
command 'gmap' from deb gmap (2020-04-08+ds1-1)
command 'smap' from deb slurm-client (19.05.5-1)

See 'snap info ' for additional versions.

========but i already installed it.==========

pip3 install imap_box
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: imap_box in ./.local/lib/python3.8/site-packages (0.1.6)
Requirement already satisfied: protobuf<=3.19.4 in /usr/lib/python3/dist-packages (from imap_box) (3.6.1)
Requirement already satisfied: record-msg<=0.1.1 in ./.local/lib/python3.8/site-packages (from imap_box) (0.1.1)
Requirement already satisfied: pyproj in ./.local/lib/python3.8/site-packages (from imap_box) (3.5.0)
Requirement already satisfied: matplotlib in /usr/lib/python3/dist-packages (from imap_box) (3.1.2)
Requirement already satisfied: lzf in ./.local/lib/python3.8/site-packages (from record-msg<=0.1.1->imap_box) (0.1)
Requirement already satisfied: opencv-python in ./.local/lib/python3.8/site-packages (from record-msg<=0.1.1->imap_box) (4.7.0.72)
Requirement already satisfied: certifi in /usr/lib/python3/dist-packages (from pyproj->imap_box) (2019.11.28)
Requirement already satisfied: cffi>=1.0.0 in ./.local/lib/python3.8/site-packages (from lzf->record-msg<=0.1.1->imap_box) (1.15.1)
Requirement already satisfied: numpy>=1.17.0 in /usr/lib/python3/dist-packages (from opencv-python->record-msg<=0.1.1->imap_box) (1.17.4)
Requirement already satisfied: pycparser in ./.local/lib/python3.8/site-packages (from cffi>=1.0.0->lzf->record-msg<=0.1.1->imap_box) (2.21)

Missing input length check at `imap.imap.lib.convertor.Opendrive2Apollo.add_lane_sample`

Version

$ python3 -m pip show imap_box | grep Version
Version: 0.1.6

Traceback

...
    total_s = lane.center_line[0].s
IndexError: list index out of range

Fix

imap/imap/lib/convertor.py

Lines 260 to 263 in e4afa8f

def add_lane_sample(self, pb_lane, lane):
cur_lane_id = int(lane.lane_id)
total_s = lane.center_line[0].s
for point3d in lane.center_line:

Check if the list is empty.

Suggested fix

    total_s = lane.center_line[0].s if lane.center_line else .0

when xodr lanes have offset ,convertion to xml makes mistake

Hi, I have this problem:

<laneOffset s="0.0000000000000000e+0" a="3.5000000000000000e+0" b="0.0000000000000000e+0" c="0.0000000000000000e+0" d="0.0000000000000000e+0"/>

This lane have offset "a = 3.5",when convert to xml and show in apollo ,the junction including the lane cannot show correctly
image
I checked code and found in lanes.py ,left direction is -1 and right direction is 1,maybe this causes issues.
Thanks for helping !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.