ApolloAuto / apollo

An open autonomous driving platform
Apache License 2.0
25k stars 9.67k forks source link

Maps File Format and Location #5055

Closed SanduIrina closed 4 years ago

SanduIrina commented 6 years ago

I managed to convert an osm map of a campus to .xodr(open drive format). Could I use this file as a new map in Apollo? I read that it uses the open drive format but I couldn't find where these maps are so that I could add my own. I may be totally wrong with this. Do you have any advice as how to take a real world map and use it?

jilinzhou commented 6 years ago

The current code takes file ends with '.xml' for open drive format map. Two places which is loaded are as the following:

  1. for path planning

    int HDMapImpl::LoadMapFromFile(const std::string& map_filename) {
    Clear();
    // TODO(startcode) seems map_ can be changed to a local variable of this
    // function, but test will fail if I do so. if so.
    if (apollo::common::util::EndWith(map_filename, ".xml")) {
    if (!adapter::OpendriveAdapter::LoadData(map_filename, &map_)) {
      return -1;
    }
    } else if (!apollo::common::util::GetProtoFromFile(map_filename, &map_)) {
    return -1;
    }
    return LoadMapFromProto(map_);
    }
  2. for routing

    bool GraphCreator::Create() {
    if (common::util::EndWith(base_map_file_path_, ".xml")) {
    if (!hdmap::adapter::OpendriveAdapter::LoadData(base_map_file_path_,
                                                    &pbmap_)) {
      AERROR << "Failed to load base map file from " << base_map_file_path_;
      return false;
    }
    } else {
    if (!common::util::GetProtoFromFile(base_map_file_path_, &pbmap_)) {
      AERROR << "Failed to load base map file from " << base_map_file_path_;
      return false;
    }
    }
    
    ...
    }

The map files should be put under /apollo/modules/map/data/blahblah. And you also need to change /apollo/modules/common/data/global_flagfile.txt to add your map folder:

--map_dir=/apollo/modules/map/data/blahblah

After these are done, relaunch the planning module and routing service. Or simply you can restart everything.

I have not tried this format myself. Good luck and please let me know if it works.

SanduIrina commented 6 years ago

Thank you, For now I'll try to manually convert some maps from a driving simulator called carla, I'll keep you posted on what I find when I'll try to convert a real world map. Do you happen to know what the scale for the coordinates is? For example, I used the map_gen_two_lanes_right_ext.py script to generate a base_map and in the input file I wrote a bunch of coordinates, like 0,24 24,24 and so on to describe the road geometry, but I couldn't find how much one unit is in meters or something similar( let's say the distance between the points 0,0 and 0,1).

alexbuyval commented 6 years ago

Hi @SanduIrina, what tool have you used to convert an OSM to OD format? Have you been succeed to load the converted map into apollo?

Regards, Alex

SanduIrina commented 6 years ago

Hi, i couldn't find any tool that would do that, so I learned the open drive format and wrote a basic map myself by taking real coordinates from google maps