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) {
47 int32_t lane_type)
const {
48 boost::optional<road::element::Waypoint> waypoint;
49 if (project_to_road) {
54 return waypoint.has_value() ?
63 boost::optional<road::element::Waypoint> waypoint;
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(
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));
96 std::vector<SharedPtr<Waypoint>> result;
98 result.reserve(waypoints.size());
99 for (
const auto &waypoint : waypoints) {
130 for (
auto &waypoint_pair : junction_waypoints) {
139 std::vector<SharedPtr<Landmark>> result;
141 for(
auto* signal_reference : signal_references) {
143 new Landmark(
nullptr, shared_from_this(), signal_reference, 0));
149 std::vector<SharedPtr<Landmark>> result;
151 for(
auto* signal_reference : signal_references) {
152 if(signal_reference->GetSignalId() == id) {
154 new Landmark(
nullptr, shared_from_this(), signal_reference, 0));
161 std::vector<SharedPtr<Landmark>> result;
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>>
174 std::vector<SharedPtr<Landmark>> result;
176 for (
auto& controller_id : controllers) {
178 for(
auto& signal_id : controller->GetSignals()) {
181 result.insert(result.end(), new_landmarks.begin(), new_landmarks.end());
std::vector< element::LaneMarking > CalculateCrossedLanes(const geom::Location &origin, const geom::Location &destination) const
std::vector< std::pair< SharedPtr< Waypoint >, SharedPtr< Waypoint > > > GetJunctionWaypoints(road::JuncId id, road::Lane::LaneType type) const
Returns a pair of waypoints (start and end) for each lane in the junction.
const geom::GeoLocation & GetGeoReference() const
std::vector< std::pair< Waypoint, Waypoint > > GenerateTopology() const
Generate the minimum set of waypoints that define the topology of map.
boost::optional< element::Waypoint > GetWaypoint(const geom::Location &location, int32_t lane_type=static_cast< int32_t >(Lane::LaneType::Driving)) const
void CookInMemoryMap(const std::string &path) const
Cooks InMemoryMap used by the traffic manager.
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
void throw_exception(const std::exception &e)
std::vector< SharedPtr< Waypoint > > GenerateWaypoints(double distance) const
std::vector< geom::Location > GetAllCrosswalkZones() const
Returns a list of locations defining 2d areas, when a location is repeated an area is finished...
const std::unordered_map< ContId, std::unique_ptr< Controller > > & GetControllers() const
const road::Map & GetMap() const
Junction * GetJunction(JuncId id)
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
This file contains definitions of common data structures used in traffic manager. ...
static void Cook(WorldMap world_map, const std::string &path)
std::vector< const element::RoadInfoSignal * > GetAllSignalReferences() const
Return all RoadInfoSignal in the map.
Class containing a reference to RoadInfoSignal.
std::vector< std::pair< SharedPtr< Waypoint >, SharedPtr< Waypoint > >> TopologyList
SharedPtr< Waypoint > GetWaypointXODR(carla::road::RoadId road_id, carla::road::LaneId lane_id, float s) const
static boost::optional< road::Map > Load(const std::string &opendrive)
boost::optional< element::Waypoint > GetClosestWaypointOnRoad(const geom::Location &location, int32_t lane_type=static_cast< int32_t >(Lane::LaneType::Driving)) const
======================================================================== – Geometry ----------------...
std::vector< road::element::LaneMarking > CalculateCrossedLanes(const geom::Location &origin, const geom::Location &destination) const
road::JuncId GetJunctionId() const
const Signal * GetSignal() const
const std::set< ContId > & GetControllers() const
LaneType
Can be used as flags.
std::vector< SharedPtr< Landmark > > GetAllLandmarksOfType(std::string type) const
Returns all the landmarks in the map of a specific type.
std::vector< geom::Location > GetAllCrosswalkZones() const
std::vector< SharedPtr< Landmark > > GetLandmarkGroup(const Landmark &landmark) const
Returns all the landmarks in the same group including this one.
std::vector< SharedPtr< Landmark > > GetAllLandmarks() const
Returns all the larndmarks in the map.
SharedPtr< Junction > GetJunction(const Waypoint &waypoint) const
static auto MakeMap(const std::string &opendrive_contents)
std::string open_drive_file
const geom::GeoLocation & GetGeoReference() const
======================================================================== – Georeference ------------...
TopologyList GetTopology() const
std::vector< Waypoint > GenerateWaypoints(double approx_distance) const
Generate all the waypoints in map separated by approx_distance.
const road::element::RoadInfoSignal * _signal
const std::unordered_map< SignId, std::unique_ptr< Signal > > & GetSignals() const
std::vector< SharedPtr< Landmark > > GetLandmarksFromId(std::string id) const
Returns all the larndmarks in the map with a specific OpenDRIVE id.
std::vector< std::pair< Waypoint, Waypoint > > GetJunctionWaypoints(JuncId id, Lane::LaneType lane_type) const
Generate waypoints of the junction.
Map(rpc::MapInfo description, std::string xodr_content)
carla::SharedPtr< carla::client::Junction > Junction