21 static auto MakeMap(
const std::string &opendrive_contents) {
22 auto stream = std::istringstream(opendrive_contents);
24 if (!map.has_value()) {
27 return std::move(*map);
31 : _description(
std::move(description)),
35 Map::Map(std::string name, std::string xodr_content)
38 std::vector<geom::Transform>{}}, xodr_content) {
39 open_drive_file = xodr_content;
42 Map::~Map() =
default;
47 int32_t lane_type)
const {
48 boost::optional<road::element::Waypoint> waypoint;
49 if (project_to_road) {
50 waypoint = _map.GetClosestWaypointOnRoad(location, lane_type);
54 return waypoint.has_value() ?
63 boost::optional<road::element::Waypoint> waypoint;
64 waypoint = _map.GetWaypoint(road_id, lane_id, s);
65 return waypoint.has_value() ?
72 std::unordered_map<re::Waypoint, SharedPtr<Waypoint>> waypoints;
74 auto get_or_make_waypoint = [&](
const auto &waypoint) {
75 auto it = waypoints.find(waypoint);
76 if (it == waypoints.end()) {
77 it = waypoints.emplace(
85 auto topology = _map.GenerateTopology();
86 result.reserve(topology.size());
87 for (
const auto &pair : topology) {
89 get_or_make_waypoint(pair.first),
90 get_or_make_waypoint(pair.second));
95 std::vector<SharedPtr<Waypoint>> Map::GenerateWaypoints(
double distance)
const {
96 std::vector<SharedPtr<Waypoint>> result;
97 const auto waypoints = _map.GenerateWaypoints(distance);
98 result.reserve(waypoints.size());
99 for (
const auto &waypoint : waypoints) {
105 std::vector<road::element::LaneMarking> Map::CalculateCrossedLanes(
108 return _map.CalculateCrossedLanes(origin, destination);
112 return _map.GetGeoReference();
115 std::vector<geom::Location> Map::GetAllCrosswalkZones()
const {
116 return _map.GetAllCrosswalkZones();
129 auto junction_waypoints = GetMap().GetJunctionWaypoints(
id, lane_type);
130 for (
auto &waypoint_pair : junction_waypoints) {
138 std::vector<SharedPtr<Landmark>> Map::GetAllLandmarks()
const {
139 std::vector<SharedPtr<Landmark>> result;
140 auto signal_references = _map.GetAllSignalReferences();
141 for(
auto* signal_reference : signal_references) {
143 new Landmark(
nullptr, shared_from_this(), signal_reference, 0));
148 std::vector<SharedPtr<Landmark>> Map::GetLandmarksFromId(std::string
id)
const {
149 std::vector<SharedPtr<Landmark>> result;
150 auto signal_references = _map.GetAllSignalReferences();
151 for(
auto* signal_reference : signal_references) {
152 if(signal_reference->GetSignalId() == id) {
154 new Landmark(
nullptr, shared_from_this(), signal_reference, 0));
160 std::vector<SharedPtr<Landmark>> Map::GetAllLandmarksOfType(std::string type)
const {
161 std::vector<SharedPtr<Landmark>> result;
162 auto signal_references = _map.GetAllSignalReferences();
163 for(
auto* signal_reference : signal_references) {
164 if(signal_reference->GetSignal()->GetType() == type) {
166 new Landmark(
nullptr, shared_from_this(), signal_reference, 0));
172 std::vector<SharedPtr<Landmark>>
173 Map::GetLandmarkGroup(
const Landmark &landmark)
const {
174 std::vector<SharedPtr<Landmark>> result;
176 for (
auto& controller_id : controllers) {
177 const auto &controller = _map.GetControllers().at(controller_id);
178 for(
auto& signal_id : controller->GetSignals()) {
179 auto& signal = _map.GetSignals().at(signal_id);
180 auto new_landmarks = GetLandmarksFromId(signal->GetSignalId());
181 result.insert(result.end(), new_landmarks.begin(), new_landmarks.end());
187 void Map::CookInMemoryMap(
const std::string& path)
const {
Class containing a reference to RoadInfoSignal
const road::element::RoadInfoSignal * _signal
std::vector< std::pair< SharedPtr< Waypoint >, SharedPtr< Waypoint > > > TopologyList
std::string open_drive_file
Map(rpc::MapInfo description, std::string xodr_content)
SharedPtr< Waypoint > GetWaypoint(const geom::Location &location, bool project_to_road=true, int32_t lane_type=static_cast< uint32_t >(road::Lane::LaneType::Driving)) const
road::JuncId GetJunctionId() const
static boost::optional< road::Map > Load(const std::string &opendrive)
LaneType
Can be used as flags
const std::set< ContId > & GetControllers() const
const Signal * GetSignal() const
static void Cook(WorldMap world_map, const std::string &path)
static auto MakeMap(const std::string &opendrive_contents)
This file contains definitions of common data structures used in traffic manager.
void throw_exception(const std::exception &e)
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...