Commit 91a2f25b authored by pitiot's avatar pitiot

correction obstacles + timings + #define RVO2

parent c8122245
......@@ -142,6 +142,9 @@ public:
ThreadUpdateInfo* tc2 ;
ThreadUpdateInfo* tc3 ;
ThreadUpdateInfo* tc4 ;
long int time_agent;
long int time_obstacle;
};
#endif
......@@ -167,6 +167,8 @@ public:
Utils::QT::uiDockInterface dock ;
QTimer* timer ;
time_t elapsedTime;
long int time_update;
/* nbIterations counts the current number of iterations
* When maxIterations is reached the simulation is stopped
......@@ -208,6 +210,7 @@ public:
unsigned int agentSlider;
int posXSlider;
int posYSlider;
bool display_times;
public slots:
void animate() ;
......@@ -215,6 +218,7 @@ public slots:
void slot_timer(bool b)
{
b ? timer->start() : timer->stop() ;
display_times =b;
}
void slot_drawEnvLines(bool b)
{
......
This diff is collapsed.
......@@ -875,7 +875,10 @@ void EnvMap::pushObstacleInOneRingCells(Obstacle * o, Dart d, int n)
Dart ddd = map.alpha1(map.alpha1(dd));
while(ddd != dd)
{
pushObstNeighborInCells(o, ddd);
if (!map.isBoundaryMarked2(ddd))
{
pushObstNeighborInCells(o, ddd);
}
mo->neighbor_cells[n].push_back(ddd);
ddd = map.alpha1(ddd);
......@@ -900,7 +903,9 @@ void EnvMap::pushObstacleInCells(Obstacle* o, int n, const std::vector<Dart>& me
for (std::vector<Dart>::iterator it = mo->belonging_cells[n].begin(); it != mo->belonging_cells[n].end(); ++it)
{
// CGoGNout <<"obstacle"<< o->p1 << "new cell : "<< *it << CGoGNendl;
addElementToVector<Obstacle*>(obstvect[*it],o);
addElementToVector<Obstacle*>(obstvect[*it],o);
}
addObstAsNeighbor(o, mo->belonging_cells[n], &(mo->neighbor_cells[n]));
......@@ -908,7 +913,10 @@ void EnvMap::pushObstacleInCells(Obstacle* o, int n, const std::vector<Dart>& me
for (std::vector<Dart>::iterator it = mo->neighbor_cells[n].begin(); it != mo->neighbor_cells[n].end(); ++it)
{
// CGoGNout <<"obstacle"<< o->p1 << "new cell : "<< *it << CGoGNendl;
addElementToVector<Obstacle*>(neighborObstvect[*it],o);
if (!map.isBoundaryMarked2(*it))
{
addElementToVector<Obstacle*>(neighborObstvect[*it],o);
}
// pushObstNeighborInCells(o, *it);
}
}
......@@ -928,7 +936,10 @@ void EnvMap::popObstacleInCells(Obstacle* o, int n)
for (std::vector<Dart>::iterator it = mo->neighbor_cells[n].begin(); it != mo->neighbor_cells[n].end(); ++it)
{
removeElementFromVector<Obstacle*>(neighborObstvect[*it], o) ;
if (!map.isBoundaryMarked2(*it))
{
removeElementFromVector<Obstacle*>(neighborObstvect[*it], o) ;
}
}
mo->belonging_cells[n].clear();
mo->neighbor_cells[n].clear();
......
......@@ -552,7 +552,7 @@ void MovingObstacle::update()
{
assert(sim_->envMap_.map.getCurrentLevel() == sim_->envMap_.map.getMaxLevel()) ;
///////remise a zero
// if(sim_->detect_agent_collision)
if(sim_->detect_agent_collision)
general_belonging.clear();
//pour les tests de détection///////////////
if(!seen)
......@@ -745,13 +745,13 @@ void MovingObstacle::update()
}
// if(sim_->detect_agent_collision)
// {
if(sim_->detect_agent_collision)
{
for (std::vector<Dart>::iterator it = belonging_cells[i].begin(); it != belonging_cells[i].end(); ++it)
{
general_belonging.insert(*it);
}
// }
}
// CGoGNout << "Apres une etape : Obstacle "<< i << CGoGNendl;
}
......
......@@ -14,7 +14,9 @@ Simulator::Simulator(unsigned int config, unsigned int minS, unsigned int nbAgen
nearNeighbors(0),
totalNeighbors(0),
avoidance(1),
nb_dead(0)
nb_dead(0),
time_agent(0),
time_obstacle(0)
{
minSize=minS;
multires=resolution;
......@@ -105,11 +107,13 @@ void Simulator::doStep()
envMap_.clearUpdateCandidates() ;
envMap_.map.setCurrentLevel(envMap_.map.getMaxLevel()) ;
#endif
unsigned long begTime, endTime;
begTime=clock() ;
for (unsigned int i = 0 ; i < movingObstacles_.size() ; ++i)
{
movingObstacles_[i]->computePrefVelocity() ;
movingObstacles_[i]->computeNewVelocity() ;
movingObstacles_[i]->updateAgentNeighbors();
movingObstacles_[i]->updateObstacleNeighbors();
#ifndef SPATIAL_HASHING
......@@ -120,11 +124,14 @@ void Simulator::doStep()
// commente par Arash
movingObstacles_[i]->updateMesh() ;
}
endTime=clock() ;
time_obstacle+= endTime-begTime;
begTime=clock() ;
for (unsigned int i = 0 ; i < agents_.size() ; ++i)
{
if (agents_[i]->alive)
{
agents_[i]->updateObstacleNeighbors() ;
#ifndef SPATIAL_HASHING
......@@ -179,6 +186,8 @@ void Simulator::doStep()
nb_dead++ ;
}
endTime=clock() ;
time_agent+= endTime-begTime;
nbRefineCandidate += envMap_.refineCandidate.size() ;
nbCoarsenCandidate += envMap_.coarsenCandidate.size() ;
......@@ -223,7 +232,7 @@ void Simulator::setupCircleScenario(unsigned int nbAgents , unsigned int nbObsta
envMap_.init(config, 2000.0f, 2000.0f, minSize, 400.0f) ; //cases fines
}
std::cout << " - Setup Circle Scenario : " << nbAgents << " agents" << std::endl ;
std::cout << " - Setup Circle Scenario : " << nbAgents << " agents et " << nbObstacles << " obstacles"<< std::endl ;
// Bordure à éviter autour de la scène (10% de sa taille)
int xBorder = envMap_.geometry.size(0) / 10 ;
......
......@@ -56,9 +56,12 @@ SocialAgents::SocialAgents(unsigned int config, unsigned int minSize, unsigned i
draw_dart(false),
target_Agent(false),
draw_posX(false),
draw_elipse(false)
draw_elipse(false),
display_times(false)
{
timer = new QTimer(this) ;
time_update = 0 ;
elapsedTime = 0;
connect(timer, SIGNAL(timeout()), this, SLOT(animate())) ;
clock_gettime(CLOCK_MONOTONIC, &startTime) ;
......@@ -847,8 +850,20 @@ void SocialAgents::cb_redraw()
++frames ;
struct timespec realTime ;
clock_gettime(CLOCK_MONOTONIC, &realTime) ;
time_t elapsedTime = realTime.tv_sec - startTime.tv_sec ;
if(nbIterations == maxIterations -1) CGoGNout << "temps mis pour "<<maxIterations<< " : "<< elapsedTime<<CGoGNendl;
elapsedTime += realTime.tv_sec - startTime.tv_sec ;
clock_gettime(CLOCK_MONOTONIC, &startTime) ;
if(display_times)
{
CGoGNout <<CGoGNendl;
CGoGNout << "temps mis pour "<<nbIterations<< " : "<< elapsedTime<<CGoGNendl;
CGoGNout << "temps mis pour l'affichage : "<< (float)elapsedTime - (((float)time_update)/CLOCKS_PER_SEC)<<CGoGNendl;
CGoGNout << "temps mis pour le DoStep : "<< (((float)time_update)/CLOCKS_PER_SEC)<<CGoGNendl;
CGoGNout << "temps mis pour les Agents : "<< (((float) simulator.time_agent)/CLOCKS_PER_SEC)<<CGoGNendl;
CGoGNout << "temps mis pour les Agents Polygonaux : "<< (((float)simulator.time_obstacle)/CLOCKS_PER_SEC)<<CGoGNendl;
CGoGNout << "temps mis pour la multirésolution : "<<(((float)time_update)/CLOCKS_PER_SEC) - (((float) simulator.time_agent)/CLOCKS_PER_SEC) - (((float)simulator.time_obstacle)/CLOCKS_PER_SEC)<<CGoGNendl;
CGoGNout <<CGoGNendl;
display_times= false;
}
if (elapsedTime >= nextUpdate)
{
// Sortie des stats pour analyse externe
......@@ -1009,7 +1024,11 @@ void SocialAgents::animate()
timer->stop() ;
exit(0) ;
}
unsigned long begTime =clock() ;
simulator.doStep() ;
unsigned long endTime =clock() ;
time_update += (endTime - begTime);
m_positionVBO->updateData(simulator.envMap_.position);
......
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