PPL API Reference
Overview Core Algorithm Abstractions Utilities Parallel Methods
Modules Class Hierarchy Classes Functions
Todo List Bug List Dead Code
List of all members | Protected Member Functions
Agent Class Referenceabstract

Public Member Functions

Agent Properties
RobotGetRobot () const noexcept
 Get the robot object to which this agent belongs.
 
virtual bool IsChild () const noexcept
 Is this agent a child of some group/aggregate?
 
Task Management
virtual void SetTask (const std::shared_ptr< MPTask > _task)
 
std::shared_ptr< MPTaskGetTask () const noexcept
 Get the task that the agent is currently working on.
 
virtual void ResetStartConstraint ()
 
Simulation Interface
virtual void Initialize ()=0
 
virtual void Step (const double _dt)=0
 
virtual void Uninitialize ()=0
 
size_t MinimumSteps () const
 
std::vector< Agent * > ProximityCheck (const double _distance) const
 
Agent Control
void Halt ()
 
void PauseAgent (const size_t _steps)
 
Accessors
const std::string & GetCapability () const noexcept
 Get the type of agent.
 

Protected Member Functions

void Localize ()
 Instruct the agent to enqueue a command for gathering sensor readings.
 
bool IsLocalizing () const noexcept
 Is the agent waiting on sensor data?
 
Cfg EstimateState ()
 Estimate the state of the robot from the last localization data.
 
bool ContinueLastControls ()
 
virtual void ExecuteControls (const ControlSet &_c, const size_t _steps)
 
virtual void ExecuteControlsSimulation (const ControlSet &_c, const size_t _steps)
 
virtual void ExecuteControlsHardware (const ControlSet &_c, const size_t _steps)
 

Protected Attributes

Internal State
Robot *const m_robot
 The robot that this agent controls.
 
bool m_initialized {false}
 Is the agent initialized?
 
std::shared_ptr< MPTaskm_task
 The task this agent is working on.
 
ControlSet m_currentControls
 The current control set.
 
size_t m_stepsRemaining {0}
 Steps remaining on current controls.
 
bool m_debug {true}
 Toggle debug messages.
 
std::string m_capability
 Specifies the type of agent for heterogenous multiagent teams. More...
 
std::unique_ptr< StepFunctionm_stepFunction
 

Construction

 Agent (Robot *const _r)
 
 Agent (Robot *const _r, XMLNode &_node)
 
 Agent (Robot *const _r, const Agent &_a)
 
virtual std::unique_ptr< AgentClone (Robot *const _r) const =0
 
virtual ~Agent ()
 
static std::unique_ptr< AgentFactory (Robot *const _r, XMLNode &_node)
 

Detailed Description

The decision-making faculties of a robot.

Agents are used with simulated robots. On each time step of the simulation, the agent decides what the robot will do and sends an appropriate command to the controller.

Constructor & Destructor Documentation

◆ Agent() [1/3]

Agent::Agent ( Robot *const  _r)

Create an agent for a robot.

Parameters
_rThe robot which this agent will reason for.

◆ Agent() [2/3]

Agent::Agent ( Robot *const  _r,
XMLNode _node 
)

Create an agent for a robot.

Parameters
_rThe robot which this agent will reason for.
_nodeThe XML node to parse.

◆ Agent() [3/3]

Agent::Agent ( Robot *const  _r,
const Agent _a 
)

Copy an agent for another robot.

Parameters
_rThe destination robot.
_aThe agent to copy.

Member Function Documentation

◆ Factory()

std::unique_ptr< Agent > Agent::Factory ( Robot *const  _r,
XMLNode _node 
)
static

Create a dynamically-allocated agent from an XML node.

Parameters
_rThe robot which this agent will reason for.
_nodeThe XML node to parse.
Returns
An agent of the type specified by _node.

◆ Clone()

virtual std::unique_ptr< Agent > Agent::Clone ( Robot *const  _r) const
pure virtual

Create a copy of this agent for another robot. This is provided so that we can copy an agent without knowing its type.

Parameters
_rThe robot which this cloned agent will reason for.
Returns
A copy of the agent.

Implemented in Coordinator, PathFollowingAgent, and PlanningAgent.

◆ SetTask()

void Agent::SetTask ( const std::shared_ptr< MPTask _task)
virtual

Set the task for this agent.

Parameters
_taskThe new task for this agent. Should be owned by the MPProblem.

Reimplemented in PlanningAgent.

◆ ResetStartConstraint()

void Agent::ResetStartConstraint ( )
virtual

Resets the start constraint of the current task to the robot's current position.

◆ Initialize()

virtual void Agent::Initialize ( )
pure virtual

Set up the agent before running. Anything that needs to be done only once on first starting should go here.

Implemented in Coordinator, and PlanningAgent.

◆ Step()

virtual void Agent::Step ( const double  _dt)
pure virtual

Decide what to do on each time step in the simulation. The agent should implement its decision by sending commands to the robot's controller.

Parameters
_dtThe timestep length.

Implemented in Coordinator, and PlanningAgent.

◆ Uninitialize()

virtual void Agent::Uninitialize ( )
pure virtual

Tear down the agent. Release any resources and reset the object to its pre-initialize state.

Implemented in Coordinator, PathFollowingAgent, and PlanningAgent.

◆ MinimumSteps()

size_t Agent::MinimumSteps ( ) const

Find the smallest time interval which is an integer multiple of the problem time resolution and larger than the hardware time (if any).

◆ ProximityCheck()

std::vector< Agent * > Agent::ProximityCheck ( const double  _distance) const

Check for proximity to other robots and return those that lie within some threshold. @WARNING This checks the distance between the robots' reference points; it does not indicate the minimum distance between their hulls.

Parameters
_distanceThe distance threshold.
Returns
The vector of Robots within the threshold.

◆ Halt()

void Agent::Halt ( )

Stop the robot in simulation (places 0s in all 6 velocity dofs). @WARNING Arbitrarily setting the velocity does not respect the robot's dynamics. It is suitable for debugging and freezing a scenario upon completion, but it is not physically realistic.

◆ PauseAgent()

void Agent::PauseAgent ( const size_t  _steps)

Orders the agent to stop itself at its current position. It will ask the controller to choose actions which stay as close as possible to the current position.

Parameters
_stepsThe number of steps to stop for.

◆ ContinueLastControls()

bool Agent::ContinueLastControls ( )
protected

Continue executing the last controls if time remains.

Returns
True if time is left on the last controls, false if the agent is finished and needs new controls.

◆ ExecuteControls()

void Agent::ExecuteControls ( const ControlSet &  _c,
const size_t  _steps 
)
protectedvirtual

Execute a set of controls on the simulated robot, and additionally on the hardware if present.

Parameters
_cThe controls to execute.
_stepsThe number of time steps to execute the control.

◆ ExecuteControlsSimulation()

void Agent::ExecuteControlsSimulation ( const ControlSet &  _c,
const size_t  _steps 
)
protectedvirtual

Execute a set of controls on the simulated robot.

Parameters
_cThe controls to execute.

◆ ExecuteControlsHardware()

void Agent::ExecuteControlsHardware ( const ControlSet &  _c,
const size_t  _steps 
)
protectedvirtual

Execute a set of controls on the hardware if present.

Parameters
_cThe controls to execute.
_stepsThe number of time steps to execute the control.

Member Data Documentation

◆ m_capability

std::string Agent::m_capability
protected

Specifies the type of agent for heterogenous multiagent teams.

Step function to define agent behaviors.


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