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;
47using NodeList = std::vector<SimpleWaypointPtr>;
51using Point3D = bg::model::point<float, 3, bg::cs::cartesian>;
52using Box = bg::model::box<Point3D>;
55using SegmentId = std::tuple<crd::RoadId, crd::LaneId, crd::SectionId>;
56using SegmentTopology = std::map<SegmentId, std::pair<std::vector<SegmentId>, std::vector<SegmentId>>>;
57using SegmentMap = std::map<SegmentId, std::vector<SimpleWaypointPtr>>;
58using Rtree = bgi::rtree<SpatialTreeEntry, bgi::rstar<16>>;
78 static void Cook(
WorldMap world_map,
const std::string& path);
81 bool Load(
const std::vector<uint8_t>& content);
97 const cc::Map&
GetMap()
const;
100 void Save(
const std::string& path);
此类构建一个离散的本地地图缓存。 使用世界实例化该类并运行SetUp()构造本地地图。
InMemoryMap(WorldMap world_map)
bool Load(const std::vector< uint8_t > &content)
WorldMap _world_map
保存构造函数接收的世界地图对象。
const cc::Map & GetMap() const
void FindAndLinkLaneChange(SimpleWaypointPtr reference_waypoint)
此方法用于查找和链接车道变更连接。
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
计算给定路径点的段ID。 ID考虑了OpenDrive的道路ID、车道ID和分段ID。
NodeList GetDenseTopology() const
此方法返回本地缓存中离散样本的完整列表。
void SetUp()
此方法以采样分辨率构建本地地图。
NodeList GetWaypointsInDelta(const cg::Location loc, const uint16_t n_points, const float random_sample) const
此方法返回与自我车辆距离一定范围内的n个路径点。
NodeList GetSuccessors(const SegmentId segment_id, const SegmentTopology &segment_topology, const SegmentMap &segment_map)
SimpleWaypointPtr GetWaypoint(const cg::Location loc) const
此方法返回给定位置上最近的路径点。
Rtree rtree
用于索引和查询路径点的空间二维R树。
NodeList dense_topology
存储所有自定义路径点对象的结构,经过稀疏拓扑插值处理。
void Save(const std::string &path)
void SetUpDenseTopology()
std::map< SegmentId, std::vector< SimpleWaypointPtr > > SegmentMap
carla::SharedPtr< cc::Waypoint > WaypointPtr
Waypoint的智能指针类型别名。
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
boost::shared_ptr< T > SharedPtr
使用这个SharedPtr(boost::shared_ptr)以保持与boost::python的兼容性, 但未来如果可能的话,我们希望能为std::shared_ptr制作一个Python适配器。