CARLA
 
载入中...
搜索中...
未找到
CollisionStage.h
浏览该文件的文档.
1
2#pragma once
3
4#include <memory>
5
6#if defined(__clang__)
7# pragma clang diagnostic push
8# pragma clang diagnostic ignored "-Wshadow"
9#endif
10#include "boost/geometry.hpp"
11#include "boost/geometry/geometries/geometries.hpp"
12#include "boost/geometry/geometries/point_xy.hpp"
13#include "boost/geometry/geometries/polygon.hpp"
14#if defined(__clang__)
15# pragma clang diagnostic pop
16#endif
17
23
24namespace carla {
25namespace traffic_manager {
26
33
39using CollisionLockMap = std::unordered_map<ActorId, CollisionLock>;
40
41namespace cc = carla::client;
42namespace bg = boost::geometry;
43
44using Buffer = std::deque<std::shared_ptr<SimpleWaypoint>>;
45using BufferMap = std::unordered_map<carla::ActorId, Buffer>;
46using LocationVector = std::vector<cg::Location>;
47using GeodesicBoundaryMap = std::unordered_map<ActorId, LocationVector>;
48using GeometryComparisonMap = std::unordered_map<uint64_t, GeometryComparison>;
49using Polygon = bg::model::polygon<bg::model::d2::point_xy<double>>;
50
51/// This class has functionality to detect potential collision with a nearby actor.
53private:
54 const std::vector<ActorId> &vehicle_id_list;
60 // Structure keeping track of blocking lead vehicles.
62 // Structures to cache geodesic boundaries of vehicle and
63 // comparision between vehicle boundaries
64 // to avoid repeated computation within a cycle.
68
69 // Method to determine if a vehicle is on a collision path to another.
70 std::pair<bool, float> NegotiateCollision(const ActorId reference_vehicle_id,
71 const ActorId other_actor_id,
72 const uint64_t reference_junction_look_ahead_index);
73
74 // Method to calculate bounding box extention length ahead of the vehicle.
75 float GetBoundingBoxExtention(const ActorId actor_id);
76
77 // Method to calculate polygon points around the vehicle's bounding box.
78 LocationVector GetBoundary(const ActorId actor_id);
79
80 // Method to construct polygon points around the path boundary of the vehicle.
82
83 Polygon GetPolygon(const LocationVector &boundary);
84
85 // Method to compare path boundaries, bounding boxes of vehicles
86 // and cache the results for reuse in current update cycle.
87 GeometryComparison GetGeometryBetweenActors(const ActorId reference_vehicle_id,
88 const ActorId other_actor_id);
89
90 // Method to draw path boundary.
91 void DrawBoundary(const LocationVector &boundary);
92
93public:
94 CollisionStage(const std::vector<ActorId> &vehicle_id_list,
96 const BufferMap &buffer_map,
101
102 void Update (const unsigned long index) override;
103
104 void RemoveActor(const ActorId actor_id) override;
105
106 void Reset() override;
107
108 // Method to flush cache for current update cycle.
109 void ClearCycleCache();
110};
111
112} // namespace traffic_manager
113} // namespace carla
This class has functionality to detect potential collision with a nearby actor.
CollisionStage(const std::vector< ActorId > &vehicle_id_list, const SimulationState &simulation_state, const BufferMap &buffer_map, const TrackTraffic &track_traffic, const Parameters &parameters, CollisionFrame &output_array, RandomGenerator &random_device)
const std::vector< ActorId > & vehicle_id_list
const SimulationState & simulation_state
GeometryComparison GetGeometryBetweenActors(const ActorId reference_vehicle_id, const ActorId other_actor_id)
LocationVector GetGeodesicBoundary(const ActorId actor_id)
Polygon GetPolygon(const LocationVector &boundary)
void RemoveActor(const ActorId actor_id) override
void DrawBoundary(const LocationVector &boundary)
LocationVector GetBoundary(const ActorId actor_id)
float GetBoundingBoxExtention(const ActorId actor_id)
void Update(const unsigned long index) override
std::pair< bool, float > NegotiateCollision(const ActorId reference_vehicle_id, const ActorId other_actor_id, const uint64_t reference_junction_look_ahead_index)
This class holds the state of all the vehicles in the simlation.
Stage type interface.
Definition Stage.h:12
std::unordered_map< ActorId, LocationVector > GeodesicBoundaryMap
std::deque< std::shared_ptr< SimpleWaypoint > > Buffer
std::vector< CollisionHazardData > CollisionFrame
std::unordered_map< ActorId, CollisionLock > CollisionLockMap
std::vector< cg::Location > LocationVector
std::unordered_map< carla::ActorId, Buffer > BufferMap
bg::model::polygon< bg::model::d2::point_xy< double > > Polygon
std::unordered_map< uint64_t, GeometryComparison > GeometryComparisonMap
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133