The simulation. More...
#include <Simulator.h>
Public Member Functions | |
Simulator () | |
Constructor. | |
~Simulator () | |
Destructor. | |
std::size_t | addAgent (const Vector2 &position, std::size_t goalNo) |
Adds a new agent with default properties to the simulation. More... | |
std::size_t | addAgent (const Vector2 &position, std::size_t goalNo, float neighborDist, std::size_t maxNeighbors, float radius, float goalRadius, float prefSpeed, float maxSpeed, float uncertaintyOffset=0.0f, float maxAccel=std::numeric_limits< float >::infinity(), const Vector2 &velocity=Vector2(0.0f, 0.0f), float orientation=0.0f) |
Adds a new agent to the simulation. More... | |
std::size_t | addGoal (const Vector2 &position) |
Adds a new goal to the simulation. More... | |
void | doStep () |
Performs a simulation step; updates the orientation, position, and velocity of each agent, and the progress of each towards its goal. | |
std::size_t | getAgentGoal (std::size_t agentNo) const |
Returns the goal number of a specified agent. More... | |
float | getAgentGoalRadius (std::size_t agentNo) const |
Returns the goal radius of a specified agent. More... | |
float | getAgentMaxAccel (std::size_t agentNo) const |
Returns the maximum acceleration of a specified agent. More... | |
std::size_t | getAgentMaxNeighbors (std::size_t agentNo) const |
Returns the maximum neighbor count of a specified agent. More... | |
float | getAgentMaxSpeed (std::size_t agentNo) const |
Returns the maximum speed of a specified agent. More... | |
float | getAgentNeighborDist (std::size_t agentNo) const |
Returns the maximum neighbor distance of a specified agent. More... | |
float | getAgentOrientation (std::size_t agentNo) const |
Returns the orientation of a specified agent. More... | |
Vector2 | getAgentPosition (std::size_t agentNo) const |
Returns the position of a specified agent. More... | |
float | getAgentPrefSpeed (std::size_t agentNo) const |
Returns the preferred speed of a specified agent. More... | |
float | getAgentRadius (std::size_t agentNo) const |
Returns the radius of a specified agent. More... | |
bool | getAgentReachedGoal (std::size_t agentNo) const |
Returns the progress towards its goal of a specified agent. More... | |
float | getAgentUncertaintyOffset (std::size_t agentNo) const |
Returns the "uncertainty offset" of a specified agent. More... | |
Vector2 | getAgentVelocity (std::size_t agentNo) const |
Returns the velocity of a specified agent. More... | |
float | getGlobalTime () const |
Returns the global time of the simulation. More... | |
Vector2 | getGoalPosition (std::size_t goalNo) const |
Returns the position of a specified goal. More... | |
std::size_t | getNumAgents () const |
Returns the count of agents in the simulation. More... | |
std::size_t | getNumGoals () const |
Returns the count of goals in the simulation. More... | |
float | getTimeStep () const |
Returns the time step of the simulation. More... | |
bool | haveReachedGoals () const |
Returns the progress towards their goals of all agents. More... | |
void | setAgentDefaults (float neighborDist, std::size_t maxNeighbors, float radius, float goalRadius, float prefSpeed, float maxSpeed, float uncertaintyOffset=0.0f, float maxAccel=std::numeric_limits< float >::infinity(), const Vector2 &velocity=Vector2(), float orientation=0.0f) |
Sets the default properties for any new agent that is added. More... | |
void | setAgentGoal (std::size_t agentNo, std::size_t goalNo) |
Sets the goal number of a specified agent. More... | |
void | setAgentGoalRadius (std::size_t agentNo, float goalRadius) |
Sets the goal radius of a specified agent. More... | |
void | setAgentMaxAccel (std::size_t agentNo, float maxAccel) |
Sets the maximum linear acceleraton of a specified agent. More... | |
void | setAgentMaxNeighbors (std::size_t agentNo, std::size_t maxNeighbors) |
Sets the maximum neighbor count of a specified agent. More... | |
void | setAgentMaxSpeed (std::size_t agentNo, float maxSpeed) |
Sets the maximum speed of a specified agent. More... | |
void | setAgentNeighborDist (std::size_t agentNo, float neighborDist) |
Sets the maximum neighbor distance of a specified agent. More... | |
void | setAgentOrientation (std::size_t agentNo, float orientation) |
Sets the orientation of a specified agent. More... | |
void | setAgentPosition (std::size_t agentNo, const Vector2 &position) |
Sets the position of a specified agent. More... | |
void | setAgentPrefSpeed (std::size_t agentNo, float prefSpeed) |
Sets the preferred speed of a specified agent. More... | |
void | setAgentRadius (std::size_t agentNo, float radius) |
Sets the radius of a specified agent. More... | |
void | setAgentUncertaintyOffset (std::size_t agentNo, float uncertaintyOffset) |
Sets the "uncertainty offset" of a specified agent. More... | |
void | setAgentVelocity (std::size_t agentNo, const Vector2 &velocity) |
Sets the velocity of a specified agent. More... | |
void | setTimeStep (float timeStep) |
Sets the time step of the simulation. More... | |
Friends | |
class | Agent |
class | Goal |
class | KdTree |
The simulation.
std::size_t hrvo::Simulator::addAgent | ( | const Vector2 & | position, |
std::size_t | goalNo | ||
) |
Adds a new agent with default properties to the simulation.
[in] | position | The starting position of this agent. |
[in] | goalNo | The goal number of this agent. |
std::size_t hrvo::Simulator::addAgent | ( | const Vector2 & | position, |
std::size_t | goalNo, | ||
float | neighborDist, | ||
std::size_t | maxNeighbors, | ||
float | radius, | ||
float | goalRadius, | ||
float | prefSpeed, | ||
float | maxSpeed, | ||
float | uncertaintyOffset = 0.0f , |
||
float | maxAccel = std::numeric_limits< float >::infinity() , |
||
const Vector2 & | velocity = Vector2(0.0f, 0.0f) , |
||
float | orientation = 0.0f |
||
) |
Adds a new agent to the simulation.
[in] | position | The starting position of this agent. |
[in] | goalNo | The goal number of this agent. |
[in] | neighborDist | The maximum neighbor distance of this agent. |
[in] | maxNeighbors | The maximum neighbor count of this agent. |
[in] | radius | The radius of this agent. |
[in] | goalRadius | The goal radius of this agent. |
[in] | prefSpeed | The preferred speed of this agent. |
[in] | maxSpeed | The maximum speed of this agent. |
[in] | uncertaintyOffset | The uncertainty offset of this agent. |
[in] | maxAccel | The maximum acceleration of this agent. |
[in] | velocity | The initial velocity of this agent. |
[in] | orientation | The initial orientation (in radians) of this agent. |
std::size_t hrvo::Simulator::addGoal | ( | const Vector2 & | position | ) |
Adds a new goal to the simulation.
[in] | position | The position of this goal. |
std::size_t hrvo::Simulator::getAgentGoal | ( | std::size_t | agentNo | ) | const |
Returns the goal number of a specified agent.
[in] | agentNo | The number of the agent whose goal number is to be retrieved. |
float hrvo::Simulator::getAgentGoalRadius | ( | std::size_t | agentNo | ) | const |
Returns the goal radius of a specified agent.
[in] | agentNo | The number of the agent whose goal radius is to be retrieved. |
float hrvo::Simulator::getAgentMaxAccel | ( | std::size_t | agentNo | ) | const |
Returns the maximum acceleration of a specified agent.
[in] | agentNo | The number of the agent whose maximum acceleration is to be retrieved. |
std::size_t hrvo::Simulator::getAgentMaxNeighbors | ( | std::size_t | agentNo | ) | const |
Returns the maximum neighbor count of a specified agent.
[in] | agentNo | The number of the agent whose maximum neighbor count is to be retrieved. |
float hrvo::Simulator::getAgentMaxSpeed | ( | std::size_t | agentNo | ) | const |
Returns the maximum speed of a specified agent.
[in] | agentNo | The number of the agent whose maximum speed is to be retrieved. |
float hrvo::Simulator::getAgentNeighborDist | ( | std::size_t | agentNo | ) | const |
Returns the maximum neighbor distance of a specified agent.
[in] | agentNo | The number of the agent whose maximum neighbor distance is to be retrieved. |
float hrvo::Simulator::getAgentOrientation | ( | std::size_t | agentNo | ) | const |
Returns the orientation of a specified agent.
[in] | agentNo | The number of the agent whose orientation is to be retrieved. |
Vector2 hrvo::Simulator::getAgentPosition | ( | std::size_t | agentNo | ) | const |
Returns the position of a specified agent.
[in] | agentNo | The number of the agent whose position is to be retrieved. |
float hrvo::Simulator::getAgentPrefSpeed | ( | std::size_t | agentNo | ) | const |
Returns the preferred speed of a specified agent.
The preferred speed of an agent is the speed it would choose to take if it were not influenced by other agents.
[in] | agentNo | The number of the agent whose preferred speed is to be retrieved. |
float hrvo::Simulator::getAgentRadius | ( | std::size_t | agentNo | ) | const |
Returns the radius of a specified agent.
[in] | agentNo | The number of the agent whose radius is to be retrieved. |
bool hrvo::Simulator::getAgentReachedGoal | ( | std::size_t | agentNo | ) | const |
Returns the progress towards its goal of a specified agent.
[in] | agentNo | The number of the agent whose progress towards its goal is to be retrieved. |
float hrvo::Simulator::getAgentUncertaintyOffset | ( | std::size_t | agentNo | ) | const |
Returns the "uncertainty offset" of a specified agent.
The uncertainty offset is the amount velocity obstacles are widened to allow for uncertainty in the position and velocity of a differential drive agent.
[in] | agentNo | The number of the agent whose uncertainty offset is to be retrieved. |
Vector2 hrvo::Simulator::getAgentVelocity | ( | std::size_t | agentNo | ) | const |
Returns the velocity of a specified agent.
[in] | agentNo | The number of the agent whose velocity is to be retrieved. |
|
inline |
Returns the global time of the simulation.
Vector2 hrvo::Simulator::getGoalPosition | ( | std::size_t | goalNo | ) | const |
Returns the position of a specified goal.
[in] | goalNo | The number of the goal whose position is to be retrieved. |
|
inline |
Returns the count of agents in the simulation.
|
inline |
Returns the count of goals in the simulation.
|
inline |
Returns the time step of the simulation.
|
inline |
Returns the progress towards their goals of all agents.
void hrvo::Simulator::setAgentDefaults | ( | float | neighborDist, |
std::size_t | maxNeighbors, | ||
float | radius, | ||
float | goalRadius, | ||
float | prefSpeed, | ||
float | maxSpeed, | ||
float | uncertaintyOffset = 0.0f , |
||
float | maxAccel = std::numeric_limits< float >::infinity() , |
||
const Vector2 & | velocity = Vector2() , |
||
float | orientation = 0.0f |
||
) |
Sets the default properties for any new agent that is added.
[in] | neighborDist | The default maximum neighbor distance of a new agent. |
[in] | maxNeighbors | The default maximum neighbor count of a new agent. |
[in] | radius | The default radius of a new agent. |
[in] | goalRadius | The default goal radius of a new agent. |
[in] | prefSpeed | The default preferred speed of a new agent. |
[in] | maxSpeed | The default maximum speed of a new agent. |
[in] | uncertaintyOffset | The default uncertainty offset of a new agent. |
[in] | maxAccel | The default maximum acceleration of a new agent. |
[in] | velocity | The default initial velocity of a new agent. |
[in] | orientation | The default initial orientation (in radians) of a new agent. |
void hrvo::Simulator::setAgentGoal | ( | std::size_t | agentNo, |
std::size_t | goalNo | ||
) |
Sets the goal number of a specified agent.
[in] | agentNo | The number of the agent whose goal number is to be modified. |
[in] | goalNo | The replacement goal number. |
void hrvo::Simulator::setAgentGoalRadius | ( | std::size_t | agentNo, |
float | goalRadius | ||
) |
Sets the goal radius of a specified agent.
[in] | agentNo | The number of the agent whose goal radius is to be modified. |
[in] | goalRadius | The replacement goal radius. |
void hrvo::Simulator::setAgentMaxAccel | ( | std::size_t | agentNo, |
float | maxAccel | ||
) |
Sets the maximum linear acceleraton of a specified agent.
[in] | agentNo | The number of the agent whose maximum acceleration is to be modified. |
[in] | maxAccel | The replacement maximum acceleration. |
void hrvo::Simulator::setAgentMaxNeighbors | ( | std::size_t | agentNo, |
std::size_t | maxNeighbors | ||
) |
Sets the maximum neighbor count of a specified agent.
[in] | agentNo | The number of the agent whose maximum neighbor count is to be modified. |
[in] | maxNeighbors | The replacement maximum neighbor count. |
void hrvo::Simulator::setAgentMaxSpeed | ( | std::size_t | agentNo, |
float | maxSpeed | ||
) |
Sets the maximum speed of a specified agent.
[in] | agentNo | The number of the agent whose maximum speed is to be modified. |
[in] | maxSpeed | The replacement maximum speed. |
void hrvo::Simulator::setAgentNeighborDist | ( | std::size_t | agentNo, |
float | neighborDist | ||
) |
Sets the maximum neighbor distance of a specified agent.
[in] | agentNo | The number of the agent whose maximum neighbor distance is to be modified. |
[in] | neighborDist | The replacement maximum neighbor distance. |
void hrvo::Simulator::setAgentOrientation | ( | std::size_t | agentNo, |
float | orientation | ||
) |
Sets the orientation of a specified agent.
[in] | agentNo | The number of the agent whose orientation is to be modified. |
[in] | orientation | The replacement orientation (in radians). |
void hrvo::Simulator::setAgentPosition | ( | std::size_t | agentNo, |
const Vector2 & | position | ||
) |
Sets the position of a specified agent.
[in] | agentNo | The number of the agent whose position is to be modified. |
[in] | position | The replacement position. |
void hrvo::Simulator::setAgentPrefSpeed | ( | std::size_t | agentNo, |
float | prefSpeed | ||
) |
Sets the preferred speed of a specified agent.
The preferred speed of an agent is the speed it would choose to take if it were not influenced by other agents.
[in] | agentNo | The number of the agent whose preferred speed is to be modified. |
[in] | prefSpeed | The replacement preferred speed. |
void hrvo::Simulator::setAgentRadius | ( | std::size_t | agentNo, |
float | radius | ||
) |
Sets the radius of a specified agent.
[in] | agentNo | The number of the agent whose radius is to be modified. |
[in] | radius | The replacement radius. |
void hrvo::Simulator::setAgentUncertaintyOffset | ( | std::size_t | agentNo, |
float | uncertaintyOffset | ||
) |
Sets the "uncertainty offset" of a specified agent.
The uncertainty offset is the amount velocity obstacles are widened to allow for uncertainty in the position and velocity of a differential drive agent.
[in] | agentNo | The number of the agent whose uncertainty offset is to be modified. |
[in] | uncertaintyOffset | The replacement uncertainty offset. |
void hrvo::Simulator::setAgentVelocity | ( | std::size_t | agentNo, |
const Vector2 & | velocity | ||
) |
Sets the velocity of a specified agent.
[in] | agentNo | The number of the agent whose velocity is to be modified. |
[in] | velocity | The replacement velocity. |
|
inline |
Sets the time step of the simulation.
[in] | timeStep | The replacement time step of the simulation. |