CARLA
 
载入中...
搜索中...
未找到
TrackTraffic.h
浏览该文件的文档.
1
2#pragma once
3
5#include "carla/rpc/ActorId.h"
6
8
9namespace carla {
10namespace traffic_manager {
11
13using ActorIdSet = std::unordered_set<ActorId>;
14using SimpleWaypointPtr = std::shared_ptr<SimpleWaypoint>;
15using Buffer = std::deque<SimpleWaypointPtr>;
17
18// This class is used to track the waypoint occupancy of all the actors.
20
21private:
22 /// Structure to keep track of overlapping waypoints between vehicles.
23 using WaypointOverlap = std::unordered_map<uint64_t, ActorIdSet>;
25
26 /// Structure to keep track of waypoints occupied by vehicles;
27 using WaypointIdSet = std::unordered_set<uint64_t>;
28 using WaypointOccupancyMap = std::unordered_map<ActorId, WaypointIdSet>;
30
31 /// Geodesic grids occupied by actors's paths.
32 std::unordered_map<ActorId, std::unordered_set<GeoGridId>> actor_to_grids;
33 /// Actors currently passing through grids.
34 std::unordered_map<GeoGridId, ActorIdSet> grid_to_actors;
35 /// Current hero location.
37
38
39public:
41
42 /// Methods to update, remove and retrieve vehicles passing through a waypoint.
43 void UpdatePassingVehicle(uint64_t waypoint_id, ActorId actor_id);
44 void RemovePassingVehicle(uint64_t waypoint_id, ActorId actor_id);
45 ActorIdSet GetPassingVehicles(uint64_t waypoint_id) const;
46
47 void UpdateGridPosition(const ActorId actor_id, const Buffer &buffer);
48 void UpdateUnregisteredGridPosition(const ActorId actor_id,
49 const std::vector<SimpleWaypointPtr> waypoints);
50
52 bool IsGeoGridFree(const GeoGridId geogrid_id) const;
53 void AddTakenGrid(const GeoGridId geogrid_id, const ActorId actor_id);
54
55 void SetHeroLocation(const cg::Location location);
57
58
59 /// Method to delete actor data from tracking.
60 void DeleteActor(ActorId actor_id);
61
62 void Clear();
63};
64
65} // namespace traffic_manager
66} // namespace carla
void UpdatePassingVehicle(uint64_t waypoint_id, ActorId actor_id)
Methods to update, remove and retrieve vehicles passing through a waypoint.
std::unordered_map< ActorId, std::unordered_set< GeoGridId > > actor_to_grids
Geodesic grids occupied by actors's paths.
void UpdateGridPosition(const ActorId actor_id, const Buffer &buffer)
ActorIdSet GetPassingVehicles(uint64_t waypoint_id) const
cg::Location hero_location
Current hero location.
std::unordered_map< uint64_t, ActorIdSet > WaypointOverlap
Structure to keep track of overlapping waypoints between vehicles.
ActorIdSet GetOverlappingVehicles(ActorId actor_id) const
bool IsGeoGridFree(const GeoGridId geogrid_id) const
std::unordered_set< uint64_t > WaypointIdSet
Structure to keep track of waypoints occupied by vehicles;
void UpdateUnregisteredGridPosition(const ActorId actor_id, const std::vector< SimpleWaypointPtr > waypoints)
std::unordered_map< ActorId, WaypointIdSet > WaypointOccupancyMap
void RemovePassingVehicle(uint64_t waypoint_id, ActorId actor_id)
void DeleteActor(ActorId actor_id)
Method to delete actor data from tracking.
WaypointOccupancyMap waypoint_occupied
void AddTakenGrid(const GeoGridId geogrid_id, const ActorId actor_id)
void SetHeroLocation(const cg::Location location)
std::unordered_map< GeoGridId, ActorIdSet > grid_to_actors
Actors currently passing through grids.
int32_t JuncId
Definition RoadTypes.h:17
std::deque< std::shared_ptr< SimpleWaypoint > > Buffer
std::shared_ptr< SimpleWaypoint > SimpleWaypointPtr
std::unordered_set< ActorId > ActorIdSet
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133
rpc::ActorId ActorId
Definition ActorId.h:18