Public Member Functions | Friends | List of all members
hrvo::Simulator Class Reference

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
 

Detailed Description

The simulation.

Member Function Documentation

◆ addAgent() [1/2]

std::size_t hrvo::Simulator::addAgent ( const Vector2 position,
std::size_t  goalNo 
)

Adds a new agent with default properties to the simulation.

Parameters
[in]positionThe starting position of this agent.
[in]goalNoThe goal number of this agent.
Returns
The number of the agent.

◆ addAgent() [2/2]

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.

Parameters
[in]positionThe starting position of this agent.
[in]goalNoThe goal number of this agent.
[in]neighborDistThe maximum neighbor distance of this agent.
[in]maxNeighborsThe maximum neighbor count of this agent.
[in]radiusThe radius of this agent.
[in]goalRadiusThe goal radius of this agent.
[in]prefSpeedThe preferred speed of this agent.
[in]maxSpeedThe maximum speed of this agent.
[in]uncertaintyOffsetThe uncertainty offset of this agent.
[in]maxAccelThe maximum acceleration of this agent.
[in]velocityThe initial velocity of this agent.
[in]orientationThe initial orientation (in radians) of this agent.
Returns
The number of the agent.

◆ addGoal()

std::size_t hrvo::Simulator::addGoal ( const Vector2 position)

Adds a new goal to the simulation.

Parameters
[in]positionThe position of this goal.
Returns
The number of the goal.

◆ getAgentGoal()

std::size_t hrvo::Simulator::getAgentGoal ( std::size_t  agentNo) const

Returns the goal number of a specified agent.

Parameters
[in]agentNoThe number of the agent whose goal number is to be retrieved.
Returns
The present goal number of the agent.

◆ getAgentGoalRadius()

float hrvo::Simulator::getAgentGoalRadius ( std::size_t  agentNo) const

Returns the goal radius of a specified agent.

Parameters
[in]agentNoThe number of the agent whose goal radius is to be retrieved.
Returns
The present goal radius of the agent

◆ getAgentMaxAccel()

float hrvo::Simulator::getAgentMaxAccel ( std::size_t  agentNo) const

Returns the maximum acceleration of a specified agent.

Parameters
[in]agentNoThe number of the agent whose maximum acceleration is to be retrieved.
Returns
The present maximum acceleration of the agent.

◆ getAgentMaxNeighbors()

std::size_t hrvo::Simulator::getAgentMaxNeighbors ( std::size_t  agentNo) const

Returns the maximum neighbor count of a specified agent.

Parameters
[in]agentNoThe number of the agent whose maximum neighbor count is to be retrieved.
Returns
The present maximum neighbor count of the agent.

◆ getAgentMaxSpeed()

float hrvo::Simulator::getAgentMaxSpeed ( std::size_t  agentNo) const

Returns the maximum speed of a specified agent.

Parameters
[in]agentNoThe number of the agent whose maximum speed is to be retrieved.
Returns
The present maximum speed of the agent.

◆ getAgentNeighborDist()

float hrvo::Simulator::getAgentNeighborDist ( std::size_t  agentNo) const

Returns the maximum neighbor distance of a specified agent.

Parameters
[in]agentNoThe number of the agent whose maximum neighbor distance is to be retrieved.
Returns
The present maximum neighbor distance of the agent.

◆ getAgentOrientation()

float hrvo::Simulator::getAgentOrientation ( std::size_t  agentNo) const

Returns the orientation of a specified agent.

Parameters
[in]agentNoThe number of the agent whose orientation is to be retrieved.
Returns
The present orientation (in radians) of the agent.

◆ getAgentPosition()

Vector2 hrvo::Simulator::getAgentPosition ( std::size_t  agentNo) const

Returns the position of a specified agent.

Parameters
[in]agentNoThe number of the agent whose position is to be retrieved.
Returns
The present position of the (center of) the agent.

◆ getAgentPrefSpeed()

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.

Parameters
[in]agentNoThe number of the agent whose preferred speed is to be retrieved.
Returns
The present preferred speed of the agent.

◆ getAgentRadius()

float hrvo::Simulator::getAgentRadius ( std::size_t  agentNo) const

Returns the radius of a specified agent.

Parameters
[in]agentNoThe number of the agent whose radius is to be retrieved.
Returns
The present radius of the agent.

◆ getAgentReachedGoal()

bool hrvo::Simulator::getAgentReachedGoal ( std::size_t  agentNo) const

Returns the progress towards its goal of a specified agent.

Parameters
[in]agentNoThe number of the agent whose progress towards its goal is to be retrieved.
Returns
True if the agent has reached its goal; false otherwise.

◆ getAgentUncertaintyOffset()

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.

Parameters
[in]agentNoThe number of the agent whose uncertainty offset is to be retrieved.
Returns
The present uncertainty offset of the agent.

◆ getAgentVelocity()

Vector2 hrvo::Simulator::getAgentVelocity ( std::size_t  agentNo) const

Returns the velocity of a specified agent.

Parameters
[in]agentNoThe number of the agent whose velocity is to be retrieved.
Returns
The present velocity of the agent.

◆ getGlobalTime()

float hrvo::Simulator::getGlobalTime ( ) const
inline

Returns the global time of the simulation.

Returns
The present global time of the simulation (zero initially).

◆ getGoalPosition()

Vector2 hrvo::Simulator::getGoalPosition ( std::size_t  goalNo) const

