C# Class RVO.Simulator

Defines the simulation.
Datei anzeigen Open project: snape/RVO2-CS Class Usage Examples

Public Methods

Method Description
Clear ( ) : void

Clears the simulation.

GetNumWorkers ( ) : int

Returns the count of workers.

SetNumWorkers ( int numWorkers ) : void

Sets the number of workers.

addAgent ( Vector2 position ) : int

Adds a new agent with default properties to the simulation. *

addAgent ( Vector2 position, float neighborDist, int maxNeighbors, float timeHorizon, float timeHorizonObst, float radius, float maxSpeed, Vector2 velocity ) : int

Adds a new agent to the simulation.

addObstacle ( IList vertices ) : int

Adds a new obstacle to the simulation.

To add a "negative" obstacle, e.g. a bounding polygon around * the environment, the vertices should be listed in clockwise order. *

doStep ( ) : float

Performs a simulation step and updates the two-dimensional * position and two-dimensional velocity of each agent.

getAgentAgentNeighbor ( int agentNo, int neighborNo ) : int

Returns the specified agent neighbor of the specified agent. *

getAgentMaxNeighbors ( int agentNo ) : int

Returns the maximum neighbor count of a specified agent. *

getAgentMaxSpeed ( int agentNo ) : float

Returns the maximum speed of a specified agent.

getAgentNeighborDist ( int agentNo ) : float

Returns the maximum neighbor distance of a specified agent. *

getAgentNumAgentNeighbors ( int agentNo ) : int

Returns the count of agent neighbors taken into account to * compute the current velocity for the specified agent.

getAgentNumObstacleNeighbors ( int agentNo ) : int

Returns the count of obstacle neighbors taken into account * to compute the current velocity for the specified agent.

getAgentObstacleNeighbor ( int agentNo, int neighborNo ) : int

Returns the specified obstacle neighbor of the specified * agent.

getAgentOrcaLines ( int agentNo ) : IList

Returns the ORCA constraints of the specified agent. *

The halfplane to the left of each line is the region of * permissible velocities with respect to that ORCA constraint. *

getAgentPosition ( int agentNo ) : Vector2

Returns the two-dimensional position of a specified agent. *

getAgentPrefVelocity ( int agentNo ) : Vector2

Returns the two-dimensional preferred velocity of a * specified agent.

getAgentRadius ( int agentNo ) : float

Returns the radius of a specified agent.

getAgentTimeHorizon ( int agentNo ) : float

Returns the time horizon of a specified agent.

getAgentTimeHorizonObst ( int agentNo ) : float

Returns the time horizon with respect to obstacles of a * specified agent.

getAgentVelocity ( int agentNo ) : Vector2

Returns the two-dimensional linear velocity of a specified * agent.

getGlobalTime ( ) : float

Returns the global time of the simulation.

getNextObstacleVertexNo ( int vertexNo ) : int

Returns the number of the obstacle vertex succeeding the * specified obstacle vertex in its polygon.

getNumAgents ( ) : int

Returns the count of agents in the simulation.

getNumObstacleVertices ( ) : int

Returns the count of obstacle vertices in the simulation. *

getObstacleVertex ( int vertexNo ) : Vector2

Returns the two-dimensional position of a specified obstacle * vertex.

getPrevObstacleVertexNo ( int vertexNo ) : int

Returns the number of the obstacle vertex preceding the * specified obstacle vertex in its polygon.

getTimeStep ( ) : float

Returns the time step of the simulation.

processObstacles ( ) : void

Processes the obstacles that have been added so that they * are accounted for in the simulation.

Obstacles added to the simulation after this function has * been called are not accounted for in the simulation.

queryVisibility ( Vector2 point1, Vector2 point2, float radius ) : bool

Performs a visibility query between the two specified points * with respect to the obstacles.

setAgentDefaults ( float neighborDist, int maxNeighbors, float timeHorizon, float timeHorizonObst, float radius, float maxSpeed, Vector2 velocity ) : void

Sets the default properties for any new agent that is added. *

setAgentMaxNeighbors ( int agentNo, int maxNeighbors ) : void

Sets the maximum neighbor count of a specified agent. *

setAgentMaxSpeed ( int agentNo, float maxSpeed ) : void

Sets the maximum speed of a specified agent.

setAgentNeighborDist ( int agentNo, float neighborDist ) : void

Sets the maximum neighbor distance of a specified agent. *

setAgentPosition ( int agentNo, Vector2 position ) : void

Sets the two-dimensional position of a specified agent. *

setAgentPrefVelocity ( int agentNo, Vector2 prefVelocity ) : void

Sets the two-dimensional preferred velocity of a specified * agent.

setAgentRadius ( int agentNo, float radius ) : void

Sets the radius of a specified agent.

setAgentTimeHorizon ( int agentNo, float timeHorizon ) : void

Sets the time horizon of a specified agent with respect to * other agents.

setAgentTimeHorizonObst ( int agentNo, float timeHorizonObst ) : void

Sets the time horizon of a specified agent with respect to * obstacles.

setAgentVelocity ( int agentNo, Vector2 velocity ) : void

Sets the two-dimensional linear velocity of a specified * agent.

setGlobalTime ( float globalTime ) : void

Sets the global time of the simulation.

setTimeStep ( float timeStep ) : void

Sets the time step of the simulation.

Private Methods

Method Description
Simulator ( ) : System

Constructs and initializes a simulation.

Method Details

Clear() public method

Clears the simulation.
public Clear ( ) : void
return void

GetNumWorkers() public method

Returns the count of workers.
public GetNumWorkers ( ) : int
return int

SetNumWorkers() public method

Sets the number of workers.
public SetNumWorkers ( int numWorkers ) : void
numWorkers int The number of workers.
return void

addAgent() public method

Adds a new agent with default properties to the simulation. *
public addAgent ( Vector2 position ) : int
position Vector2 The two-dimensional starting position of this * agent.
return int

addAgent() public method

Adds a new agent to the simulation.
public addAgent ( Vector2 position, float neighborDist, int maxNeighbors, float timeHorizon, float timeHorizonObst, float radius, float maxSpeed, Vector2 velocity ) : int
position Vector2 The two-dimensional starting position of this * agent.
neighborDist float The maximum distance (center point to * center point) to other agents this agent takes into account in the * navigation. The larger this number, the longer the running time of * the simulation. If the number is too low, the simulation will not be * safe. Must be non-negative.
maxNeighbors int The maximum number of other agents this * agent takes into account in the navigation. The larger this number, * the longer the running time of the simulation. If the number is too * low, the simulation will not be safe.
timeHorizon float The minimal amount of time for which this * agent's velocities that are computed by the simulation are safe with * respect to other agents. The larger this number, the sooner this * agent will respond to the presence of other agents, but the less * freedom this agent has in choosing its velocities. Must be positive. *
timeHorizonObst float The minimal amount of time for which * this agent's velocities that are computed by the simulation are safe * with respect to obstacles. The larger this number, the sooner this * agent will respond to the presence of obstacles, but the less freedom * this agent has in choosing its velocities. Must be positive.
radius float The radius of this agent. Must be non-negative. *
maxSpeed float The maximum speed of this agent. Must be * non-negative.
velocity Vector2 The initial two-dimensional linear velocity of * this agent.
return int

addObstacle() public method

Adds a new obstacle to the simulation.
To add a "negative" obstacle, e.g. a bounding polygon around * the environment, the vertices should be listed in clockwise order. *
public addObstacle ( IList vertices ) : int
vertices IList List of the vertices of the polygonal obstacle * in counterclockwise order.
return int

doStep() public method

Performs a simulation step and updates the two-dimensional * position and two-dimensional velocity of each agent.
public doStep ( ) : float
return float

getAgentAgentNeighbor() public method

Returns the specified agent neighbor of the specified agent. *
public getAgentAgentNeighbor ( int agentNo, int neighborNo ) : int
agentNo int The number of the agent whose agent neighbor is * to be retrieved.
neighborNo int The number of the agent neighbor to be * retrieved.
return int

getAgentMaxNeighbors() public method

Returns the maximum neighbor count of a specified agent. *
public getAgentMaxNeighbors ( int agentNo ) : int
agentNo int The number of the agent whose maximum neighbor * count is to be retrieved.
return int

getAgentMaxSpeed() public method

Returns the maximum speed of a specified agent.
public getAgentMaxSpeed ( int agentNo ) : float
agentNo int The number of the agent whose maximum speed is * to be retrieved.
return float

getAgentNeighborDist() public method

Returns the maximum neighbor distance of a specified agent. *
public getAgentNeighborDist ( int agentNo ) : float
agentNo int The number of the agent whose maximum neighbor * distance is to be retrieved.
return float

getAgentNumAgentNeighbors() public method

