Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
|
O(1) distance lookup structure for quickly accessing route distance information. NOTE: This structure is used internally in the world model and is not intended for use by WorldModel users. More...
#include <IndexedDistanceMap.hpp>
Public Member Functions | |
void | pushBack (const lanelet::LineString2d &ls) |
Add a linestring to this structure. This function will iterate over the line string to compute distances between each segment. More... | |
double | elementLength (size_t index) const |
Get the length of the linestring located at the provided index. More... | |
double | distanceToElement (size_t index) const |
Get the distance to the start of the linestring at the specified index. More... | |
double | distanceBetween (size_t index, size_t p1_index, size_t p2_index) const |
Get the distance between two points on the same linestring. More... | |
double | distanceToPointAlongElement (size_t index, size_t point_index) const |
Get the along-line distance to the point on the provided linestring. More... | |
double | totalLength () const |
Returns the total along-line length of this structure. More... | |
std::pair< size_t, size_t > | getIndexFromId (const lanelet::Id &id) const |
Returns the indexes of the element identified by the provided Id NOTE: It is up to the user to know if the id is for a linestring or a point. By default index values will be 0. More... | |
size_t | size () const |
Returns number of linestrings in this structure. More... | |
size_t | size (size_t index) const |
Returns the size of the linestring at the specified index. More... | |
std::pair< size_t, size_t > | getElementIndexByDistance (double distance, bool get_point=true) const |
Returns index of the linestring which the provided distance is within. NOTE: Unlike the rest of this class, this method runs in O(log n) where n is this.size() for accessing linestring index If accessing point index (get_point=true) then it runs an addition O(log m) where m is the linestring index.size(); This means the max complexity of this function is O(log n) + O(log m) More... | |
Private Attributes | |
std::vector< std::tuple< std::vector< double >, double > > | accum_lengths |
std::unordered_map< lanelet::Id, std::pair< size_t, size_t > > | id_index_map |
O(1) distance lookup structure for quickly accessing route distance information. NOTE: This structure is used internally in the world model and is not intended for use by WorldModel users.
This class is meant to be used when a route update occurs to precompute distances along the route to support rapid queries later on Insertion is O(n) where n is the number of points in the linestring This structure does not support element reinsertion Linestrings added to this structure should be fully unique (NO DUPLICATE IDs for linestring or point objects)
NOTE: Pre-computing route distances make queries much faster but could slow down route loading for large routes and cause them to use more memory.
Definition at line 42 of file IndexedDistanceMap.hpp.
double carma_wm::IndexedDistanceMap::distanceBetween | ( | size_t | index, |
size_t | p1_index, | ||
size_t | p2_index | ||
) | const |
Get the distance between two points on the same linestring.
NOTE: No bounds checking is performed
index | The index of the linestring |
p1_index | The index of the first point on the linestring |
p2_index | The index of the second point |
Definition at line 90 of file IndexedDistanceMap.cpp.
References distanceToPointAlongElement().
Referenced by carma_wm::CARMAWorldModel::routeTrackPos().
double carma_wm::IndexedDistanceMap::distanceToElement | ( | size_t | index | ) | const |
Get the distance to the start of the linestring at the specified index.
NOTE: No bounds checking is performed
index | The index of the linestring |
Definition at line 85 of file IndexedDistanceMap.cpp.
References accum_lengths.
Referenced by getElementIndexByDistance(), carma_wm::CARMAWorldModel::pointFromRouteTrackPos(), carma_wm::CARMAWorldModel::routeTrackPos(), and totalLength().
double carma_wm::IndexedDistanceMap::distanceToPointAlongElement | ( | size_t | index, |
size_t | point_index | ||
) | const |
Get the along-line distance to the point on the provided linestring.
NOTE: No bounds checking is performed
index | The linestring index |
point_index | The point index in the linestring at index |
Definition at line 95 of file IndexedDistanceMap.cpp.
References accum_lengths.
Referenced by distanceBetween(), carma_wm::CARMAWorldModel::pointFromRouteTrackPos(), and carma_wm::CARMAWorldModel::routeTrackPos().
double carma_wm::IndexedDistanceMap::elementLength | ( | size_t | index | ) | const |
Get the length of the linestring located at the provided index.
NOTE: No bounds checking is performed
index | The index of the linestring |
Definition at line 80 of file IndexedDistanceMap.cpp.
References accum_lengths.
Referenced by totalLength().
std::pair< size_t, size_t > carma_wm::IndexedDistanceMap::getElementIndexByDistance | ( | double | distance, |
bool | get_point = true |
||
) | const |
Returns index of the linestring which the provided distance is within. NOTE: Unlike the rest of this class, this method runs in O(log n) where n is this.size() for accessing linestring index If accessing point index (get_point=true) then it runs an addition O(log m) where m is the linestring index.size(); This means the max complexity of this function is O(log n) + O(log m)
std::invalid_argument | if distance does not fit within bounds [0, totalLength()] |
distance | The downtrack distance in meters to get the element for |
get_point | Set to true if you wish to access the index of the point prior to the provided distance. If false then pair->second will always be 0 |
Definition at line 44 of file IndexedDistanceMap.cpp.
References accum_lengths, distanceToElement(), carma_cooperative_perception::to_string(), and totalLength().
Referenced by carma_wm::CARMAWorldModel::pointFromRouteTrackPos().
std::pair< size_t, size_t > carma_wm::IndexedDistanceMap::getIndexFromId | ( | const lanelet::Id & | id | ) | const |
Returns the indexes of the element identified by the provided Id NOTE: It is up to the user to know if the id is for a linestring or a point. By default index values will be 0.
std::out_of_range | if the container does not have an element with the specified id |
Definition at line 109 of file IndexedDistanceMap.cpp.
References id_index_map.
Referenced by carma_wm::CARMAWorldModel::routeTrackPos().
void carma_wm::IndexedDistanceMap::pushBack | ( | const lanelet::LineString2d & | ls | ) |
Add a linestring to this structure. This function will iterate over the line string to compute distances between each segment.
std::invalid_argument | If the provided linstring was already added to this structure |
ls | The linestring to add |
Definition at line 21 of file IndexedDistanceMap.cpp.
References accum_lengths, process_bag::i, id_index_map, and totalLength().
Referenced by carma_wm::CARMAWorldModel::computeDowntrackReferenceLine().
size_t carma_wm::IndexedDistanceMap::size | ( | ) | const |
Returns number of linestrings in this structure.
Definition at line 114 of file IndexedDistanceMap.cpp.
References accum_lengths.
Referenced by carma_wm::CARMAWorldModel::computeDowntrackReferenceLine().
size_t carma_wm::IndexedDistanceMap::size | ( | size_t | index | ) | const |
Returns the size of the linestring at the specified index.
Definition at line 119 of file IndexedDistanceMap.cpp.
References accum_lengths.
double carma_wm::IndexedDistanceMap::totalLength | ( | ) | const |
Returns the total along-line length of this structure.
Definition at line 100 of file IndexedDistanceMap.cpp.
References accum_lengths, distanceToElement(), and elementLength().
Referenced by getElementIndexByDistance(), and pushBack().
|
private |
Definition at line 50 of file IndexedDistanceMap.hpp.
Referenced by distanceToElement(), distanceToPointAlongElement(), elementLength(), getElementIndexByDistance(), pushBack(), size(), and totalLength().
|
private |
Definition at line 54 of file IndexedDistanceMap.hpp.
Referenced by getIndexFromId(), and pushBack().