Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

simulator.h 1.43 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef SIMULATOR_H
#define SIMULATOR_H

#include <limits>

#include "env_map.h"
#include "agent.h"
#include "path_finder.h"

#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class ThreadUpdateInfo
{
public :
	std::vector<Agent*> ag_;
	unsigned int bMin_;
	unsigned int bMax_;

	// Constructor
	ThreadUpdateInfo(std::vector<Agent*> agents, unsigned int bMin, unsigned int bMax) :
		bMin_(bMin),
		bMax_(bMax)
	{
		ag_.insert(ag_.end(), agents.begin() + bMin, agents.begin() + bMax);
	}

	// Destructor
	~ThreadUpdateInfo() { }

	void run()
	{
	    // Thread execution stuff goes here
		for (unsigned int i = 0; i < ag_.size(); ++i)
		{
			ag_[i]->updateObstacleNeighbors();
			ag_[i]->updateAgentNeighbors();
			ag_[i]->computePrefVelocity();
			ag_[i]->computeNewVelocity();
		}
	}
};

Pierre Kraemer's avatar
Pierre Kraemer committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class Simulator
{
public:
	Simulator();
	
	Simulator(
		float timeStep, float neighborDist, unsigned int maxNeighbors,
		float timeHorizon, float timeHorizonObst, float radius,
		float maxSpeed, const VEC3& velocity = VEC3(0)
	);
	
	~Simulator();
	
	void doStep();
	
61
	void setupScenario(unsigned int nbMaxAgent);
62
	void addPathsToAgents();
Pierre Kraemer's avatar
Pierre Kraemer committed
63
64
65
66
67
68
69
70
71
72
73
	
	bool importAgents(std::string filename);
	bool exportAgents(std::string filename);
	
	void swapAgentsGoals();
	
	EnvMap envMap_;
	std::vector<Agent*> agents_;
	
	float globalTime_;
	float timeStep_;
74
75
76
77
78

	ThreadUpdateInfo* tc1;
	ThreadUpdateInfo* tc2;
	ThreadUpdateInfo* tc3;
	ThreadUpdateInfo* tc4;
Pierre Kraemer's avatar
Pierre Kraemer committed
79
80
81
};

#endif