Returns the count of agent neighbors taken into account to * compute the current velocity for the specified agent.
public getAgentNumAgentNeighbors ( int agentNo ) : int
agentNo int The number of the agent whose count of agent * neighbors is to be retrieved.
return int

getAgentNumObstacleNeighbors() public method

Returns the count of obstacle neighbors taken into account * to compute the current velocity for the specified agent.
public getAgentNumObstacleNeighbors ( int agentNo ) : int
agentNo int The number of the agent whose count of obstacle * neighbors is to be retrieved.
return int

getAgentObstacleNeighbor() public method

Returns the specified obstacle neighbor of the specified * agent.
public getAgentObstacleNeighbor ( int agentNo, int neighborNo ) : int
agentNo int The number of the agent whose obstacle neighbor * is to be retrieved.
neighborNo int The number of the obstacle neighbor to be * retrieved.
return int

getAgentOrcaLines() public method

Returns the ORCA constraints of the specified agent. *
The halfplane to the left of each line is the region of * permissible velocities with respect to that ORCA constraint. *
public getAgentOrcaLines ( int agentNo ) : IList
agentNo int The number of the agent whose ORCA constraints * are to be retrieved.
return IList

getAgentPosition() public method

Returns the two-dimensional position of a specified agent. *
public getAgentPosition ( int agentNo ) : Vector2
agentNo int The number of the agent whose two-dimensional * position is to be retrieved.
return Vector2

getAgentPrefVelocity() public method

Returns the two-dimensional preferred velocity of a * specified agent.
public getAgentPrefVelocity ( int agentNo ) : Vector2
agentNo int The number of the agent whose two-dimensional * preferred velocity is to be retrieved.
return Vector2

getAgentRadius() public method

Returns the radius of a specified agent.
public getAgentRadius ( int agentNo ) : float
agentNo int The number of the agent whose radius is to be * retrieved.
return float

getAgentTimeHorizon() public method

Returns the time horizon of a specified agent.
public getAgentTimeHorizon ( int agentNo ) : float
agentNo int The number of the agent whose time horizon is * to be retrieved.
return float

getAgentTimeHorizonObst() public method

Returns the time horizon with respect to obstacles of a * specified agent.
public getAgentTimeHorizonObst ( int agentNo ) : float
agentNo int The number of the agent whose time horizon with * respect to obstacles is to be retrieved.
return float

getAgentVelocity() public method

Returns the two-dimensional linear velocity of a specified * agent.
public getAgentVelocity ( int agentNo ) : Vector2
agentNo int The number of the agent whose two-dimensional * linear velocity is to be retrieved.
return Vector2

getGlobalTime() public method

Returns the global time of the simulation.
public getGlobalTime ( ) : float
return float

getNextObstacleVertexNo() public method

Returns the number of the obstacle vertex succeeding the * specified obstacle vertex in its polygon.
public getNextObstacleVertexNo ( int vertexNo ) : int
vertexNo int The number of the obstacle vertex whose * successor is to be retrieved.
return int

getNumAgents() public method

Returns the count of agents in the simulation.
public getNumAgents ( ) : int
return int

getNumObstacleVertices() public method

Returns the count of obstacle vertices in the simulation. *
public getNumObstacleVertices ( ) : int
return int

getObstacleVertex() public method

Returns the two-dimensional position of a specified obstacle * vertex.
public getObstacleVertex ( int vertexNo ) : Vector2
vertexNo int The number of the obstacle vertex to be * retrieved.
return Vector2

getPrevObstacleVertexNo() public method

Returns the number of the obstacle vertex preceding the * specified obstacle vertex in its polygon.
public getPrevObstacleVertexNo ( int vertexNo ) : int
vertexNo int The number of the obstacle vertex whose * predecessor is to be retrieved.
return int

getTimeStep() public method

Returns the time step of the simulation.
public getTimeStep ( ) : float
return float

processObstacles() public method

Processes the obstacles that have been added so that they * are accounted for in the simulation.
Obstacles added to the simulation after this function has * been called are not accounted for in the simulation.
public processObstacles ( ) : void
return void

queryVisibility() public method

Performs a visibility query between the two specified points * with respect to the obstacles.
public queryVisibility ( Vector2 point1, Vector2 point2, float radius ) : bool
point1 Vector2 The first point of the query.
point2 Vector2 The second point of the query.
radius float The minimal distance between the line connecting * the two points and the obstacles in order for the points to be * mutually visible (optional). Must be non-negative.
return bool

setAgentDefaults() public method

Sets the default properties for any new agent that is added. *
public setAgentDefaults ( float neighborDist, int maxNeighbors, float timeHorizon, float timeHorizonObst, float radius, float maxSpeed, Vector2 velocity ) : void
neighborDist float The default maximum distance (center point * to center point) to other agents a new agent takes into account in * the navigation. The larger this number, the longer he running time of * the simulation. If the number is too low, the simulation will not be * safe. Must be non-negative.
maxNeighbors int The default maximum number of other agents * a new agent takes into account in the navigation. The larger this * number, the longer the running time of the simulation. If the number * is too low, the simulation will not be safe.
timeHorizon float The default minimal amount of time for * which a new agent's velocities that are computed by the simulation * are safe with respect to other agents. The larger this number, the * sooner an agent will respond to the presence of other agents, but the * less freedom the agent has in choosing its velocities. Must be * positive.
timeHorizonObst float The default minimal amount of time for * which a new agent's velocities that are computed by the simulation * are safe with respect to obstacles. The larger this number, the * sooner an agent will respond to the presence of obstacles, but the * less freedom the agent has in choosing its velocities. Must be * positive.
radius float The default radius of a new agent. Must be * non-negative.
maxSpeed float The default maximum speed of a new agent. Must * be non-negative.
velocity Vector2 The default initial two-dimensional linear * velocity of a new agent.
return void

setAgentMaxNeighbors() public method

Sets the maximum neighbor count of a specified agent. *
public setAgentMaxNeighbors ( int agentNo, int maxNeighbors ) : void
agentNo int The number of the agent whose maximum neighbor * count is to be modified.
maxNeighbors int The replacement maximum neighbor count. *
return void

setAgentMaxSpeed() public method

Sets the maximum speed of a specified agent.
public setAgentMaxSpeed ( int agentNo, float maxSpeed ) : void
agentNo int The number of the agent whose maximum speed is * to be modified.
maxSpeed float The replacement maximum speed. Must be * non-negative.
return void

setAgentNeighborDist() public method

Sets the maximum neighbor distance of a specified agent. *
public setAgentNeighborDist ( int agentNo, float neighborDist ) : void
agentNo int The number of the agent whose maximum neighbor * distance is to be modified.
neighborDist float The replacement maximum neighbor distance. * Must be non-negative.
return void

setAgentPosition() public method

Sets the two-dimensional position of a specified agent. *
public setAgentPosition ( int agentNo, Vector2 position ) : void
agentNo int The number of the agent whose two-dimensional * position is to be modified.
position Vector2 The replacement of the two-dimensional * position.
return void

setAgentPrefVelocity() public method

Sets the two-dimensional preferred velocity of a specified * agent.
public setAgentPrefVelocity ( int agentNo, Vector2 prefVelocity ) : void
agentNo int The number of the agent whose two-dimensional * preferred velocity is to be modified.
prefVelocity Vector2 The replacement of the two-dimensional * preferred velocity.
return void

setAgentRadius() public method

Sets the radius of a specified agent.
public setAgentRadius ( int agentNo, float radius ) : void
agentNo int The number of the agent whose radius is to be * modified.
radius float The replacement radius. Must be non-negative. *
return void

setAgentTimeHorizon() public method

Sets the time horizon of a specified agent with respect to * other agents.
public setAgentTimeHorizon ( int agentNo, float timeHorizon ) : void
agentNo int The number of the agent whose time horizon is * to be modified.
timeHorizon float The replacement time horizon with respect * to other agents. Must be positive.
return void

setAgentTimeHorizonObst() public method

Sets the time horizon of a specified agent with respect to * obstacles.
public setAgentTimeHorizonObst ( int agentNo, float timeHorizonObst ) : void
agentNo int The number of the agent whose time horizon with * respect to obstacles is to be modified.
timeHorizonObst float The replacement time horizon with * respect to obstacles. Must be positive.
return void

setAgentVelocity() public method

Sets the two-dimensional linear velocity of a specified * agent.
public setAgentVelocity ( int agentNo, Vector2 velocity ) : void
agentNo int The number of the agent whose two-dimensional * linear velocity is to be modified.
velocity Vector2 The replacement two-dimensional linear * velocity.
return void

setGlobalTime() public method

Sets the global time of the simulation.
public setGlobalTime ( float globalTime ) : void
globalTime float The global time of the simulation.
return void

setTimeStep() public method

Sets the time step of the simulation.
public setTimeStep ( float timeStep ) : void
timeStep float The time step of the simulation. Must be * positive.
return void