O --- O
libPEDSIM Documentation
[HOME] [EXAMPLES] [ECOSYSTEM] [DOCUMENTATION] [DOWNLOAD]
O --- O
Public Types | Public Member Functions | Protected Attributes | List of all members
Ped::Tagent Class Reference

#include <ped_agent.h>

Public Types

enum  WaypointBehavior { BEHAVIOR_CIRCULAR = 0, BEHAVIOR_ONCE = 1 }
 

Public Member Functions

 Tagent ()
 
virtual ~Tagent ()
 
virtual void computeForces ()
 
virtual void move (double stepSizeIn)
 
virtual Tvector desiredForce ()
 
virtual Tvector socialForce (const set< const Ped::Tagent * > &neighbors)
 
virtual Tvector obstacleForce (const set< const Ped::Tagent * > &neighbors)
 
virtual Tvector lookaheadForce (Tvector desired, const set< const Ped::Tagent * > &neighbors)
 
virtual Tvector myForce (Tvector desired, const set< const Ped::Tagent * > &neighbors)
 
void setType (int t)
 
int getType () const
 
void setVmax (double vmax)
 
double getVmax ()
 
void setFollow (int id)
 
int getFollow () const
 
int getid () const
 
void setPosition (double px, double py, double pz)
 
void setPosition (const Tvector &pos)
 
Tvector getPosition () const
 
Tvector getVelocity () const
 
Tvector getAcceleration () const
 
void setfactorsocialforce (double f)
 
void setfactorobstacleforce (double f)
 
void setfactordesiredforce (double f)
 
void setfactorlookaheadforce (double f)
 
void setscene (Tscene *s)
 
Tscenegetscene ()
 
void addWaypoint (Twaypoint *wp)
 
bool removeWaypoint (const Twaypoint *wp)
 
void clearWaypoints ()
 
deque< Twaypoint * > getWaypoints ()
 
bool reachedDestination () const
 
void setWaypointBehavior (int mode)
 

Protected Attributes

int id
 agent number
 
Tvector p
 current position of the agent
 
Tvector v
 velocity of the agent
 
Tvector a
 current acceleration of the agent
 
int type
 
double vmax
 individual max velocity per agent
 
int follow
 
Ped::Tvector desiredDirection
 
Ped::Tscenescene
 
deque< Twaypoint * > waypoints
 coordinates of the next destinations
 
Twaypointdestination
 coordinates of the next destination
 
Twaypointlastdestination
 coordinates of the last destination
 
int waypointbehavior
 waypoints are round queues or not.
 
bool mlLookAhead
 
double factordesiredforce
 
double factorsocialforce
 
double factorobstacleforce
 
double factorlookaheadforce
 
double obstacleForceSigma
 
Ped::Tvector desiredforce
 
Ped::Tvector socialforce
 
Ped::Tvector obstacleforce
 
Ped::Tvector lookaheadforce
 
Ped::Tvector myforce
 
double relaxationTime
 
double agentRadius
 
long timestep
 

Detailed Description

This is the main class of the library. It contains the Tagent, which eventually will move through the Tscene and interact with Tobstacle and other Tagent. You can use it as it is, and access the agent's coordinates using the getx() etc methods. Or, if you want to change the way the agent behaves, you can derive a new class from it, and overwrite the methods you want to change. This is also a convenient way to get access to internal variables not available though public methods, like the individual forces that affect the agent.

Author
chgloor
Date
2003-12-26
Examples:
examples/example01.cpp, examples/example02.cpp, examples/example03.cpp, examples/example04.cpp, and examples/example05.cpp.

Definition at line 51 of file ped_agent.h.

Constructor & Destructor Documentation

Ped::Tagent::Tagent ( )

Default Constructor

Date
2003-12-29

Definition at line 24 of file ped_agent.cpp.

Ped::Tagent::~Tagent ( )
virtual

Destructor

Date
2012-02-04

Definition at line 63 of file ped_agent.cpp.

Member Function Documentation

void Ped::Tagent::addWaypoint ( Twaypoint wp)

Adds a TWaypoint to an agent's list of waypoints. Twaypoints are stored in a cyclic queue, the one just visited is pushed to the back again. There will be a flag to change this behavior soon. Adding a waypoint will also selecting the first waypoint in the internal list as the active one, i.e. the first waypoint added will be the first point to headt to, no matter what is added later.

Author
chgloor
Date
2012-01-19
Examples:
examples/example01.cpp, examples/example02.cpp, and examples/example04.cpp.

Definition at line 94 of file ped_agent.cpp.

void Ped::Tagent::computeForces ( )
virtual

This is the first step of the 2-step update process used here. First, all forces are computed, using the t-1 agent positions as input. Once the forces are computed, all agent positions for timestep t are updated at the same time.

Definition at line 498 of file ped_agent.cpp.

Ped::Tvector Ped::Tagent::desiredForce ( )
virtual

Calculates the force between this agent and the next assigned waypoint. If the waypoint has been reached, the next waypoint in the list will be selected. At the moment, a visited waypoint is pushed back to the end of the list, which means that the agents will visit all the waypoints over and over again. This behavior can be controlled by a flag using setWaypointBehavior().

Date
2012-01-17
Returns
Tvector: the calculated force

Definition at line 236 of file ped_agent.cpp.

int Ped::Tagent::getFollow ( ) const

Gets the ID of the agent this agent is following.

Date
2012-01-18
Returns
int, the agent id of the agent

Definition at line 158 of file ped_agent.cpp.

Ped::Tscene * Ped::Tagent::getscene ( )

Returns the Tscene assigned to the agent.

Date
2012-01-17
Warning
Bad things will happen if the agent is not assigned to a scene. But usually, Tscene takes care of that.
Returns
*s A Tscene initialized earlier, if one is assigned to the agent.

Definition at line 81 of file ped_agent.cpp.

double Ped::Tagent::getVmax ( )

Gets the maximum velocity of an agent (vmax). Even if pushed by other agents, it will not move faster than this.

Date
2016-08-10
Returns
The maximum velocity. In scene units per timestep, multiplied by the simulation's precision h.

Definition at line 175 of file ped_agent.cpp.

Ped::Tvector Ped::Tagent::lookaheadForce ( Ped::Tvector  e,
const set< const Ped::Tagent * > &  neighbors 
)
virtual

Calculates the mental layer force of the strategy "look ahead". It is implemented here in the physical layer because of performance reasons. It iterates over all Tagents in the Tscene, complexity $O(N^2)$.

Date
2012-01-17
Returns
Tvector: the calculated force
Parameters
eis a vector defining the direction in which the agent should look ahead to. Usually, this is the direction he wants to walk to.

Definition at line 439 of file ped_agent.cpp.

void Ped::Tagent::move ( double  h)
virtual

Does the agent dynamics stuff. In the current implementation a simple Euler integration is used. As the first step, the new position is calculated using t-1 velocity. Then, the new contributing individual forces are calculated. This will then be added to the existing velocity, which again is used during the next time step. See e.g. https://en.wikipedia.org/wiki/Euler_method

Date
2003-12-29
Parameters
hIntegration time step delta t

Definition at line 519 of file ped_agent.cpp.

Ped::Tvector Ped::Tagent::myForce ( Ped::Tvector  e,
const set< const Ped::Tagent * > &  neighbors 
)
virtual

myForce() is a method that returns an "empty" force (all components set to 0). This method can be overridden in order to define own forces. It is called in move() in addition to the other default forces.

Date
2012-02-12
Returns
Tvector: the calculated force
Parameters
eis a vector defining the direction in which the agent wants to walk to.

Definition at line 489 of file ped_agent.cpp.

Ped::Tvector Ped::Tagent::obstacleForce ( const set< const Ped::Tagent * > &  neighbors)
virtual

Calculates the force between this agent and the nearest obstacle in this scene. Iterates over all obstacles == O(N).

Date
2012-01-17
Returns
Tvector: the calculated force

Definition at line 411 of file ped_agent.cpp.

void Ped::Tagent::setfactordesiredforce ( double  f)

Sets the factor by which the desired force is multiplied. Values between 0 and about 10 do make sense.

Date
2012-01-20
Parameters
fThe factor

Definition at line 215 of file ped_agent.cpp.

void Ped::Tagent::setfactorlookaheadforce ( double  f)

Sets the factor by which the look ahead force is multiplied. Values between 0 and about 10 do make sense.

Date
2012-01-20
Parameters
fThe factor

Definition at line 224 of file ped_agent.cpp.

void Ped::Tagent::setfactorobstacleforce ( double  f)

Sets the factor by which the obstacle force is multiplied. Values between 0 and about 10 do make sense.

Date
2012-01-20
Parameters
fThe factor
Examples:
examples/example05.cpp.

Definition at line 206 of file ped_agent.cpp.

void Ped::Tagent::setfactorsocialforce ( double  f)

Sets the factor by which the social force is multiplied. Values between 0 and about 10 do make sense.

Date
2012-01-20
Parameters
fThe factor
Examples:
examples/example04.cpp, and examples/example05.cpp.

Definition at line 197 of file ped_agent.cpp.

void Ped::Tagent::setFollow ( int  id)

Sets the agent ID this agent has to follow. If set, the agent will ignore its assigned waypoints and just follow the other agent.

Date
2012-01-08
Parameters
idis the agent to follow (must exist, obviously)

Definition at line 149 of file ped_agent.cpp.

void Ped::Tagent::setPosition ( double  px,
double  py,
double  pz 
)

Sets the agent's position. This, and other getters returning coordinates, will eventually changed to returning a Tvector.

Date
2004-02-10
Parameters
pxPosition x
pyPosition y
pzPosition z
Examples:
examples/example01.cpp, examples/example02.cpp, examples/example03.cpp, and examples/example04.cpp.

Definition at line 186 of file ped_agent.cpp.

void Ped::Tagent::setscene ( Ped::Tscene s)

Assigns a Tscene to the agent. Tagent uses this to iterate over all obstacles and other agents in a scene. The scene will invoke this function when Tscene::addAgent() is called.

Date
2012-01-17
Warning
Bad things will happen if the agent is not assigned to a scene. But usually, Tscene takes care of that.
Parameters
*sA valid Tscene initialized earlier.

Definition at line 73 of file ped_agent.cpp.

Referenced by Ped::Tscene::addAgent().

void Ped::Tagent::setVmax ( double  pvmax)

Sets the maximum velocity of an agent (vmax). Even if pushed by other agents, it will not move faster than this.

Date
2012-01-08
Parameters
pvmaxThe maximum velocity. In scene units per timestep, multiplied by the simulation's precision h.
Examples:
examples/example05.cpp.

Definition at line 167 of file ped_agent.cpp.

Ped::Tvector Ped::Tagent::socialForce ( const set< const Ped::Tagent * > &  neighbors)
virtual

Calculates the social force between this agent and all the other agents belonging to the same scene. It iterates over all agents inside the scene, has therefore complexity $O(N^2)$. A better agent storing structure in Tscene would fix this. But for small (less than 10000 agents) scenarios, this is just fine.

Date
2012-01-17
Returns
Tvector: the calculated force

Definition at line 316 of file ped_agent.cpp.


The documentation for this class was generated from the following files:
O --- O

⁠(c) Christian Gloor [ c|h|g|l|o|o|r|@|s|i|l|m|a|r|i|l|.|o|r|g| ]