Commit 1f604271 authored by Ulrich Kemloh's avatar Ulrich Kemloh

events paramter are not longer hardcoded

but read from the event file
update_frequency="2" 
update_radius="1" 
agents_color_by_knowledge="true"
parent 07b37047
......@@ -198,19 +198,28 @@ bool EventManager::UpdateAgentKnowledge(Building* _b)
{
for (auto&& door: _b->GetAllTransitions())
{
if(door.second->DistTo(ped->GetPos())<0.5) //TODO: put 0.c metre in macro
if(door.second->DistTo(ped->GetPos())<0.5)//distance to door to register its state
{
//actualize the information about the newly closed door
if(door.second->IsOpen()==false)
{
ped->AddKnownClosedDoor(door.first, Pedestrian::GetGlobalTime());
ped->SetSpotlight(true);
ped->SetNewEventFlag(true);
}
}
}
}
for(auto&& ped1:_b->GetAllPedestrians())
//collect the peds that are allowed to forward the information.
vector<Pedestrian*> informant;
for(auto&& ped:_b->GetAllPedestrians())
{
if (ped->GetNewEventFlag())informant.push_back(ped);
}
//TODO: what happen when they all have the new event flag ? reset maybe?
for(auto&& ped1:informant)
{
vector<Pedestrian*> neighbourhood;
_b->GetGrid()->GetNeighbourhood(ped1,neighbourhood);
......@@ -219,12 +228,29 @@ bool EventManager::UpdateAgentKnowledge(Building* _b)
if( (ped1->GetPos()-ped2->GetPos()).Norm()<_updateRadius)
{
//maybe same room and subroom ?
//if(_b->IsVisible(ped1->GetPos(),ped2->GetPos()))
if(_b->IsVisible(ped1->GetPos(),ped2->GetPos()))
MergeKnowledge(ped1, ped2); //ped1->SetSpotlight(true);
ped2->SetNewEventFlag(true);
}
}
}
// information speed to fast
// for(auto&& ped1:_b->GetAllPedestrians())
// {
// vector<Pedestrian*> neighbourhood;
// _b->GetGrid()->GetNeighbourhood(ped1,neighbourhood);
// for(auto&& ped2:neighbourhood)
// {
// if( (ped1->GetPos()-ped2->GetPos()).Norm()<_updateRadius)
// {
// //maybe same room and subroom ?
// if(_b->IsVisible(ped1->GetPos(),ped2->GetPos()))
// MergeKnowledge(ped1, ped2); //ped1->SetSpotlight(true);
// }
// }
// }
//update the routers based on the configurations
//#pragma omp parallel
for(auto&& ped:_b->GetAllPedestrians())
......@@ -234,6 +260,7 @@ bool EventManager::UpdateAgentKnowledge(Building* _b)
//Clear the memory and attempt to reroute
//this can happen if all doors are known to be closed
ped->ClearKnowledge();
Log->Write("ERROR: \t clearing ped knowledge");
if(UpdateRoute(ped)==false)
{
Log->Write("ERROR: \t cannot reroute the pedestrian. unknown problem");
......@@ -261,6 +288,8 @@ bool EventManager::UpdateRoute(Pedestrian* ped)
Router*rout =engine->GetRouter(strategy);
//check for validity
ped->SetRouter(rout);
//clear all previous routes
ped->ClearMentalMap();
//overwrite/update the pedestrian router
if(!rout) status= false;
}
......@@ -296,7 +325,7 @@ void EventManager::MergeKnowledge(Pedestrian* p1, Pedestrian* p2)
merge_info[info2.first]=info2.second;
}
}
else //just add
else //the info was not present, just add
{
merge_info[info2.first]=info2.second;
}
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JPScore project="JPS-Project" version="0.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/jps_events.xsd">
<events>
<event time="1" type="door" state="close" id="8" caption="left_exit" />
<event time="10" type="door" state="open" id="8" caption="left_exit" />
<event time="25" type="door" state="close" id="4" caption="main_exit" />
<event time="40" type="door" state="open" id="4" caption="main_exit" />
<event time="70" type="door" state="close" id="8" caption="main_exit" />
<events update_frequency="2" update_radius="1" agents_color_by_knowledge="true">
<event time="15" type="door" state="close" id="8" caption="left_exit" />
<event time="50" type="door" state="open" id="8" caption="left_exit" />
<event time="50" type="door" state="close" id="4" caption="main_exit" />
<event time="100" type="door" state="open" id="4" caption="main_exit" />
<event time="370" type="door" state="open" id="8" caption="main_exit" />
</events>
</JPScore>
\ No newline at end of file
</JPScore>
<!-- <JPScore project="JPS-Project" version="0.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/jps_events.xsd"> -->
<!-- <events update_frequency="1" update_radius="2" agents_color_by_knowledge="true"> -->
<!-- <event time="1" type="door" state="close" id="8" caption="left_exit" /> -->
<!-- <event time="10" type="door" state="open" id="8" caption="left_exit" /> -->
<!-- <event time="25" type="door" state="close" id="4" caption="main_exit" /> -->
<!-- <event time="40" type="door" state="open" id="4" caption="main_exit" /> -->
<!-- <event time="370" type="door" state="close" id="8" caption="main_exit" /> -->
<!-- </events> -->
<!-- </JPScore> -->
\ No newline at end of file
......@@ -9,9 +9,9 @@
<max_sim_time>900</max_sim_time>
<events>events.xml</events>
<!-- trajectories file and format -->
<trajectories format="xml-plain" embed_mesh="false" fps="8">
<trajectories format="xml-plain" fps="8">
<file location="testSchulTrajectories.xml" />
<!-- <socket hostname="127.0.0.1" port="8989"/> -->
<!-- <socket hostname="127.0.0.1" port="8989"/> -->
</trajectories>
<!-- where to store the logs -->
<!--<logfile>outputfiles/log.txt</logfile> -->
......
......@@ -764,8 +764,9 @@ void Pedestrian::Dump(int ID, int pa)
break;
case 7:
printf(">> knowledge\n");
for(auto&& item:_knownDoors)
printf("\t door [%d] closed since [%lf] sec\n",item.first, item.second.GetTime());
printf("\t door [%d] closed since [%.2f] sec\n",item.first, _globalTime-item.second.GetTime());
break;
default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment