CARLA
 
载入中...
搜索中...
未找到
InMemoryMap.cpp
浏览该文件的文档.
1// Copyright (c) 2020 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#include "carla/Logging.h"
8
11#include <boost/geometry/geometries/box.hpp>
12
13namespace carla {
14namespace traffic_manager {
15
16 namespace cg = carla::geom;
17 using namespace constants::Map;
18
19 using TopologyList = std::vector<std::pair<WaypointPtr, WaypointPtr>>;
20 using RawNodeList = std::vector<WaypointPtr>;
21
22 InMemoryMap::InMemoryMap(WorldMap world_map) : _world_map(world_map) {}
24
26 return std::make_tuple(wp->GetRoadId(), wp->GetLaneId(), wp->GetSectionId());
27 }
28
30 return GetSegmentId(swp->GetWaypoint());
31 }
32
34 const SegmentTopology &segment_topology,
35 const SegmentMap &segment_map) {
36 NodeList result;
37 if (segment_topology.find(segment_id) == segment_topology.end()) {
38 return result;
39 }
40
41 for (const auto &successor_segment_id : segment_topology.at(segment_id).second) {
42 if (segment_map.find(successor_segment_id) == segment_map.end()) {
43 auto successors = GetSuccessors(successor_segment_id, segment_topology, segment_map);
44 result.insert(result.end(), successors.begin(), successors.end());
45 } else {
46 result.emplace_back(segment_map.at(successor_segment_id).front());
47 }
48 }
49 return result;
50 }
51
53 const SegmentTopology &segment_topology,
54 const SegmentMap &segment_map) {
55 NodeList result;
56 if (segment_topology.find(segment_id) == segment_topology.end()) {
57 return result;
58 }
59
60 for (const auto &predecessor_segment_id : segment_topology.at(segment_id).first) {
61 if (segment_map.find(predecessor_segment_id) == segment_map.end()) {
62 auto predecessors = GetPredecessors(predecessor_segment_id, segment_topology, segment_map);
63 result.insert(result.end(), predecessors.begin(), predecessors.end());
64 } else {
65 result.emplace_back(segment_map.at(predecessor_segment_id).back());
66 }
67 }
68 return result;
69 }
70
71 void InMemoryMap::Cook(WorldMap world_map, const std::string& path) {
72 InMemoryMap local_map(world_map);
73 local_map.SetUp();
74 local_map.Save(path);
75 }
76
77 void InMemoryMap::Save(const std::string& path) {
78 std::string filename;
79 if (path.empty()) {
80 filename = this->GetMapName() + ".bin";
81 } else {
82 filename = path;
83 }
84
85 std::ofstream out_file;
86 out_file.open(filename, std::ios::binary);
87 if (!out_file.is_open()) {
88 log_error("Could not open binary file");
89 return;
90 }
91
92 // write total records
93 uint32_t total = static_cast<uint32_t>(dense_topology.size());
94 out_file.write(reinterpret_cast<const char *>(&total), sizeof(uint32_t));
95
96 // write simple waypoints
97 std::unordered_set<uint64_t> used_ids;
98 for (auto& wp: dense_topology) {
99 if (used_ids.find(wp->GetId()) != used_ids.end()) {
100 log_error("Could not generate the binary file. There are repeated waypoints");
101 }
102 CachedSimpleWaypoint cached_wp(wp);
103 cached_wp.Write(out_file);
104
105 used_ids.insert(wp->GetId());
106 }
107
108 out_file.close();
109 return;
110 }
111
112 bool InMemoryMap::Load(const std::vector<uint8_t>& content) {
113 unsigned long pos = 0;
114 std::vector<CachedSimpleWaypoint> cached_waypoints;
115 std::unordered_map<uint64_t, uint32_t> id2index;
116
117 // read total records
118 uint32_t total;
119 memcpy(&total, &content[pos], sizeof(total));
120 pos += sizeof(total);
121
122 // read simple waypoints
123 for (uint32_t i=0; i < total; i++) {
124 CachedSimpleWaypoint cached_wp;
125 cached_wp.Read(content, pos);
126 cached_waypoints.push_back(cached_wp);
127 id2index.insert({cached_wp.waypoint_id, i});
128
129 WaypointPtr waypoint_ptr = _world_map->GetWaypointXODR(cached_wp.road_id, cached_wp.lane_id, cached_wp.s);
130 SimpleWaypointPtr wp = std::make_shared<SimpleWaypoint>(waypoint_ptr);
131 wp->SetGeodesicGridId(cached_wp.geodesic_grid_id);
132 wp->SetIsJunction(cached_wp.is_junction);
133 wp->SetRoadOption(static_cast<RoadOption>(cached_wp.road_option));
134 dense_topology.push_back(wp);
135 }
136
137 // connect waypoints
138 for (uint32_t i=0; i < dense_topology.size(); i++) {
139 auto wp = dense_topology.at(i);
140 auto cached_wp = cached_waypoints.at(i);
141
142 std::vector<SimpleWaypointPtr> next_waypoints;
143 for (auto id : cached_wp.next_waypoints) {
144 next_waypoints.push_back(dense_topology.at(id2index.at(id)));
145 }
146 std::vector<SimpleWaypointPtr> previous_waypoints;
147 for (auto id : cached_wp.previous_waypoints) {
148 previous_waypoints.push_back(dense_topology.at(id2index.at(id)));
149 }
150 wp->SetNextWaypoint(next_waypoints);
151 wp->SetPreviousWaypoint(previous_waypoints);
152 if (cached_wp.next_left_waypoint > 0) {
153 wp->SetLeftWaypoint(dense_topology.at(id2index.at(cached_wp.next_left_waypoint)));
154 }
155 if (cached_wp.next_right_waypoint > 0) {
156 wp->SetRightWaypoint(dense_topology.at(id2index.at(cached_wp.next_right_waypoint)));
157 }
158 }
159
160 // create spatial tree
162
163 return true;
164 }
165
167
168 // 1. Building segment topology (i.e., defining set of segment predecessors and successors)
169 assert(_world_map != nullptr && "No map reference found.");
170 auto waypoint_topology = _world_map->GetTopology();
171
172 SegmentTopology segment_topology;
173 std::unordered_map<int64_t, std::pair<std::set<crd::RoadId>, std::set<crd::RoadId>>> std_road_connectivity;
174 std::unordered_map<crd::RoadId, bool> is_real_junction;
175
176 for (auto &connection : waypoint_topology) {
177 auto &waypoint = connection.first;
178 auto &successor = connection.second;
179
180 // Setting segment predecessors and successors.
181 SegmentId waypoint_segment_id = GetSegmentId(connection.first);
182 SegmentId successor_segment_id = GetSegmentId(connection.second);
183 if (waypoint_segment_id == successor_segment_id){
184 // If both topology waypoints are at the same segment, ignore them.
185 // This happens at lanes that have either no successor or predecessor connections.
186 continue;
187 }
188 using SegIdVectorPair = std::pair<std::vector<SegmentId>, std::vector<SegmentId>>;
189 SegIdVectorPair &connection_first = segment_topology[waypoint_segment_id];
190 SegIdVectorPair &connection_second = segment_topology[successor_segment_id];
191 connection_first.second.push_back(successor_segment_id);
192 connection_second.first.push_back(waypoint_segment_id);
193
194 // From path to standard road.
195 bool waypoint_is_junction = waypoint->IsJunction();
196 bool successor_is_junction = successor->IsJunction();
197 if (waypoint_is_junction && !successor_is_junction) {
198 crd::RoadId path_id = waypoint->GetRoadId();
199 int64_t std_road_id = static_cast<int64_t>(successor->GetRoadId());
200 std_road_id = (successor->GetLaneId() < 0) ? -1 * std_road_id : std_road_id;
201
202 std::set<crd::RoadId> &in_paths = std_road_connectivity[std_road_id].first;
203 in_paths.insert(path_id);
204
205 if (in_paths.size() >= 2) {
206 for (auto &in_path_id: in_paths) {
207 is_real_junction[in_path_id] = true;
208 }
209 }
210 }
211
212 // From standard road to path.
213 if (!waypoint_is_junction && successor_is_junction) {
214 crd::RoadId path_id = successor->GetRoadId();
215 int64_t std_road_id = static_cast<int64_t>(waypoint->GetRoadId());
216 std_road_id = (waypoint->GetLaneId() < 0) ? -1 * std_road_id : std_road_id;
217
218 std::set<crd::RoadId> &out_paths = std_road_connectivity[std_road_id].second;
219 out_paths.insert(path_id);
220
221 if (out_paths.size() >= 2) {
222 for (auto &out_path_id: out_paths) {
223 is_real_junction[out_path_id] = true;
224 }
225 }
226 }
227 }
228
229 // 2. Consuming the raw dense topology from cc::Map into SimpleWaypoints.
230 SegmentMap segment_map;
231 assert(_world_map != nullptr && "No map reference found.");
232 auto raw_dense_topology = _world_map->GenerateWaypoints(MAP_RESOLUTION);
233 for (auto &waypoint_ptr: raw_dense_topology) {
234 if (waypoint_ptr->GetLaneWidth() > MIN_LANE_WIDTH){
235 // Avoid making the vehicles move through very narrow lanes
236 segment_map[GetSegmentId(waypoint_ptr)].emplace_back(std::make_shared<SimpleWaypoint>(waypoint_ptr));
237 }
238 }
239
240 // 3. Processing waypoints.
241 auto distance_squared = [](cg::Location l1, cg::Location l2) {
242 return cg::Math::DistanceSquared(l1, l2);
243 };
244 auto square = [](float input) {return std::pow(input, 2);};
245 auto compare_s = [](const SimpleWaypointPtr &swp1, const SimpleWaypointPtr &swp2) {
246 return (swp1->GetWaypoint()->GetDistance() < swp2->GetWaypoint()->GetDistance());
247 };
248 auto wpt_angle = [](cg::Vector3D l1, cg::Vector3D l2) {
249 return cg::Math::GetVectorAngle(l1, l2);
250 };
251 auto max = [](int16_t x, int16_t y) {
252 return x ^ ((x ^ y) & -(x < y));
253 };
254
255 GeoGridId geodesic_grid_id_counter = -1;
256 for (auto &segment: segment_map) {
257 auto &segment_waypoints = segment.second;
258
259 // Generating geodesic grid ids.
260 ++geodesic_grid_id_counter;
261
262 // Ordering waypoints according to road direction.
263 std::sort(segment_waypoints.begin(), segment_waypoints.end(), compare_s);
264 auto lane_id = segment_waypoints.front()->GetWaypoint()->GetLaneId();
265 if (lane_id > 0) {
266 std::reverse(segment_waypoints.begin(), segment_waypoints.end());
267 }
268
269 // Adding more waypoints if the angle is too tight or if they are too distant.
270 for (std::size_t i = 0; i < segment_waypoints.size() - 1; ++i) {
271 double distance = std::abs(segment_waypoints.at(i)->GetWaypoint()->GetDistance() - segment_waypoints.at(i+1)->GetWaypoint()->GetDistance());
272 double angle = wpt_angle(segment_waypoints.at(i)->GetTransform().GetForwardVector(), segment_waypoints.at(i+1)->GetTransform().GetForwardVector());
273 int16_t angle_splits = static_cast<int16_t>(angle/MAX_WPT_RADIANS);
274 int16_t distance_splits = static_cast<int16_t>((distance*distance)/MAX_WPT_DISTANCE);
275 auto max_splits = max(angle_splits, distance_splits);
276 if (max_splits >= 1) {
277 // Compute how many waypoints do we need to generate.
278 for (uint16_t j = 0; j < max_splits; ++j) {
279 auto next_waypoints = segment_waypoints.at(i)->GetWaypoint()->GetNext(distance/(max_splits+1));
280 if (next_waypoints.size() != 0) {
281 auto new_waypoint = next_waypoints.front();
282 i++;
283 segment_waypoints.insert(segment_waypoints.begin()+static_cast<int64_t>(i), std::make_shared<SimpleWaypoint>(new_waypoint));
284 } else {
285 // Reached end of the road.
286 break;
287 }
288 }
289 }
290 }
291
292 // Placing intra-segment connections.
293 cg::Location grid_edge_location = segment_waypoints.front()->GetLocation();
294 for (std::size_t i = 0; i < segment_waypoints.size() - 1; ++i) {
295 SimpleWaypointPtr current_waypoint = segment_waypoints.at(i);
296 SimpleWaypointPtr next_waypoint = segment_waypoints.at(i+1);
297 // Assigning grid id.
298 if (distance_squared(grid_edge_location, current_waypoint->GetLocation()) >
299 square(MAX_GEODESIC_GRID_LENGTH)) {
300 ++geodesic_grid_id_counter;
301 grid_edge_location = current_waypoint->GetLocation();
302 }
303 current_waypoint->SetGeodesicGridId(geodesic_grid_id_counter);
304
305 current_waypoint->SetNextWaypoint({next_waypoint});
306 next_waypoint->SetPreviousWaypoint({current_waypoint});
307
308 }
309 segment_waypoints.back()->SetGeodesicGridId(geodesic_grid_id_counter);
310
311 // Adding simple waypoints to processed dense topology.
312 for (auto swp: segment_waypoints) {
313 // Checking whether the waypoint is in a real junction.
314 auto wpt = swp->GetWaypoint();
315 auto road_id = wpt->GetRoadId();
316 if (wpt->IsJunction() && !is_real_junction.count(road_id)) {
317 swp->SetIsJunction(false);
318 } else {
319 swp->SetIsJunction(swp->GetWaypoint()->IsJunction());
320 }
321
322 dense_topology.push_back(swp);
323 }
324 }
325
327
328 // Placing inter-segment connections.
329 for (auto &segment : segment_map) {
330 SegmentId segment_id = segment.first;
331 auto &segment_waypoints = segment.second;
332
333 auto successors = GetSuccessors(segment_id, segment_topology, segment_map);
334 auto predecessors = GetPredecessors(segment_id, segment_topology, segment_map);
335
336 segment_waypoints.front()->SetPreviousWaypoint(predecessors);
337 segment_waypoints.back()->SetNextWaypoint(successors);
338 }
339
340 // Linking lane change connections.
341 for (auto &swp : dense_topology) {
342 if (!swp->CheckJunction()) {
344 }
345 }
346
347 // Linking any unconnected segments.
348 for (auto &swp : dense_topology) {
349 if (swp->GetNextWaypoint().empty()) {
350 auto neighbour = swp->GetRightWaypoint();
351 if (!neighbour) {
352 neighbour = swp->GetLeftWaypoint();
353 }
354
355 if (neighbour) {
356 swp->SetNextWaypoint(neighbour->GetNextWaypoint());
357 for (auto next_waypoint : neighbour->GetNextWaypoint()) {
358 next_waypoint->SetPreviousWaypoint({swp});
359 }
360 }
361 }
362 }
363
364 // Specifying a RoadOption for each SimpleWaypoint
366 }
367
369 for (auto &simple_waypoint: dense_topology) {
370 if (simple_waypoint != nullptr) {
371 const cg::Location loc = simple_waypoint->GetLocation();
372 Point3D point(loc.x, loc.y, loc.z);
373 rtree.insert(std::make_pair(point, simple_waypoint));
374 }
375 }
376 }
377
379 for (auto &swp : dense_topology) {
380 std::vector<SimpleWaypointPtr> next_waypoints = swp->GetNextWaypoint();
381 std::size_t next_swp_size = next_waypoints.size();
382
383 if (next_swp_size == 0) {
384 // No next waypoint means that this is an end of the road.
385 swp->SetRoadOption(RoadOption::RoadEnd);
386 }
387
388 else if (next_swp_size > 1 || (!swp->CheckJunction() && next_waypoints.front()->CheckJunction())) {
389 // To check if we are in an actual junction, and not on an highway, we try to see
390 // if there's a landmark nearby of type Traffic Light, Stop Sign or Yield Sign.
391
392 bool found_landmark= false;
393 if (next_swp_size <= 1) {
394
395 auto all_landmarks = swp->GetWaypoint()->GetAllLandmarksInDistance(15.0);
396
397 if (all_landmarks.empty()) {
398 // Landmark hasn't been found, this isn't a junction.
399 swp->SetRoadOption(RoadOption::LaneFollow);
400 } else {
401 for (auto &landmark : all_landmarks) {
402 auto landmark_type = landmark->GetType();
403 if (landmark_type == "1000001" || landmark_type == "206" || landmark_type == "205") {
404 // We found a landmark.
405 found_landmark= true;
406 break;
407 }
408 }
409 if (!found_landmark) {
410 swp->SetRoadOption(RoadOption::LaneFollow);
411 }
412 }
413 }
414
415 // If we did find a landmark, or we are in the other case, find all waypoints
416 // in the junction and assign the correct RoadOption.
417 if (found_landmark || next_swp_size > 1) {
418 swp->SetRoadOption(RoadOption::LaneFollow);
419 for (auto &next_swp : next_waypoints) {
420 std::vector<SimpleWaypointPtr> traversed_waypoints;
421 SimpleWaypointPtr junction_end_waypoint;
422
423 if (next_swp_size > 1) {
424 junction_end_waypoint = next_swp;
425 } else {
426 junction_end_waypoint = next_waypoints.front();
427 }
428
429 while (junction_end_waypoint->CheckJunction()){
430 traversed_waypoints.push_back(junction_end_waypoint);
431 std::vector<SimpleWaypointPtr> temp = junction_end_waypoint->GetNextWaypoint();
432 if (temp.empty()) {
433 break;
434 }
435 junction_end_waypoint = temp.front();
436 }
437
438 // Calculate the angle between the first and the last point of the junction.
439 int16_t current_angle = static_cast<int16_t>(traversed_waypoints.front()->GetTransform().rotation.yaw);
440 int16_t junction_end_angle = static_cast<int16_t>(traversed_waypoints.back()->GetTransform().rotation.yaw);
441 int16_t diff_angle = (junction_end_angle - current_angle) % 360;
442 bool straight = (diff_angle < STRAIGHT_DEG && diff_angle > -STRAIGHT_DEG) ||
443 (diff_angle > 360-STRAIGHT_DEG && diff_angle <= 360) ||
444 (diff_angle < -360+STRAIGHT_DEG && diff_angle >= -360);
445 bool right = (diff_angle >= STRAIGHT_DEG && diff_angle <= 180) ||
446 (diff_angle <= -180 && diff_angle >= -360+STRAIGHT_DEG);
447
448 auto assign_option = [](RoadOption ro, std::vector<SimpleWaypointPtr> traversed_waypoints) {
449 for (auto &twp : traversed_waypoints) {
450 twp->SetRoadOption(ro);
451 }
452 };
453
454 // Assign RoadOption according to the angle.
455 if (straight) assign_option(RoadOption::Straight, traversed_waypoints);
456 else if (right) assign_option(RoadOption::Right, traversed_waypoints);
457 else assign_option(RoadOption::Left, traversed_waypoints);
458 }
459 }
460 }
461 else if (next_swp_size == 1 && swp->GetRoadOption() == RoadOption::Void) {
462 swp->SetRoadOption(RoadOption::LaneFollow);
463 }
464 }
465 }
466
468
469 Point3D query_point(loc.x, loc.y, loc.z);
470 std::vector<SpatialTreeEntry> result_1;
471
472 rtree.query(bgi::nearest(query_point, 1), std::back_inserter(result_1));
473
474 SpatialTreeEntry &closest_entry = result_1.front();
475 SimpleWaypointPtr &closest_point = closest_entry.second;
476
477 return closest_point;
478 }
479
480 NodeList InMemoryMap::GetWaypointsInDelta(const cg::Location loc, const uint16_t n_points, const float random_sample) const {
481 Point3D query_point(loc.x, loc.y, loc.z);
482
483 Point3D lower_p1(loc.x + random_sample, loc.y + random_sample, loc.z + Z_DELTA);
484 Point3D lower_p2(loc.x - random_sample, loc.y - random_sample, loc.z - Z_DELTA);
485 Point3D upper_p1(loc.x + random_sample + DELTA, loc.y + random_sample + DELTA, loc.z + Z_DELTA);
486 Point3D upper_p2(loc.x - random_sample - DELTA, loc.y - random_sample - DELTA, loc.z - Z_DELTA);
487
488 Box lower_query_box(lower_p2, lower_p1);
489 Box upper_query_box(upper_p2, upper_p1);
490
491 NodeList result;
492 uint8_t x = 0;
493 for (Rtree::const_query_iterator
494 it = rtree.qbegin(bgi::within(upper_query_box)
495 && !bgi::within(lower_query_box)
496 && bgi::satisfies([&](SpatialTreeEntry const& v) { return !v.second->CheckJunction();}));
497 it != rtree.qend();
498 ++it) {
499 x++;
500 result.push_back(it->second);
501 if (x >= n_points)
502 break;
503 }
504
505 return result;
506 }
507
511
513
514 const WaypointPtr raw_waypoint = reference_waypoint->GetWaypoint();
515 const crd::element::LaneMarking::LaneChange lane_change = raw_waypoint->GetLaneChange();
516
517 /// Cheack for transits
518 switch(lane_change)
519 {
520 /// Left transit way point present only
521 case crd::element::LaneMarking::LaneChange::Left:
522 {
523 const WaypointPtr left_waypoint = raw_waypoint->GetLeft();
524 if (left_waypoint != nullptr &&
525 left_waypoint->GetType() == crd::Lane::LaneType::Driving &&
526 (left_waypoint->GetLaneId() * raw_waypoint->GetLaneId() > 0)) {
527
528 SimpleWaypointPtr closest_simple_waypoint = GetWaypoint(left_waypoint->GetTransform().location);
529 reference_waypoint->SetLeftWaypoint(closest_simple_waypoint);
530 }
531 }
532 break;
533
534 /// Right transit way point present only
535 case crd::element::LaneMarking::LaneChange::Right:
536 {
537 const WaypointPtr right_waypoint = raw_waypoint->GetRight();
538 if(right_waypoint != nullptr &&
539 right_waypoint->GetType() == crd::Lane::LaneType::Driving &&
540 (right_waypoint->GetLaneId() * raw_waypoint->GetLaneId() > 0)) {
541
542 SimpleWaypointPtr closest_simple_waypoint = GetWaypoint(right_waypoint->GetTransform().location);
543 reference_waypoint->SetRightWaypoint(closest_simple_waypoint);
544 }
545 }
546 break;
547
548 /// Both left and right transit present
549 case crd::element::LaneMarking::LaneChange::Both:
550 {
551 /// Right transit way point
552 const WaypointPtr right_waypoint = raw_waypoint->GetRight();
553 if (right_waypoint != nullptr &&
554 right_waypoint->GetType() == crd::Lane::LaneType::Driving &&
555 (right_waypoint->GetLaneId() * raw_waypoint->GetLaneId() > 0)) {
556
557 SimpleWaypointPtr closest_simple_waypointR = GetWaypoint(right_waypoint->GetTransform().location);
558 reference_waypoint->SetRightWaypoint(closest_simple_waypointR);
559 }
560
561 /// Left transit way point
562 const WaypointPtr left_waypoint = raw_waypoint->GetLeft();
563 if (left_waypoint != nullptr &&
564 left_waypoint->GetType() == crd::Lane::LaneType::Driving &&
565 (left_waypoint->GetLaneId() * raw_waypoint->GetLaneId() > 0)) {
566
567 SimpleWaypointPtr closest_simple_waypointL = GetWaypoint(left_waypoint->GetTransform().location);
568 reference_waypoint->SetLeftWaypoint(closest_simple_waypointL);
569 }
570 }
571 break;
572
573 /// For no transit waypoint (left or right)
574 default: break;
575 }
576 }
577
579 assert(_world_map != nullptr && "No map reference found.");
580 return _world_map->GetName();
581 }
582
584 return *_world_map;
585 }
586
587
588} // namespace traffic_manager
589} // namespace carla
void Read(const std::vector< uint8_t > &content, unsigned long &start)
This class builds a discretized local map-cache.
Definition InMemoryMap.h:63
bool Load(const std::vector< uint8_t > &content)
WorldMap _world_map
Object to hold the world map received by the constructor.
Definition InMemoryMap.h:68
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.
Definition InMemoryMap.h:73
NodeList dense_topology
Structure to hold all custom waypoint objects after interpolation of sparse topology.
Definition InMemoryMap.h:71
void Save(const std::string &path)
uint32_t RoadId
Definition RoadTypes.h:15
static const float MAX_GEODESIC_GRID_LENGTH
Definition Constants.h:100
std::map< SegmentId, std::vector< SimpleWaypointPtr > > SegmentMap
Definition InMemoryMap.h:57
carla::SharedPtr< cc::Waypoint > WaypointPtr
Definition InMemoryMap.h:45
std::vector< SimpleWaypointPtr > NodeList
Definition InMemoryMap.h:47
bg::model::box< Point3D > Box
Definition InMemoryMap.h:52
bg::model::point< float, 3, bg::cs::cartesian > Point3D
Definition InMemoryMap.h:51
carla::SharedPtr< const cc::Map > WorldMap
Definition InMemoryMap.h:49
std::map< SegmentId, std::pair< std::vector< SegmentId >, std::vector< SegmentId > > > SegmentTopology
Definition InMemoryMap.h:56
std::vector< WaypointPtr > RawNodeList
std::shared_ptr< SimpleWaypoint > SimpleWaypointPtr
std::tuple< crd::RoadId, crd::LaneId, crd::SectionId > SegmentId
Definition InMemoryMap.h:55
std::vector< std::pair< WaypointPtr, WaypointPtr > > TopologyList
std::pair< Point3D, SimpleWaypointPtr > SpatialTreeEntry
Definition InMemoryMap.h:53
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133
static void log_error(Args &&... args)
Definition Logging.h:110