11#include <unordered_map>
12#include <unordered_set>
15# pragma clang diagnostic push
16# pragma clang diagnostic ignored "-Wshadow"
18#include "boost/geometry.hpp"
19#include "boost/geometry/geometries/point.hpp"
20#include "boost/geometry/index/rtree.hpp"
22# pragma clang diagnostic pop
37namespace traffic_manager {
42namespace bg = boost::geometry;
43namespace bgi = boost::geometry::index;
47 using NodeList = std::vector<SimpleWaypointPtr>;
51 using Point3D = bg::model::point<float, 3, bg::cs::cartesian>;
52 using Box = bg::model::box<Point3D>;
55 using SegmentId = std::tuple<crd::RoadId, crd::LaneId, crd::SectionId>;
56 using SegmentTopology = std::map<SegmentId, std::pair<std::vector<SegmentId>, std::vector<SegmentId>>>;
57 using SegmentMap = std::map<SegmentId, std::vector<SimpleWaypointPtr>>;
58 using Rtree = bgi::rtree<SpatialTreeEntry, bgi::rstar<16>>;
80 static void Cook(
WorldMap world_map,
const std::string& path);
83 bool Load(
const std::vector<uint8_t>& content);
102 void Save(
const std::string& path);
This class builds a discretized local map-cache.
InMemoryMap(WorldMap world_map)
bool Load(const std::vector< uint8_t > &content)
WorldMap _world_map
Object to hold the world map received by the constructor.
const cc::Map & GetMap() const
void FindAndLinkLaneChange(SimpleWaypointPtr reference_waypoint)
This method is used to find and place lane change links.
NodeList GetPredecessors(const SegmentId segment_id, const SegmentTopology &segment_topology, const SegmentMap &segment_map)
static void Cook(WorldMap world_map, const std::string &path)
SegmentId GetSegmentId(const WaypointPtr &wp) const
Computes the segment id of a given waypoint.
NodeList GetDenseTopology() const
This method returns the full list of discrete samples of the map in the local cache.
void SetUp()
This method constructs the local map with a resolution of sampling_resolution.
NodeList GetWaypointsInDelta(const cg::Location loc, const uint16_t n_points, const float random_sample) const
This method returns n waypoints in an delta area with a certain distance from the ego vehicle.
NodeList GetSuccessors(const SegmentId segment_id, const SegmentTopology &segment_topology, const SegmentMap &segment_map)
SimpleWaypointPtr GetWaypoint(const cg::Location loc) const
This method returns the closest waypoint to a given location on the map.
Rtree rtree
Spatial quadratic R-tree for indexing and querying waypoints.
NodeList dense_topology
Structure to hold all custom waypoint objects after interpolation of sparse topology.
void Save(const std::string &path)
void SetUpDenseTopology()
std::map< SegmentId, std::vector< SimpleWaypointPtr > > SegmentMap
carla::SharedPtr< cc::Waypoint > WaypointPtr
std::vector< SimpleWaypointPtr > NodeList
bg::model::box< Point3D > Box
bg::model::point< float, 3, bg::cs::cartesian > Point3D
carla::SharedPtr< const cc::Map > WorldMap
std::map< SegmentId, std::pair< std::vector< SegmentId >, std::vector< SegmentId > > > SegmentTopology
bgi::rtree< SpatialTreeEntry, bgi::rstar< 16 > > Rtree
std::shared_ptr< SimpleWaypoint > SimpleWaypointPtr
std::tuple< crd::RoadId, crd::LaneId, crd::SectionId > SegmentId
std::pair< Point3D, SimpleWaypointPtr > SpatialTreeEntry
This file contains definitions of common data structures used in traffic manager.
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...