Defines the simulation. More...
#include <RVOSimulator.h>
Public Member Functions | |
RVOSimulator () | |
Constructs a simulator instance. | |
RVOSimulator (float timeStep, float neighborDist, size_t maxNeighbors, float timeHorizon, float timeHorizonObst, float radius, float maxSpeed, const Vector2 &velocity=Vector2()) | |
Constructs a simulator instance and sets the default properties for any new agent that is added. More... | |
~RVOSimulator () | |
Destroys this simulator instance. | |
size_t | addAgent (const Vector2 &position) |
Adds a new agent with default properties to the simulation. More... | |
size_t | addAgent (const Vector2 &position, float neighborDist, size_t maxNeighbors, float timeHorizon, float timeHorizonObst, float radius, float maxSpeed, const Vector2 &velocity=Vector2()) |
Adds a new agent to the simulation. More... | |
size_t | addObstacle (const std::vector< Vector2 > &vertices) |
Adds a new obstacle to the simulation. More... | |
void | doStep () |
Lets the simulator perform a simulation step and updates the two-dimensional position and two-dimensional velocity of each agent. | |
size_t | getAgentAgentNeighbor (size_t agentNo, size_t neighborNo) const |
Returns the specified agent neighbor of the specified agent. More... | |
size_t | getAgentMaxNeighbors (size_t agentNo) const |
Returns the maximum neighbor count of a specified agent. More... | |
float | getAgentMaxSpeed (size_t agentNo) const |
Returns the maximum speed of a specified agent. More... | |
float | getAgentNeighborDist (size_t agentNo) const |
Returns the maximum neighbor distance of a specified agent. More... | |
size_t | getAgentNumAgentNeighbors (size_t agentNo) const |
Returns the count of agent neighbors taken into account to compute the current velocity for the specified agent. More... | |
size_t | getAgentNumObstacleNeighbors (size_t agentNo) const |
Returns the count of obstacle neighbors taken into account to compute the current velocity for the specified agent. More... | |
size_t | getAgentNumORCALines (size_t agentNo) const |
Returns the count of ORCA constraints used to compute the current velocity for the specified agent. More... | |
size_t | getAgentObstacleNeighbor (size_t agentNo, size_t neighborNo) const |
Returns the specified obstacle neighbor of the specified agent. More... | |
const Line & | getAgentORCALine (size_t agentNo, size_t lineNo) const |
Returns the specified ORCA constraint of the specified agent. More... | |
const Vector2 & | getAgentPosition (size_t agentNo) const |
Returns the two-dimensional position of a specified agent. More... | |
const Vector2 & | getAgentPrefVelocity (size_t agentNo) const |
Returns the two-dimensional preferred velocity of a specified agent. More... | |
float | getAgentRadius (size_t agentNo) const |
Returns the radius of a specified agent. More... | |
float | getAgentTimeHorizon (size_t agentNo) const |
Returns the time horizon of a specified agent. More... | |
float | getAgentTimeHorizonObst (size_t agentNo) const |
Returns the time horizon with respect to obstacles of a specified agent. More... | |
const Vector2 & | getAgentVelocity (size_t agentNo) const |
Returns the two-dimensional linear velocity of a specified agent. More... | |
float | getGlobalTime () const |
Returns the global time of the simulation. More... | |
size_t | getNumAgents () const |
Returns the count of agents in the simulation. More... | |
size_t | getNumObstacleVertices () const |
Returns the count of obstacle vertices in the simulation. More... | |
const Vector2 & | getObstacleVertex (size_t vertexNo) const |
Returns the two-dimensional position of a specified obstacle vertex. More... | |
size_t | getNextObstacleVertexNo (size_t vertexNo) const |
Returns the number of the obstacle vertex succeeding the specified obstacle vertex in its polygon. More... | |
size_t | getPrevObstacleVertexNo (size_t vertexNo) const |
Returns the number of the obstacle vertex preceding the specified obstacle vertex in its polygon. More... | |
float | getTimeStep () const |
Returns the time step of the simulation. More... | |
void | processObstacles () |
Processes the obstacles that have been added so that they are accounted for in the simulation. More... | |
bool | queryVisibility (const Vector2 &point1, const Vector2 &point2, float radius=0.0f) const |
Performs a visibility query between the two specified points with respect to the obstacles. More... | |
void | setAgentDefaults (float neighborDist, size_t maxNeighbors, float timeHorizon, float timeHorizonObst, float radius, float maxSpeed, const Vector2 &velocity=Vector2()) |
Sets the default properties for any new agent that is added. More... | |
void | setAgentMaxNeighbors (size_t agentNo, size_t maxNeighbors) |
Sets the maximum neighbor count of a specified agent. More... | |
void | setAgentMaxSpeed (size_t agentNo, float maxSpeed) |
Sets the maximum speed of a specified agent. More... | |
void | setAgentNeighborDist (size_t agentNo, float neighborDist) |
Sets the maximum neighbor distance of a specified agent. More... | |
void | setAgentPosition (size_t agentNo, const Vector2 &position) |
Sets the two-dimensional position of a specified agent. More... | |
void | setAgentPrefVelocity (size_t agentNo, const Vector2 &prefVelocity) |
Sets the two-dimensional preferred velocity of a specified agent. More... | |
void | setAgentRadius (size_t agentNo, float radius) |
Sets the radius of a specified agent. More... | |
void | setAgentTimeHorizon (size_t agentNo, float timeHorizon) |
Sets the time horizon of a specified agent with respect to other agents. More... | |
void | setAgentTimeHorizonObst (size_t agentNo, float timeHorizonObst) |
Sets the time horizon of a specified agent with respect to obstacles. More... | |
void | setAgentVelocity (size_t agentNo, const Vector2 &velocity) |
Sets the two-dimensional linear velocity of a specified agent. More... | |
void | setTimeStep (float timeStep) |
Sets the time step of the simulation. More... | |
Friends | |
class | Agent |
class | KdTree |
class | Obstacle |
Defines the simulation.
The main class of the library that contains all simulation functionality.
RVO::RVOSimulator::RVOSimulator | ( | float | timeStep, |
float | neighborDist, | ||
size_t | maxNeighbors, | ||
float | timeHorizon, | ||
float | timeHorizonObst, | ||
float | radius, | ||
float | maxSpeed, | ||
const Vector2 & | velocity = Vector2() |
||
) |
Constructs a simulator instance and sets the default properties for any new agent that is added.
timeStep | The time step of the simulation. Must be positive. |
neighborDist | 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 | 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 | 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 | 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 | The default radius of a new agent. Must be non-negative. |
maxSpeed | The default maximum speed of a new agent. Must be non-negative. |
velocity | The default initial two-dimensional linear velocity of a new agent (optional). |
size_t RVO::RVOSimulator::addAgent | ( | const Vector2 & | position | ) |
Adds a new agent with default properties to the simulation.
position | The two-dimensional starting position of this agent. |
size_t RVO::RVOSimulator::addAgent | ( | const Vector2 & | position, |
float | neighborDist, | ||
size_t | maxNeighbors, | ||
float | timeHorizon, | ||
float | timeHorizonObst, | ||
float | radius, | ||
float | maxSpeed, | ||
const Vector2 & | velocity = Vector2() |
||
) |
Adds a new agent to the simulation.
position | The two-dimensional starting position of this agent. |
neighborDist | 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 | 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 | 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 | 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 | The radius of this agent. Must be non-negative. |
maxSpeed | The maximum speed of this agent. Must be non-negative. |
velocity | The initial two-dimensional linear velocity of this agent (optional). |
size_t RVO::RVOSimulator::addObstacle | ( | const std::vector< Vector2 > & | vertices | ) |
Adds a new obstacle to the simulation.
vertices | List of the vertices of the polygonal obstacle in counterclockwise order. |
size_t RVO::RVOSimulator::getAgentAgentNeighbor | ( | size_t | agentNo, |
size_t | neighborNo | ||
) | const |
Returns the specified agent neighbor of the specified agent.
agentNo | The number of the agent whose agent neighbor is to be retrieved. |
neighborNo | The number of the agent neighbor to be retrieved. |
size_t RVO::RVOSimulator::getAgentMaxNeighbors | ( | size_t | agentNo | ) | const |
Returns the maximum neighbor count of a specified agent.
agentNo | The number of the agent whose maximum neighbor count is to be retrieved. |
float RVO::RVOSimulator::getAgentMaxSpeed | ( | size_t | agentNo | ) | const |
Returns the maximum speed of a specified agent.
agentNo | The number of the agent whose maximum speed is to be retrieved. |
float RVO::RVOSimulator::getAgentNeighborDist | ( | size_t | agentNo | ) | const |
Returns the maximum neighbor distance of a specified agent.
agentNo | The number of the agent whose maximum neighbor distance is to be retrieved. |
size_t RVO::RVOSimulator::getAgentNumAgentNeighbors | ( | size_t | agentNo | ) | const |
Returns the count of agent neighbors taken into account to compute the current velocity for the specified agent.
agentNo | The number of the agent whose count of agent neighbors is to be retrieved. |
size_t RVO::RVOSimulator::getAgentNumObstacleNeighbors | ( | size_t | agentNo | ) | const |
Returns the count of obstacle neighbors taken into account to compute the current velocity for the specified agent.
agentNo | The number of the agent whose count of obstacle neighbors is to be retrieved. |
size_t RVO::RVOSimulator::getAgentNumORCALines | ( | size_t | agentNo | ) | const |
Returns the count of ORCA constraints used to compute the current velocity for the specified agent.
agentNo | The number of the agent whose count of ORCA constraints is to be retrieved. |
size_t RVO::RVOSimulator::getAgentObstacleNeighbor | ( | size_t | agentNo, |
size_t | neighborNo | ||
) | const |
Returns the specified obstacle neighbor of the specified agent.
agentNo | The number of the agent whose obstacle neighbor is to be retrieved. |
neighborNo | The number of the obstacle neighbor to be retrieved. |
const Line& RVO::RVOSimulator::getAgentORCALine | ( | size_t | agentNo, |
size_t | lineNo | ||
) | const |
Returns the specified ORCA constraint of the specified agent.
agentNo | The number of the agent whose ORCA constraint is to be retrieved. |
lineNo | The number of the ORCA constraint to be retrieved. |
const Vector2& RVO::RVOSimulator::getAgentPosition | ( | size_t | agentNo | ) | const |
Returns the two-dimensional position of a specified agent.
agentNo | The number of the agent whose two-dimensional position is to be retrieved. |
const Vector2& RVO::RVOSimulator::getAgentPrefVelocity | ( | size_t | agentNo | ) | const |
Returns the two-dimensional preferred velocity of a specified agent.
agentNo | The number of the agent whose two-dimensional preferred velocity is to be retrieved. |
float RVO::RVOSimulator::getAgentRadius | ( | size_t | agentNo | ) | const |
Returns the radius of a specified agent.
agentNo | The number of the agent whose radius is to be retrieved. |
float RVO::RVOSimulator::getAgentTimeHorizon | ( | size_t | agentNo | ) | const |
Returns the time horizon of a specified agent.
agentNo | The number of the agent whose time horizon is to be retrieved. |
float RVO::RVOSimulator::getAgentTimeHorizonObst | ( | size_t | agentNo | ) | const |
Returns the time horizon with respect to obstacles of a specified agent.
agentNo | The number of the agent whose time horizon with respect to obstacles is to be retrieved. |
const Vector2& RVO::RVOSimulator::getAgentVelocity | ( | size_t | agentNo | ) | const |
Returns the two-dimensional linear velocity of a specified agent.
agentNo | The number of the agent whose two-dimensional linear velocity is to be retrieved. |
float RVO::RVOSimulator::getGlobalTime | ( | ) | const |
Returns the global time of the simulation.
size_t RVO::RVOSimulator::getNextObstacleVertexNo | ( | size_t | vertexNo | ) | const |
Returns the number of the obstacle vertex succeeding the specified obstacle vertex in its polygon.
vertexNo | The number of the obstacle vertex whose successor is to be retrieved. |
size_t RVO::RVOSimulator::getNumAgents | ( | ) | const |
Returns the count of agents in the simulation.
size_t RVO::RVOSimulator::getNumObstacleVertices | ( | ) | const |
Returns the count of obstacle vertices in the simulation.
const Vector2& RVO::RVOSimulator::getObstacleVertex | ( | size_t | vertexNo | ) | const |
Returns the two-dimensional position of a specified obstacle vertex.
vertexNo | The number of the obstacle vertex to be retrieved. |
size_t RVO::RVOSimulator::getPrevObstacleVertexNo | ( | size_t | vertexNo | ) | const |
Returns the number of the obstacle vertex preceding the specified obstacle vertex in its polygon.
vertexNo | The number of the obstacle vertex whose predecessor is to be retrieved. |
float RVO::RVOSimulator::getTimeStep | ( | ) | const |
Returns the time step of the simulation.
void RVO::RVOSimulator::processObstacles | ( | ) |
Processes the obstacles that have been added so that they are accounted for in the simulation.
bool RVO::RVOSimulator::queryVisibility | ( | const Vector2 & | point1, |
const Vector2 & | point2, | ||
float | radius = 0.0f |
||
) | const |
Performs a visibility query between the two specified points with respect to the obstacles.
point1 | The first point of the query. |
point2 | The second point of the query. |
radius | 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. |
void RVO::RVOSimulator::setAgentDefaults | ( | float | neighborDist, |
size_t | maxNeighbors, | ||
float | timeHorizon, | ||
float | timeHorizonObst, | ||
float | radius, | ||
float | maxSpeed, | ||
const Vector2 & | velocity = Vector2() |
||
) |
Sets the default properties for any new agent that is added.
neighborDist | 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 | 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 | 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 | 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 | The default radius of a new agent. Must be non-negative. |
maxSpeed | The default maximum speed of a new agent. Must be non-negative. |
velocity | The default initial two-dimensional linear velocity of a new agent (optional). |
void RVO::RVOSimulator::setAgentMaxNeighbors | ( | size_t | agentNo, |
size_t | maxNeighbors | ||
) |
Sets the maximum neighbor count of a specified agent.
agentNo | The number of the agent whose maximum neighbor count is to be modified. |
maxNeighbors | The replacement maximum neighbor count. |
void RVO::RVOSimulator::setAgentMaxSpeed | ( | size_t | agentNo, |
float | maxSpeed | ||
) |
Sets the maximum speed of a specified agent.
agentNo | The number of the agent whose maximum speed is to be modified. |
maxSpeed | The replacement maximum speed. Must be non-negative. |
void RVO::RVOSimulator::setAgentNeighborDist | ( | size_t | agentNo, |
float | neighborDist | ||
) |
Sets the maximum neighbor distance of a specified agent.
agentNo | The number of the agent whose maximum neighbor distance is to be modified. |
neighborDist | The replacement maximum neighbor distance. Must be non-negative. |
void RVO::RVOSimulator::setAgentPosition | ( | size_t | agentNo, |
const Vector2 & | position | ||
) |
Sets the two-dimensional position of a specified agent.
agentNo | The number of the agent whose two-dimensional position is to be modified. |
position | The replacement of the two-dimensional position. |
void RVO::RVOSimulator::setAgentPrefVelocity | ( | size_t | agentNo, |
const Vector2 & | prefVelocity | ||
) |
Sets the two-dimensional preferred velocity of a specified agent.
agentNo | The number of the agent whose two-dimensional preferred velocity is to be modified. |
prefVelocity | The replacement of the two-dimensional preferred velocity. |
void RVO::RVOSimulator::setAgentRadius | ( | size_t | agentNo, |
float | radius | ||
) |
Sets the radius of a specified agent.
agentNo | The number of the agent whose radius is to be modified. |
radius | The replacement radius. Must be non-negative. |
void RVO::RVOSimulator::setAgentTimeHorizon | ( | size_t | agentNo, |
float | timeHorizon | ||
) |
Sets the time horizon of a specified agent with respect to other agents.
agentNo | The number of the agent whose time horizon is to be modified. |
timeHorizon | The replacement time horizon with respect to other agents. Must be positive. |
void RVO::RVOSimulator::setAgentTimeHorizonObst | ( | size_t | agentNo, |
float | timeHorizonObst | ||
) |
Sets the time horizon of a specified agent with respect to obstacles.
agentNo | The number of the agent whose time horizon with respect to obstacles is to be modified. |
timeHorizonObst | The replacement time horizon with respect to obstacles. Must be positive. |
void RVO::RVOSimulator::setAgentVelocity | ( | size_t | agentNo, |
const Vector2 & | velocity | ||
) |
Sets the two-dimensional linear velocity of a specified agent.
agentNo | The number of the agent whose two-dimensional linear velocity is to be modified. |
velocity | The replacement two-dimensional linear velocity. |
void RVO::RVOSimulator::setTimeStep | ( | float | timeStep | ) |
Sets the time step of the simulation.
timeStep | The time step of the simulation. Must be positive. |