#include <RVOSimulator.h>
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 Vector2 & | getAgentPosition (int agentID) const |
float | getAgentPrefSpeed (int agentID) const |
float | getAgentRadius (int agentID) const |
bool | getAgentReachedGoal (int agentID) const |
float | getAgentSafetyFactor (int agentID) const |
const Vector2 & | getAgentVelocity (int agentID) const |
int | getAgentVelSampleCount (int agentID) const |
float | getGlobalTime () const |
int | getGoalNeighbor (int goalID, int neighborNr) const |
int | getGoalNumNeighbors (int goalID) const |
const Vector2 & | getGoalPosition (int goalID) const |
int | getNumAgents () const |
int | getNumGoals () const |
int | getNumObstacles () const |
int | getNumRoadmapVertices () const |
const Vector2 & | getObstaclePoint1 (int obstacleID) const |
const Vector2 & | getObstaclePoint2 (int obstacleID) const |
bool | getReachedGoal () const |
int | getRoadmapVertexNeighbor (int vertexID, int neighborNr) const |
int | getRoadmapVertexNumNeighbors (int vertexID) const |
const Vector2 & | getRoadmapVertexPosition (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 RVOSimulator * | Instance () |
The main class of the RVO library.
RVO::RVOSimulator::~RVOSimulator | ( | ) |
Deconstructor of the RVOSimulator instance.
int RVO::RVOSimulator::addAgent | ( | const Vector2 & | startPosition, | |
int | goalID | |||
) |
Adds an agent with default parameters to the simulation.
startPosition | The start position of the agent | |
goalID | The ID of the goal of the agent |
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.
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 |
int RVO::RVOSimulator::addGoal | ( | const Vector2 & | position | ) |
Adds a goal position to the simulation.
position | The position of the goal |
Adds a line segment obstacle to the simulation.
point1 | The position of the first endpoint of the line segment obstacle | |
point2 | The position of the second endpoint of the line segment obstacle |
int RVO::RVOSimulator::addRoadmapEdge | ( | int | vertexID1, | |
int | vertexID2 | |||
) |
Adds an edge between two vertices of the roadmap. The roadmap is undirected.
vertexID1 | The ID of the first vertex of the edge | |
vertexID2 | The ID of the second vertex of the edge |
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.
position | The position of the roadmap vertex |
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.
int RVO::RVOSimulator::getAgentClass | ( | int | agentID | ) | const |
Retrieving the class of an agent.
agentID | The agent's ID |
int RVO::RVOSimulator::getAgentGoal | ( | int | agentID | ) | const |
Retrieving the goal of an agent.
agentID | The agent's ID |
float RVO::RVOSimulator::getAgentGoalRadius | ( | int | agentID | ) | const |
Retrieving the goal radius of an agent.
agentID | The agent's ID |
float RVO::RVOSimulator::getAgentMaxAccel | ( | int | agentID | ) | const |
Retrieving the maximum acceleration of an agent.
agentID | The agent's ID |
int RVO::RVOSimulator::getAgentMaxNeighbors | ( | int | agentID | ) | const |
Retrieving the maximum number of neighbors of an agent.
agentID | The agent's ID |
float RVO::RVOSimulator::getAgentMaxSpeed | ( | int | agentID | ) | const |
Retrieving the maximum speed of an agent.
agentID | The agent's ID |
float RVO::RVOSimulator::getAgentNeighborDist | ( | int | agentID | ) | const |
Retrieving the neighbor distance of an agent
agentID | The agent's ID |
float RVO::RVOSimulator::getAgentOrientation | ( | int | agentID | ) | const |
Retrieving the current orientation of an agent.
agentID | The agent's ID |
const Vector2& RVO::RVOSimulator::getAgentPosition | ( | int | agentID | ) | const |
Retrieving the current position of an agent.
agentID | The agent's ID |
float RVO::RVOSimulator::getAgentPrefSpeed | ( | int | agentID | ) | const |
Retrieving the preferred speed of an agent.
agentID | The agent's ID |
float RVO::RVOSimulator::getAgentRadius | ( | int | agentID | ) | const |
Retrieving the radius of an agent.
agentID | The agent's ID |
bool RVO::RVOSimulator::getAgentReachedGoal | ( | int | agentID | ) | const |
Retrieving whether an agent has reached its goal.
agentID | The agent's ID |
float RVO::RVOSimulator::getAgentSafetyFactor | ( | int | agentID | ) | const |
Retrieving the safety factor of an agent.
agentID | The agent's ID |
const Vector2& RVO::RVOSimulator::getAgentVelocity | ( | int | agentID | ) | const |
Retrieving the current velocity of an agent.
agentID | The agent's ID |
int RVO::RVOSimulator::getAgentVelSampleCount | ( | int | agentID | ) | const |
Retrieving the sample number of an agent
agentID | The agent's ID |
float RVO::RVOSimulator::getGlobalTime | ( | ) | const |
int RVO::RVOSimulator::getGoalNeighbor | ( | int | goalID, | |
int | neighborNr | |||
) | const |
Retrieving the ID of a roadmap vertex connected to a goal.
goalID | The goal's ID | |
neighborNr | The neighbor number |
int RVO::RVOSimulator::getGoalNumNeighbors | ( | int | goalID | ) | const |
Retrieving the number of roadmap vertices connected to a goal.
goalID | The goal's ID |
const Vector2& RVO::RVOSimulator::getGoalPosition | ( | int | goalID | ) | const |
Retrieving the position of a goal.
goalID | The goal's ID |
int RVO::RVOSimulator::getNumAgents | ( | ) | const |
int RVO::RVOSimulator::getNumGoals | ( | ) | const |
int RVO::RVOSimulator::getNumObstacles | ( | ) | const |
int RVO::RVOSimulator::getNumRoadmapVertices | ( | ) | const |
const Vector2& RVO::RVOSimulator::getObstaclePoint1 | ( | int | obstacleID | ) | const |
Retrieving the first endpoint of an obstacle.
obstacleID | The obstacle's ID |
const Vector2& RVO::RVOSimulator::getObstaclePoint2 | ( | int | obstacleID | ) | const |
Retrieving the second endpoint of an obstacle.
obstacleID | The obstacle's ID |
bool RVO::RVOSimulator::getReachedGoal | ( | ) | const |
int RVO::RVOSimulator::getRoadmapVertexNeighbor | ( | int | vertexID, | |
int | neighborNr | |||
) | const |
Retrieving the ID of a roadmap vertex connected to a vertex in the roadmap.
vertexID | The vertex' ID | |
neighborNr | The neighbor number |
int RVO::RVOSimulator::getRoadmapVertexNumNeighbors | ( | int | vertexID | ) | const |
Retrieving the number of roadmap vertices connected to a vertex in the roadmap.
vertexID | The vertex' ID |
const Vector2& RVO::RVOSimulator::getRoadmapVertexPosition | ( | int | vertexID | ) | const |
Retrieving the position of a vertex in the roadmap.
vertexID | The vertex' ID |
float RVO::RVOSimulator::getTimeStep | ( | ) | const |
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.
void RVO::RVOSimulator::setAgentClass | ( | int | agentID, | |
int | classID | |||
) |
Sets the class of an agent.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
stepSize | The new time step of the simulation. |