7 namespace traffic_manager {
15 const std::vector<SimpleWaypointPtr> waypoints) {
19 std::unordered_set<GeoGridId> current_grids;
21 for (
auto &waypoint : waypoints) {
24 GeoGridId ggid = waypoint->GetGeodesicGridId();
25 current_grids.insert(ggid);
29 if (actor_ids.find(actor_id) == actor_ids.end()) {
30 actor_ids.insert(actor_id);
41 if (!buffer.empty()) {
45 std::unordered_set<GeoGridId> ¤t_grids =
actor_to_grids.at(actor_id);
46 for (
auto &grid_id : current_grids) {
49 actor_ids.erase(actor_id);
57 std::unordered_set<GeoGridId> current_grids;
58 uint64_t buffer_size = buffer.size();
59 for (uint64_t i = 0u; i <= buffer_size - 1u; ++i) {
60 auto waypoint = buffer.at(i);
61 GeoGridId ggid = waypoint->GetGeodesicGridId();
62 current_grids.insert(ggid);
69 if (actor_ids.find(actor_id) == actor_ids.end()) {
70 actor_ids.insert(actor_id);
105 const std::unordered_set<GeoGridId> &grid_ids =
actor_to_grids.at(actor_id);
106 for (
auto &grid_id : grid_ids) {
109 actor_id_set.insert(actor_ids.begin(), actor_ids.end());
119 std::unordered_set<GeoGridId> &grid_ids =
actor_to_grids.at(actor_id);
120 for (
auto &grid_id : grid_ids) {
123 actor_ids.erase(actor_id);
131 for (
const uint64_t &waypoint_id : waypoint_id_set) {
140 if (actor_id_set.find(actor_id) == actor_id_set.end()) {
141 actor_id_set.insert(actor_id);
149 if (waypoint_id_set.find(waypoint_id) == waypoint_id_set.end()) {
150 waypoint_id_set.insert(waypoint_id);
160 actor_id_set.erase(actor_id);
162 if (actor_id_set.size() == 0) {
169 waypoint_id_set.erase(waypoint_id);
171 if (waypoint_id_set.size() == 0) {
static const uint64_t BUFFER_STEP_THROUGH
cg::Location hero_location
Current hero location.
std::unordered_set< uint64_t > WaypointIdSet
Structure to keep track of waypoints occupied by vehicles;.
void SetHeroLocation(const cg::Location location)
void UpdatePassingVehicle(uint64_t waypoint_id, ActorId actor_id)
Methods to update, remove and retrieve vehicles passing through a waypoint.
void UpdateGridPosition(const ActorId actor_id, const Buffer &buffer)
This file contains definitions of common data structures used in traffic manager. ...
std::unordered_set< ActorId > ActorIdSet
std::deque< std::shared_ptr< SimpleWaypoint > > Buffer
void RemovePassingVehicle(uint64_t waypoint_id, ActorId actor_id)
std::unordered_map< GeoGridId, ActorIdSet > grid_to_actors
Actors currently passing through grids.
void UpdateUnregisteredGridPosition(const ActorId actor_id, const std::vector< SimpleWaypointPtr > waypoints)
static const float INV_BUFFER_STEP_THROUGH
WaypointOverlap waypoint_overlap_tracker
ActorIdSet GetOverlappingVehicles(ActorId actor_id) const
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)
cg::Location GetHeroLocation() const
bool IsGeoGridFree(const GeoGridId geogrid_id) const
ActorIdSet GetPassingVehicles(uint64_t waypoint_id) const
std::unordered_map< ActorId, std::unordered_set< GeoGridId > > actor_to_grids
Geodesic grids occupied by actors's paths.