Returns the position of a specified goal.

Parameters
[in]goalNoThe number of the goal whose position is to be retrieved.
Returns
The position of the goal.

◆ getNumAgents()

std::size_t hrvo::Simulator::getNumAgents ( ) const
inline

Returns the count of agents in the simulation.

Returns
The count of agents in the simulation.

◆ getNumGoals()

std::size_t hrvo::Simulator::getNumGoals ( ) const
inline

Returns the count of goals in the simulation.

Returns
The count of goals in the simulation.

◆ getTimeStep()

float hrvo::Simulator::getTimeStep ( ) const
inline

Returns the time step of the simulation.

Returns
The present time step of the simulation.

◆ haveReachedGoals()

bool hrvo::Simulator::haveReachedGoals ( ) const
inline

Returns the progress towards their goals of all agents.

Returns
True if all agents have reached their goals; false otherwise.

◆ setAgentDefaults()

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.

Parameters
[in]neighborDistThe default maximum neighbor distance of a new agent.
[in]maxNeighborsThe default maximum neighbor count of a new agent.
[in]radiusThe default radius of a new agent.
[in]goalRadiusThe default goal radius of a new agent.
[in]prefSpeedThe default preferred speed of a new agent.
[in]maxSpeedThe default maximum speed of a new agent.
[in]uncertaintyOffsetThe default uncertainty offset of a new agent.
[in]maxAccelThe default maximum acceleration of a new agent.
[in]velocityThe default initial velocity of a new agent.
[in]orientationThe default initial orientation (in radians) of a new agent.

◆ setAgentGoal()

void hrvo::Simulator::setAgentGoal ( std::size_t  agentNo,
std::size_t  goalNo 
)

Sets the goal number of a specified agent.

Parameters
[in]agentNoThe number of the agent whose goal number is to be modified.
[in]goalNoThe replacement goal number.

◆ setAgentGoalRadius()

void hrvo::Simulator::setAgentGoalRadius ( std::size_t  agentNo,
float  goalRadius 
)

Sets the goal radius of a specified agent.

Parameters
[in]agentNoThe number of the agent whose goal radius is to be modified.
[in]goalRadiusThe replacement goal radius.

◆ setAgentMaxAccel()

void hrvo::Simulator::setAgentMaxAccel ( std::size_t  agentNo,
float  maxAccel 
)

Sets the maximum linear acceleraton of a specified agent.

Parameters
[in]agentNoThe number of the agent whose maximum acceleration is to be modified.
[in]maxAccelThe replacement maximum acceleration.

◆ setAgentMaxNeighbors()

void hrvo::Simulator::setAgentMaxNeighbors ( std::size_t  agentNo,
std::size_t  maxNeighbors 
)

Sets the maximum neighbor count of a specified agent.

Parameters
[in]agentNoThe number of the agent whose maximum neighbor count is to be modified.
[in]maxNeighborsThe replacement maximum neighbor count.

◆ setAgentMaxSpeed()

void hrvo::Simulator::setAgentMaxSpeed ( std::size_t  agentNo,
float  maxSpeed 
)

Sets the maximum speed of a specified agent.

Parameters
[in]agentNoThe number of the agent whose maximum speed is to be modified.
[in]maxSpeedThe replacement maximum speed.

◆ setAgentNeighborDist()

void hrvo::Simulator::setAgentNeighborDist ( std::size_t  agentNo,
float  neighborDist 
)

Sets the maximum neighbor distance of a specified agent.

Parameters
[in]agentNoThe number of the agent whose maximum neighbor distance is to be modified.
[in]neighborDistThe replacement maximum neighbor distance.

◆ setAgentOrientation()

void hrvo::Simulator::setAgentOrientation ( std::size_t  agentNo,
float  orientation 
)

Sets the orientation of a specified agent.

Parameters
[in]agentNoThe number of the agent whose orientation is to be modified.
[in]orientationThe replacement orientation (in radians).

◆ setAgentPosition()

void hrvo::Simulator::setAgentPosition ( std::size_t  agentNo,
const Vector2 position 
)

Sets the position of a specified agent.

Parameters
[in]agentNoThe number of the agent whose position is to be modified.
[in]positionThe replacement position.

◆ setAgentPrefSpeed()

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.

Parameters
[in]agentNoThe number of the agent whose preferred speed is to be modified.
[in]prefSpeedThe replacement preferred speed.

◆ setAgentRadius()

void hrvo::Simulator::setAgentRadius ( std::size_t  agentNo,
float  radius 
)

Sets the radius of a specified agent.

Parameters
[in]agentNoThe number of the agent whose radius is to be modified.
[in]radiusThe replacement radius.

◆ setAgentUncertaintyOffset()

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.

Parameters
[in]agentNoThe number of the agent whose uncertainty offset is to be modified.
[in]uncertaintyOffsetThe replacement uncertainty offset.

◆ setAgentVelocity()

void hrvo::Simulator::setAgentVelocity ( std::size_t  agentNo,
const Vector2 velocity 
)

Sets the velocity of a specified agent.

Parameters
[in]agentNoThe number of the agent whose velocity is to be modified.
[in]velocityThe replacement velocity.

◆ setTimeStep()

void hrvo::Simulator::setTimeStep ( float  timeStep)
inline

Sets the time step of the simulation.

Parameters
[in]timeStepThe replacement time step of the simulation.

The documentation for this class was generated from the following file: