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
PlanningAgent Class Reference

Public Member Functions

Construction
 PlanningAgent (Robot *const _r)
 
 PlanningAgent (Robot *const _r, const PlanningAgent &_a)
 
 PlanningAgent (Robot *const _r, XMLNode &_node)
 
virtual std::unique_ptr< AgentClone (Robot *const _r) const override
 
virtual ~PlanningAgent ()
 
Agent Overrides
virtual void Initialize () override
 
virtual void Step (const double _dt) override
 
virtual void Uninitialize () override
 
virtual void SetTask (std::shared_ptr< MPTask > const _task) override
 
Planning
virtual bool HasPlan () const
 
virtual void ClearPlan ()
 
bool IsPlanning () const
 
size_t GetPlanVersion () const
 
MPSolution * GetMPSolution ()
 
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
std::shared_ptr< MPTaskGetTask () const noexcept
 Get the task that the agent is currently working on.
 
virtual void ResetStartConstraint ()
 
Simulation Interface
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.
 

Static Public Member Functions

Construction
static std::unique_ptr< AgentFactory (Robot *const _r, XMLNode &_node)
 

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)
 
Planning Helpers
virtual void GeneratePlan ()
 
virtual void WorkFunction (std::shared_ptr< MPProblem > _problem)
 Function call for PPL. More...
 
void StopPlanning ()
 
Task Helpers
virtual bool SelectTask ()
 
virtual bool EvaluateTask ()
 
virtual void ExecuteTask (const double _dt)
 
Localization Helpers
void UpdateSimulatedState ()
 

Protected Attributes

Internal State
std::unique_ptr< MPLibrary > m_library
 This agent's planning library.
 
std::unique_ptr< MPSolution > m_solution
 The current solution.
 
std::thread m_thread
 Thread for agent to run PPL.
 
std::atomic< bool > m_planning {false}
 Is the agent currently planning.
 
std::atomic< size_t > m_planVersion {1}
 The current plan version.
 
size_t m_roadmapVisualID {size_t(-1)}
 The ID of the roadmap drawing.
 
size_t m_pathVisualID {size_t(-1)}
 The ID of the path drawing.
 
size_t m_localizePeriod {200}
 The number of timesteps between localize calls.
 
size_t m_localizeCount {1}
 The number of timesteps since the last localize call.
 
double m_localizeErrorThreshold {0.4}
 The largest allowed error before requiring a replan.
 
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
 

Detailed Description

Base class for agents which will plan paths using PPL. This agent only plans; it does not attempt to execute the plan in the simulation.

The core behavior is: 1. If no task, select one (or pass if none is available). 2. If no plan, create one (in a separate thread, robot waits during planning). 3. Continue executing current plan.

There are two primary mechanisms for directing agents of this type: 1. The task: describes the agent's planning task/high level goal. Without a task, the agent will not attempt to do anything. 2. The plan: describes the agent's motion plan for achieving the task. Clearing this without clearing the task will cause the agent to replan.

Whenever the agent produces a new plan or clears an existing one, its 'plan version' will be incremented by one. This allows coordinated agents to detect changes in each others' plans and possibly react/replan in response.

Constructor & Destructor Documentation

◆ PlanningAgent() [1/3]

PlanningAgent::PlanningAgent ( Robot *const  _r)

Create an agent for a robot.

Parameters
_rThe robot which this agent will reason for.

◆ PlanningAgent() [2/3]

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

Copy an agent for another robot.

Parameters
_rThe destination robot.
_aThe agent to copy.

◆ PlanningAgent() [3/3]

PlanningAgent::PlanningAgent ( 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.

Member Function Documentation

◆ Clone()

std::unique_ptr< Agent > PlanningAgent::Clone ( Robot *const  _r) const
overridevirtual

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.

Implements Agent.

Reimplemented in PathFollowingAgent.

◆ Initialize()

void PlanningAgent::Initialize ( )
overridevirtual

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

Implements Agent.

◆ Step()

void PlanningAgent::Step ( const double  _dt)
overridevirtual

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.

Implements Agent.

◆ Uninitialize()

void PlanningAgent::Uninitialize ( )
overridevirtual

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

Implements Agent.

Reimplemented in PathFollowingAgent.

◆ SetTask()

void PlanningAgent::SetTask ( std::shared_ptr< MPTask > const  _task)
overridevirtual

Set the task for this agent.

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

Reimplemented from Agent.

◆ HasPlan()

bool PlanningAgent::HasPlan ( ) const
virtual

Does the agent have a plan for its current task?

Returns
True if the agent has a plan.

Reimplemented in PathFollowingAgent.

◆ ClearPlan()

void PlanningAgent::ClearPlan ( )
virtual

Clear the agent's current plan. If a plan was cleared, the plan version will be updated. Overrides should always call this base method to update the plan version.

Reimplemented in PathFollowingAgent.

◆ IsPlanning()

bool PlanningAgent::IsPlanning ( ) const

Is the agent currently generating a plan?

Returns
True if the agent is generating a plan.

◆ GetPlanVersion()

size_t PlanningAgent::GetPlanVersion ( ) const

Get the current version number for the agent's plan.

Returns
The plan version number.

◆ GetMPSolution()

MPSolution * PlanningAgent::GetMPSolution ( )

Get the pointer to this agents solution object.

Returns
The MPSolution pointer.

◆ GeneratePlan()

void PlanningAgent::GeneratePlan ( )
protectedvirtual

Generate a plan for the agent's current task. Calls the WorkFunction in a separate thread.

◆ WorkFunction()

void PlanningAgent::WorkFunction ( std::shared_ptr< MPProblem _problem)
protectedvirtual

Function call for PPL.

Reimplemented in PathFollowingAgent.

◆ StopPlanning()

void PlanningAgent::StopPlanning ( )
protected

Stop the current plan (only works for MPStrategies which are implemented using the base Run() method).

◆ SelectTask()

bool PlanningAgent::SelectTask ( )
protectedvirtual

Select the next task for this agent. The base implementation selects the first available task.

Returns
True if a new task was selected, or false if none remain.

◆ EvaluateTask()

bool PlanningAgent::EvaluateTask ( )
protectedvirtual

Evaluate the agent's progress on its current task.

Returns
True if we should continue the current task, false otherwise.

Reimplemented in PathFollowingAgent.

◆ ExecuteTask()

void PlanningAgent::ExecuteTask ( const double  _dt)
protectedvirtual

Continue executing the agent's current task.

Parameters
_dtThe step length.

Reimplemented in PathFollowingAgent.

◆ UpdateSimulatedState()

void PlanningAgent::UpdateSimulatedState ( )
protected

Evaluates whether the robot's simulated state is incorrect (beyond some error threshold) and sets the simulated state as necessary.

◆ Factory()

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

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.

◆ ResetStartConstraint()

void Agent::ResetStartConstraint ( )
virtualinherited

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

◆ MinimumSteps()

size_t Agent::MinimumSteps ( ) const
inherited

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
inherited

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 ( )
inherited

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)
inherited

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 ( )
protectedinherited

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 
)
protectedvirtualinherited

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 
)
protectedvirtualinherited

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 
)
protectedvirtualinherited

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
protectedinherited

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: