Public Member Functions | Static Public Member Functions

RVO::RVOSimulator Class Reference

#include <RVOSimulator.h>

List of all members.

Public Member Functions

 ~RVOSimulator ()
int addAgent (const Vector2 &startPosition, int goalID)
int addAgent (const Vector2 &startPosition, int goalID, int velSampleCount, float neighborDist, int maxNeighbors, float radius, float goalRadius, float prefSpeed, float maxSpeed, float safetyFactor, float maxAccel=RVO_INFTY, const Vector2 &velocity=Vector2(0, 0), float orientation=0, int classID=0)
int addGoal (const Vector2 &position)
int addObstacle (const Vector2 &point1, const Vector2 &point2)
int addRoadmapEdge (int vertexID1, int vertexID2)
int addRoadmapVertex (const Vector2 &position)
int doStep ()
int getAgentClass (int agentID) const
int getAgentGoal (int agentID) const
float getAgentGoalRadius (int agentID) const
float getAgentMaxAccel (int agentID) const
int getAgentMaxNeighbors (int agentID) const
float getAgentMaxSpeed (int agentID) const
float getAgentNeighborDist (int agentID) const
float getAgentOrientation (int agentID) const
const Vector2getAgentPosition (int agentID) const
float getAgentPrefSpeed (int agentID) const
float getAgentRadius (int agentID) const
bool getAgentReachedGoal (int agentID) const
float getAgentSafetyFactor (int agentID) const
const Vector2getAgentVelocity (int agentID) const
int getAgentVelSampleCount (int agentID) const
float getGlobalTime () const
int getGoalNeighbor (int goalID, int neighborNr) const
int getGoalNumNeighbors (int goalID) const
const Vector2getGoalPosition (int goalID) const
int getNumAgents () const
int getNumGoals () const
int getNumObstacles () const
int getNumRoadmapVertices () const
const Vector2getObstaclePoint1 (int obstacleID) const
const Vector2getObstaclePoint2 (int obstacleID) const
bool getReachedGoal () const
int getRoadmapVertexNeighbor (int vertexID, int neighborNr) const
int getRoadmapVertexNumNeighbors (int vertexID) const
const Vector2getRoadmapVertexPosition (int vertexID) const
float getTimeStep () const
void initSimulation ()
void setAgentClass (int agentID, int classID)
void setAgentDefaults (int velSampleCountDefault, float neighborDistDefault, int maxNeighborsDefault, float radiusDefault, float goalRadiusDefault, float prefSpeedDefault, float maxSpeedDefault, float safetyFactorDefault, float maxAccelDefault=RVO_INFTY, const Vector2 &velocityDefault=Vector2(0, 0), float orientationDefault=0, int classDefault=0)
void setAgentGoal (int agentID, int goalID)
void setAgentGoalRadius (int agentID, float goalRadius)
void setAgentMaxAccel (int agentID, float maxAccel)
void setAgentMaxNeighbors (int agentID, int maximum)
void setAgentMaxSpeed (int agentID, float maxSpeed)
void setAgentNeighborDist (int agentID, float distance)
void setAgentOrientation (int agentID, float orientation)
void setAgentPosition (int agentID, const Vector2 &position)
void setAgentPrefSpeed (int agentID, float prefSpeed)
void setAgentRadius (int agentID, float radius)
void setAgentSafetyFactor (int agentID, float safetyFactor)
void setAgentVelocity (int agentID, const Vector2 &velocity)
void setAgentVelSampleCount (int agentID, int samples)
void setRoadmapAutomatic (float automaticRadius)
void setTimeStep (float stepSize)

Static Public Member Functions

static RVOSimulatorInstance ()

Detailed Description

The main class of the RVO library.


Constructor & Destructor Documentation

RVO::RVOSimulator::~RVOSimulator (  ) 

Deconstructor of the RVOSimulator instance.


Member Function Documentation

int RVO::RVOSimulator::addAgent ( const Vector2 startPosition,
int  goalID 
)

Adds an agent with default parameters to the simulation.

Parameters:
startPosition The start position of the agent
goalID The ID of the goal of the agent
Returns:
The function returns the ID of the agent that has been added, and an errorcode if the agent defaults have not been set, or when the function is called after the simulation has been initialized.
int RVO::RVOSimulator::addAgent ( const Vector2 startPosition,
int  goalID,
int  velSampleCount,
float  neighborDist,
int  maxNeighbors,
float  radius,
float  goalRadius,
float  prefSpeed,
float  maxSpeed,
float  safetyFactor,
float  maxAccel = RVO_INFTY,
const Vector2 velocity = Vector2(0, 0),
float  orientation = 0,
int  classID = 0 
)

Adds an agent with specified parameters to the simulation.

Parameters:
startPosition The start position of the agent
goalID The ID of the goal of the agent
velSampleCount The number of candidate velocities sampled for the agent in each step of the simulation. The running time of the simulation increases linearly with this number.
neighborDist The distance within which the agent take other agents and obstacles into account in the navigation. The larger this number, the larger the running time of the simulation. If the number is too low, the simulation will not be safe.
maxNeighbors The maximum number of other agents and obstacles the agent takes into account in the navigation. The larger this number, the larger the running time of the simulation. If the number is too low, the simulation will not be safe.
radius The radius of the agent
goalRadius The goal radius of the agent; an agent is said to have reached its goal when it is within a distance goalRadius from its goal position.
prefSpeed The preferred speed of the agent
maxSpeed The maximum speed of the agent
safetyFactor The safety factor of the agent. I.e. the weight that is given to the 'time to collision' when penalizing a candidate velocity for the agent (vs. the distance to the preferred velocity). The higher this value, the 'safer' or the 'shyer' the agent is. The lower this value, the more 'aggressive' and 'reckless' the agent is. Its unit is distance.
maxAccel The maximum acceleration of the agent
velocity The initial velocity of the agent
orientation The initial orientation of the agent
classID The class of the agent; the class of an agent does not affect the simulation, but can be used in external applications to distinguish among agents
Returns:
The function returns the ID of the agent that has been added. It returns an errorcode when the function is called after the simulation has been initialized.
int RVO::RVOSimulator::addGoal ( const Vector2 position  ) 

Adds a goal position to the simulation.

Parameters:
position The position of the goal
Returns:
The function returns the ID of the goal that has been added. It returns an errorcode when the function is called after the simulation has been initialized.
int RVO::RVOSimulator::addObstacle ( const Vector2 point1,
const Vector2 point2 
)

Adds a line segment obstacle to the simulation.

Parameters:
point1 The position of the first endpoint of the line segment obstacle
point2 The position of the second endpoint of the line segment obstacle
Returns:
The function returns the ID of the obstacle that has been added. It returns an errorcode when the function is called after the simulation has been initialized.
int RVO::RVOSimulator::addRoadmapEdge ( int  vertexID1,
int  vertexID2 
)

Adds an edge between two vertices of the roadmap. The roadmap is undirected.

Parameters:
vertexID1 The ID of the first vertex of the edge
vertexID2 The ID of the second vertex of the edge
Returns:
The function returns RVO_SUCCESS when successful, and an errorcode when the function is called after the simulation has been initialized.
int RVO::RVOSimulator::addRoadmapVertex ( const Vector2 position  ) 

Adds a vertex to the roadmap of environment. The roadmap is used for global planning for the agents around obstacles.

Parameters:
position The position of the roadmap vertex
Returns:
The function returns the ID of the roadmap vertex that has been added. It returns an errorcode when the function is called after the simulation has been initialized.
int RVO::RVOSimulator::doStep (  ) 

Causes the simulator to take another simulation step. Modifies position, velocity and orientation of agents. Updates the global time of the simulation, and sets a 'reached goal' flag when all of the agents have reached their goal.

Returns:
The function returns RVO_SUCCESS on success, and an errorcode when the simulation has not been initialized, or when the global parameters have not been set.
int RVO::RVOSimulator::getAgentClass ( int  agentID  )  const

Retrieving the class of an agent.

Parameters:
agentID The agent's ID
Returns:
The function returns the class of the specified agent.
int RVO::RVOSimulator::getAgentGoal ( int  agentID  )  const

Retrieving the goal of an agent.

Parameters:
agentID The agent's ID
Returns:
The function returns the ID of the goal of the specified agent.
float RVO::RVOSimulator::getAgentGoalRadius ( int  agentID  )  const

Retrieving the goal radius of an agent.

Parameters:
agentID The agent's ID
Returns:
The function returns the goal radius of the specified agent.
float RVO::RVOSimulator::getAgentMaxAccel ( int  agentID  )  const

Retrieving the maximum acceleration of an agent.

Parameters:
agentID The agent's ID
Returns:
The function returns the acceleration of the specified agent.
int RVO::RVOSimulator::getAgentMaxNeighbors ( int  agentID  )  const

Retrieving the maximum number of neighbors of an agent.

Parameters:
agentID The agent's ID
Returns:
The function returns the currently set maximum number of neighbors of the specified agent.
float RVO::RVOSimulator::getAgentMaxSpeed ( int  agentID  )  const

Retrieving the maximum speed of an agent.

Parameters:
agentID The agent's ID
Returns:
The function returns the maximum speed of the specified agent.
float RVO::RVOSimulator::getAgentNeighborDist ( int  agentID  )  const

Retrieving the neighbor distance of an agent

Parameters:
agentID The agent's ID
Returns:
The function returns the currently set neighbor distance of the specified agent.
float RVO::RVOSimulator::getAgentOrientation ( int  agentID  )  const

Retrieving the current orientation of an agent.

Parameters:
agentID The agent's ID
Returns:
The function returns the current orientation of the specified agent.
const Vector2& RVO::RVOSimulator::getAgentPosition ( int  agentID  )  const

Retrieving the current position of an agent.

Parameters:
agentID The agent's ID
Returns:
The function returns the current position of the specified agent.
float RVO::RVOSimulator::getAgentPrefSpeed ( int  agentID  )  const

Retrieving the preferred speed of an agent.

Parameters:
agentID The agent's ID
Returns:
The function returns the preferred speed of the specified agent.
float RVO::RVOSimulator::getAgentRadius ( int  agentID  )  const

Retrieving the radius of an agent.

Parameters:
agentID The agent's ID
Returns:
The function returns the radius of the specified agent.
bool RVO::RVOSimulator::getAgentReachedGoal ( int  agentID  )  const

Retrieving whether an agent has reached its goal.

Parameters:
agentID The agent's ID
Returns:
The function returns true when the specified agent has reached its goal. Returns false otherwise.
float RVO::RVOSimulator::getAgentSafetyFactor ( int  agentID  )  const

Retrieving the safety factor of an agent.

Parameters:
agentID The agent's ID
Returns:
The function returns the safety factor of the specified agent.
const Vector2& RVO::RVOSimulator::getAgentVelocity ( int  agentID  )  const

Retrieving the current velocity of an agent.

Parameters:
agentID The agent's ID
Returns:
The function returns the current velocity of the specified agent.
int RVO::RVOSimulator::getAgentVelSampleCount ( int  agentID  )  const

Retrieving the sample number of an agent

Parameters:
agentID The agent's ID
Returns:
The function returns the currently set number of candidate velocities that is sampled for the specified agent in each step of the simulation.
float RVO::RVOSimulator::getGlobalTime (  )  const
Returns:
The function returns the current global time of the simulation. Is initially 0.
int RVO::RVOSimulator::getGoalNeighbor ( int  goalID,
int  neighborNr 
) const

Retrieving the ID of a roadmap vertex connected to a goal.

Parameters:
goalID The goal's ID
neighborNr The neighbor number
Returns:
The ID of the vertex in the roadmap that is the neighborNr'th neighbor of the specified goal.
int RVO::RVOSimulator::getGoalNumNeighbors ( int  goalID  )  const

Retrieving the number of roadmap vertices connected to a goal.

Parameters:
goalID The goal's ID
Returns:
The function returns the number of vertices in the roadmap that are neighbors of the specified goal.
const Vector2& RVO::RVOSimulator::getGoalPosition ( int  goalID  )  const

Retrieving the position of a goal.

Parameters:
goalID The goal's ID
Returns:
The function returns the position of the specified goal.
int RVO::RVOSimulator::getNumAgents (  )  const
Returns:
The function returns the number of agents in the simulation.
int RVO::RVOSimulator::getNumGoals (  )  const
Returns:
The function returns the number of goals in the simulation.
int RVO::RVOSimulator::getNumObstacles (  )  const
Returns:
The function returns the number of obstacles in the simulation.
int RVO::RVOSimulator::getNumRoadmapVertices (  )  const
Returns:
The function returns the number of vertices in the roadmap of the simulation.
const Vector2& RVO::RVOSimulator::getObstaclePoint1 ( int  obstacleID  )  const

Retrieving the first endpoint of an obstacle.

Parameters:
obstacleID The obstacle's ID
Returns:
The function returns the position of the first endpoint of the specified obstacle.
const Vector2& RVO::RVOSimulator::getObstaclePoint2 ( int  obstacleID  )  const

Retrieving the second endpoint of an obstacle.

Parameters:
obstacleID The obstacle's ID
Returns:
The function returns the position of the second endpoint of the specified obstacle.
bool RVO::RVOSimulator::getReachedGoal (  )  const
Returns:
The function returns true when all agents have reached their goal. Returns false otherwise.
int RVO::RVOSimulator::getRoadmapVertexNeighbor ( int  vertexID,
int  neighborNr 
) const

Retrieving the ID of a roadmap vertex connected to a vertex in the roadmap.

Parameters:
vertexID The vertex' ID
neighborNr The neighbor number
Returns:
The ID of the vertex in the roadmap that is the neighborNr'th neighbor of the specified roadmap vertex.
int RVO::RVOSimulator::getRoadmapVertexNumNeighbors ( int  vertexID  )  const

Retrieving the number of roadmap vertices connected to a vertex in the roadmap.

Parameters:
vertexID The vertex' ID
Returns:
The function returns the number of neighbors of the specified vertex in the roadmap.
const Vector2& RVO::RVOSimulator::getRoadmapVertexPosition ( int  vertexID  )  const

Retrieving the position of a vertex in the roadmap.

Parameters:
vertexID The vertex' ID
Returns:
The function returns the position of the specified roadmap vertex.
float RVO::RVOSimulator::getTimeStep (  )  const
Returns:
The function returns the currently set time step of the simulation.
void RVO::RVOSimulator::initSimulation (  ) 

Processes the input (goals, agents, obstacles and roadmap) of the simulation. After initialization, no content can be added anymore to the environment.

static RVOSimulator* RVO::RVOSimulator::Instance (  )  [static]

Instantiates an RVOSimulator.

Returns:
The function returns a pointer to the singleton instance.
void RVO::RVOSimulator::setAgentClass ( int  agentID,
int  classID 
)

Sets the class of an agent.

Parameters:
agentID The agent's ID
classID The new class of the agent
void RVO::RVOSimulator::setAgentDefaults ( int  velSampleCountDefault,
float  neighborDistDefault,
int  maxNeighborsDefault,
float  radiusDefault,
float  goalRadiusDefault,
float  prefSpeedDefault,
float  maxSpeedDefault,
float  safetyFactorDefault,
float  maxAccelDefault = RVO_INFTY,
const Vector2 velocityDefault = Vector2(0, 0),
float  orientationDefault = 0,
int  classDefault = 0 
)

Sets the default parameters for agents that are subsequently added.

Parameters:
velSampleCountDefault The default number of candidate velocities sampled for the agent in each step of the simulation. The running time of the simulation increases linearly with this number.
neighborDistDefault The default distance within which the agent take other agents and obstacles into account in the navigation. The larger this number, the larger the running time of the simulation. If the number is too low, the simulation will not be safe.
maxNeighborsDefault The default maximum number of other agents and obstacles the agent takes into account in the navigation. The larger this number, the larger the running time of the simulation. If the number is too low, the simulation will not be safe.
radiusDefault The default radius of the agents
goalRadiusDefault The default goal radius of the agents
prefSpeedDefault The default preferred speed of the agents
maxSpeedDefault The default maximum speed of the agents
safetyFactorDefault The default safety factor of the agents. I.e. the weight that is given to the 'time to collision' when penalizing a candidate velocity for the agent (vs. the distance to the preferred velocity). The higher this value, the 'safer' or the 'shyer' the agent is. The lower this value, the more 'aggressive' and 'reckless' the agent is. Its unit is distance.
maxAccelDefault The default maximum acceleration of the agents
velocityDefault The default initial velocity of the agents
orientationDefault The default initial orientation of the agents
classDefault The default class of the agent
void RVO::RVOSimulator::setAgentGoal ( int  agentID,
int  goalID 
)

Sets the goal of an agent.

Parameters:
agentID The agent's ID
goalID The ID of the new goal of the agent
void RVO::RVOSimulator::setAgentGoalRadius ( int  agentID,
float  goalRadius 
)

Sets the goal radius of an agent.

Parameters:
agentID The agent's ID
goalRadius The new goal radius of the agent
void RVO::RVOSimulator::setAgentMaxAccel ( int  agentID,
float  maxAccel 
)

Sets the maximum acceleration of an agent.

Parameters:
agentID The agent's ID
maxAccel The new maximum acceleration of the agent
void RVO::RVOSimulator::setAgentMaxNeighbors ( int  agentID,
int  maximum 
)

Sets the maximum number of neighbors of the specified agent.

Parameters:
agentID The agent's ID
maximum The new maximum number of neighbors.
void RVO::RVOSimulator::setAgentMaxSpeed ( int  agentID,
float  maxSpeed 
)

Sets the maximum speed of an agent.

Parameters:
agentID The agent's ID
maxSpeed The new maximum speed of the agent
void RVO::RVOSimulator::setAgentNeighborDist ( int  agentID,
float  distance 
)

Sets the neighbor distance of the specified agent.

Parameters:
agentID The agent's ID
distance The new neighbor distance.
void RVO::RVOSimulator::setAgentOrientation ( int  agentID,
float  orientation 
)

Sets the current orientation of an agent.

Parameters:
agentID The agent's ID
orientation The new orientation of the agent
void RVO::RVOSimulator::setAgentPosition ( int  agentID,
const Vector2 position 
)

Sets the current position of an agent.

Parameters:
agentID The agent's ID
position The new position of the agent
void RVO::RVOSimulator::setAgentPrefSpeed ( int  agentID,
float  prefSpeed 
)

Sets the preferred speed of an agent.

Parameters:
agentID The agent's ID
prefSpeed The new preferred speed of the agent
void RVO::RVOSimulator::setAgentRadius ( int  agentID,
float  radius 
)

Sets the radius of an agent.

Parameters:
agentID The agent's ID
radius The new radius of the agent
void RVO::RVOSimulator::setAgentSafetyFactor ( int  agentID,
float  safetyFactor 
)

Sets the safety factor of an agent.

Parameters:
agentID The agent's ID
safetyFactor The new safety factor of the agent
void RVO::RVOSimulator::setAgentVelocity ( int  agentID,
const Vector2 velocity 
)

Sets the current velocity of an agent.

Parameters:
agentID The agent's ID
velocity The new velocity of the agent
void RVO::RVOSimulator::setAgentVelSampleCount ( int  agentID,
int  samples 
)

Sets the number of candidate velocities that is sampled for the specified agent in each step of the simulation.

Parameters:
agentID The agent's ID
samples The new number of samples.
void RVO::RVOSimulator::setRoadmapAutomatic ( float  automaticRadius  ) 

Sets for which radius the mutually visible vertices of the roadmap should automatically be connected by edges when the simulation is initialized. The radius specifies the tolerated distance to obstacles of the line between two roadmap vertices in order for them to be mutually visible. Default is -1.

Parameters:
automaticRadius If non-negative, the mutually visible vertices for the specified radius will be connected in addition to manually specified edges. If negative, no edges will created in addition to the manually specified ones.
void RVO::RVOSimulator::setTimeStep ( float  stepSize  ) 

Sets the time step of the simulation.

Parameters:
stepSize The new time step of the simulation.