nutonomy / nuscenes-devkit

The devkit of the nuScenes dataset.
https://www.nuScenes.org
Other
2.19k stars 616 forks source link

Deviation between map data and OSM #1011

Closed wowlza closed 6 months ago

wowlza commented 7 months ago

Hi, sorry I closed the previous issue by mistake. And I state my problem here again.

I'm trying to obtain SD maps from OpenStreetMap(OSM) based on the map data. But I had a problem with deviation between map data and OSM data.

I want to know how to correct such deviations?

The method I got the OSM data can be demonstrated by the following image: 坐标转换思路

I got the city_coords according to the frame_pose, which is measured in meters.

Therefore, in order to get the absolute coordinates, I have to use the UTM coordinate system as an intermediary.

I first converted the original coordinates of the city EPSG:4326, like singapore-onenorth: (1.2882100868743724, 103.78475189208984), to EPSG:3857. In the EPSG:3857 coordinates, the values of the city coordinate are added on the basis of the original coordinates. Then I converted it back to EPSG 4326, and got the OSM data.

The steps to convert back are also consistent.

@whyekit-motional I think #966 did not solve my problem.

#966 visualize the results in EPSG 3857 or EPSG 4326, but I visualized my result under the city coordinates.

I vitualized the maps and there is a certain bias in the results, especially the boston-seaport. The results are as following:

The gray lines are roads from OSM and the gray blocks are road_segment and lane from nuScenes 图片4

图片1

Did I make any mistakes along the way? Could you give me some advice? Thanks!

Originally posted by @wowlza in https://github.com/nutonomy/nuscenes-devkit/issues/1010#issuecomment-1820500016

basbaba commented 7 months ago

Many people mailed me about the coordinates of nuScenes problem. I'll make it more clear:

  1. nuScenes raw data captured by GNSS is under EPSG:4326, this is a Spherical coordinate system , described as latitude, longitude and altitude(LLA), it's unit is degree

  2. When drawing the raw data on nuScenes Map, this is a projection, we called it: Local tangent plane coordinates (LTP), in most case also as east, north, up (ENU), it's unit is meter.(so nuScenes Map is ENU coordinate system, not EPSG:4326 or EPSG:3857) https://en.wikipedia.org/wiki/Local_tangent_plane_coordinates

  3. because each map of nuScenes is small(about 3km x 3km), so we can take is as a rectangle plane, not a curve surface on spherical, so it's easy to calculate distance and angle on these maps

  4. The detail of transferring between ENU and EPSG:4326 or EPSG:3857 is like this: ENU <-> ECEF <-> EPSG:4326 <-> EPSG:3857 ECEF is Earth-centered, Earth-fixed coordinate system https://en.wikipedia.org/wiki/Earth-centered,_Earth-fixed_coordinate_system

ENU and EPSG:3857 are 2D Cartesian coordinate system ECEF is 3D Cartesian coordinate system

  1. there is a good tool to do these convertion, I got them from: https://github.com/mapillary/OpenSfM/blob/main/opensfm/geo.py https://github.com/facebookresearch/OrienterNet/blob/main/maploc/utils/geo.py#L79 You can easily migrate the 2 files into your project. The Class Projection can be used to do: ENU(X,Y) <-> ECEF(X,Y,Z) <-> EPSG:4326(LLA)

    I just used these resource to integrate nuScenes Map and OSM

Hope this can help you

wowlza commented 7 months ago

Thanks for your reply! I solved the problem with the Boston map as you said the coordinate conversion. And the aligned result is as following: enu_bev_map_boston-seaport However, in the map of singapore's city, there are still some minor deviation: 偏差enu_bev_map_singapore-queenstown enu_bev_map_singapore-onenorth偏差 We can see that the lines of OSM are slightly higher than the nuscenes map elements.

I first thought that the influence of parameters such as height and reference ellipsoid was ignored during the coordinate conversion, but after checking it I found no problems.

Is there anything else I missed? It would be nice if you could give me some more advice. Thanks a lot !

basbaba commented 7 months ago

You are right, I think the problem is in nuScenes map, not caused by OSM or your codes.

  1. This is from my project screen shot, you can find the same offset between the 2 maps: 2023-12-05 10-24-36

  2. This is the original nuScenes map, look at the cross-road at the top, I marked in green rectangle: 2023-12-05 10-24-58

  3. The same cross-road in OSM, I marked the center of it in red circle, it's latitude and longitude can be find in the url: osm

  4. with the latitude and longitude, I calculate it's distance to the reference coordinates in NORTH-distance and EAST-distance: `from geo import gps_distance

REFERENCE_COORDINATES = { "boston-seaport": [42.336849169438615, -71.05785369873047], "singapore-onenorth": [1.2882100868743724, 103.78475189208984], "singapore-hollandvillage": [1.2993652317780957, 103.78217697143555], "singapore-queenstown": [1.2782562240223188, 103.76741409301758], }

lat1 = REFERENCE_COORDINATES['singapore-hollandvillage'][0] lon1 = REFERENCE_COORDINATES['singapore-hollandvillage'][1]

lat2 = 1.32494 lon2 = 103.79262

dis_NORTH = gps_distance(lat1, lon1, lat2, lon1) dis_EAST = gps_distance(lat1, lon1, lat1, lon2)

print(dis_NORTH, dis_EAST)`

the result is: dis_NORTH: 2827.926343195776 dis_EAST: 1162.2156931086347

  1. I enlarged the rectangle region in green and find (dis_EAST, dis_NORTH) is at the red circle: 2023-12-05 10-18-21

  2. The correct position should be at: 2023-12-05 10-19-07

So in my opinion, the reference coordinate of singapore-hollandvillage,provide by nuScenes, drifit a little distance along the longitude, that's why we got this result. The same problem happened in other maps of Singapore, maybe it's caused by GPS-RTK measurement when they collect the data in Singapore.