7namespace 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) {
void UpdatePassingVehicle(uint64_t waypoint_id, ActorId actor_id)
Methods to update, remove and retrieve vehicles passing through a waypoint.
cg::Location GetHeroLocation() const
std::unordered_map< ActorId, std::unordered_set< GeoGridId > > actor_to_grids
Geodesic grids occupied by actors's paths.
WaypointOverlap waypoint_overlap_tracker
void UpdateGridPosition(const ActorId actor_id, const Buffer &buffer)
ActorIdSet GetPassingVehicles(uint64_t waypoint_id) const
cg::Location hero_location
Current hero location.
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)
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.
static const uint64_t BUFFER_STEP_THROUGH
static const float INV_BUFFER_STEP_THROUGH
std::deque< std::shared_ptr< SimpleWaypoint > > Buffer
std::unordered_set< ActorId > ActorIdSet
This file contains definitions of common data structures used in traffic manager.