Skip to content
Snippets Groups Projects
Commit 23d09e20 authored by Tobias Schrödter's avatar Tobias Schrödter
Browse files

FF now navigates from waiting area to final goal

parent 3d913f77
Branches
Tags
No related merge requests found
...@@ -101,5 +101,18 @@ void WaitingArea::setWaitingTime(double waitingTime) ...@@ -101,5 +101,18 @@ void WaitingArea::setWaitingTime(double waitingTime)
std::vector<Line> WaitingArea::getAllLines() std::vector<Line> WaitingArea::getAllLines()
{ {
}
int WaitingArea::GetNextGoal()
{
double random = std::rand()/RAND_MAX;
double cumProb = 0.;
for (auto& nextGoal : nextGoals){
cumProb += nextGoal.second;
if (random <= cumProb ){
return nextGoal.first;
}
}
} }
\ No newline at end of file
...@@ -66,6 +66,8 @@ public: ...@@ -66,6 +66,8 @@ public:
std::vector<Line> getAllLines(); std::vector<Line> getAllLines();
int GetNextGoal();
private: private:
void updateProbabilities(); void updateProbabilities();
bool checkProbabilities(); bool checkProbabilities();
......
...@@ -487,10 +487,12 @@ int FFRouterTrips::FindExit(Pedestrian* ped) ...@@ -487,10 +487,12 @@ int FFRouterTrips::FindExit(Pedestrian* ped)
// yes: set next goal and return findExit(p) // yes: set next goal and return findExit(p)
if (subroom->IsInSubRoom(goal->GetCentroid())){ if (subroom->IsInSubRoom(goal->GetCentroid())){
std::cout << "Ped and Goal in same subroom: " << subroom->IsInSubRoom(goal->GetCentroid()) << std::endl; std::cout << "Ped and Goal in same subroom: " << subroom->IsInSubRoom(goal->GetCentroid()) << std::endl;
int bestDoor = 31; std::cout << "Ped Final Destination before: " << ped->GetFinalDestination() << std::endl;
ped->SetExitIndex(bestDoor); if(WaitingArea* wa = dynamic_cast<WaitingArea*>(goal)) {
ped->SetExitLine(_CroTrByUID.at(bestDoor)); ped->SetFinalDestination(wa->GetNextGoal());
}
std::cout << "Ped Final Destination after: " << ped->GetFinalDestination() << std::endl;
ret = FindExit1(ped);
}else{ }else{
ret = FindExit1(ped); ret = FindExit1(ped);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment