17 Neighbours = std::vector <std::pair<float, Agent*>>();
18 NeighboursObst = std::vector <std::pair<float, ObstacleSegment>>();
19 ORCALines = std::vector <Line>();
25 invTimeBoundaryObst = 0;
40 this->options = &options;
42 Neighbours = std::vector <std::pair<float, Agent*>>();
44 NeighboursObst = std::vector <std::pair<float, ObstacleSegment>>();
45 ORCALines = std::vector <Line>();
63 this->start = obj.start;
64 this->goal = obj.goal;
66 this->options = obj.options;
67 this->param = obj.param;
69 if(obj.planner !=
nullptr)
71 this->planner = obj.planner->
Clone();
74 Neighbours = obj.Neighbours;
75 NeighboursObst = obj.NeighboursObst;
76 ORCALines = obj.ORCALines;
77 position = obj.position;
81 invTimeBoundaryObst = obj.invTimeBoundaryObst;
82 invTimeBoundary = obj.invTimeBoundary;
83 collisions = obj.collisions;
84 collisionsObst = obj.collisionsObst;
85 maxSqObstDist = obj.maxSqObstDist;
91 if(planner !=
nullptr)
104 return ((this->position - this->goal).EuclideanNorm() < options->delta);
110 return this->
id == another.id;
116 return this->
id != another.id;
122 float sightSq = param.sightRadius * param.sightRadius;
124 if(distSq >= sightSq)
129 auto tmpit = Neighbours.begin();
130 while(tmpit != Neighbours.end() && i < param.agentsMaxNum && Neighbours[i].first < distSq)
135 if(i < param.agentsMaxNum)
137 Neighbours.insert(tmpit,std::pair<float, Agent *>(distSq, &neighbour));
157 NeighboursObst.clear();
158 std::vector<std::vector<ObstacleSegment>> tmpObstacles = map->GetObstacles();
161 for(
int i = 0; i < tmpObstacles.size(); i++)
163 for(
int j = 0; j < tmpObstacles[i].size(); j++)
167 if(distSq < maxSqObstDist)
169 NeighboursObst.push_back({distSq, tmpObstacles[i][j]});
174 std::sort(NeighboursObst.begin(), NeighboursObst.end(), Utils::Less<ObstacleSegment>);
186 return {collisions, collisionsObst};
192 return planner->CreateGlobalPath();
216 position = obj.position;
221 invTimeBoundaryObst = obj.invTimeBoundaryObst;
222 invTimeBoundary = obj.invTimeBoundary;
223 maxSqObstDist = obj.maxSqObstDist;
224 collisions = obj.collisions;
225 collisionsObst = obj.collisionsObst;
226 ORCALines = obj.ORCALines;
227 NeighboursObst = obj.NeighboursObst;
228 Neighbours = obj.Neighbours;
229 options = obj.options;
231 if(planner !=
nullptr)
236 planner = (obj.planner ==
nullptr) ?
nullptr : obj.planner->
Clone();;
bool operator==(const Agent &another) const
Comparisons operator. Compares id of agents.
Agent & operator=(const Agent &obj)
Assignment operator.
virtual ~Agent()
Virtual destructor.
Point GetStart() const
Returns start of agent. For ROS Simulation purposes.
virtual bool isFinished()
Checks, what the agent is on finish. To achieve finish agent should be at least in delta distance fro...
float radius
Size of the agent (radius of the agent).
The Point class defines a position (or euclidean vector from (0,0)) in 2D space.
float timeBoundaryObst
Time within which ORCA algorithm ensures collision avoidance with neighbor obstacles.
int agentsMaxNum
Number of neighbors, that the agent takes into account.
int GetID() const
Returns identifier of agent.
Class AgentParam contains agent and algoritms parameters.
virtual Agent * Clone() const =0
Abstract method for cloning inheritors objects. Implementations of this method should create copy of ...
float GetRadius() const
Returns radius of agent.
Agent class implements base agent interface and behavior.
bool operator!=(const Agent &another) const
Comparisons operator. Compares id of agents.
float timeBoundary
Time within which ORCA algorithm ensures collision avoidance with neighbor agents.
Point GetPosition() const
Returns current position of Agent.
void UpdateNeighbourObst()
Computes neighbouring obstacles.
Class EnvironmentOptions contains environment and algoritms parameters.
virtual void SetVelocity(const Point &vel)
Sets current velocity. Should be used if the new velocity may not coincide with the computed...
Map class describes static environment.
float maxSpeed
Maximum speed of agent.
AgentParam GetParam() const
Returns parameters of agent. For ROS Simulation purposes.
std::pair< unsigned int, unsigned int > GetCollision() const
Returns collisions count. For debug purposes.
Point GetGoal() const
Returns goal of agent. For ROS Simulation purposes.
bool InitPath()
Starts pathfinding from start to goal position.
File contains Agent class and AgentParam class.
Agent()
Agent default constructor.
virtual void AddNeighbour(Agent &neighbour, float distSq)
Adds new neighbour. Only agents inside sight radius will be adeed. Can be ovveriden.
float SqPointSegDistance(Point L1, Point L2, Point P)
Computes squared euclidean distance from point to line segment.
Point GetNext() const
Returns current goal of agent. For debug purposes.
virtual void SetPosition(const Point &pos)
SetsS current position of agent. Can be ovveriden.
Point GetVelocity() const
Returns current velocity of agent.