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

Public Member Functions

Construction
 PathFollowingAgent (Robot *const _r)
 
 PathFollowingAgent (Robot *const _r, const PathFollowingAgent &_a)
 
 PathFollowingAgent (Robot *const _r, XMLNode &_node)
 
virtual std::unique_ptr< AgentClone (Robot *const _r) const override
 
virtual ~PathFollowingAgent ()
 
Agent Interface
virtual void Uninitialize () override
 
void ClearVisualGraph ()
 Visually remove the agent's roadmap representation.
 
Planning
virtual bool HasPlan () const override
 
virtual void ClearPlan () override
 
void SetPlan (std::vector< Cfg > _path)
 
Agent Overrides
virtual void Initialize () override
 
virtual void Step (const double _dt) override
 
virtual void SetTask (std::shared_ptr< MPTask > const _task) override
 
Planning
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 WorkFunction (std::shared_ptr< MPProblem > _problem) override
 Function call for PPL. More...
 
Task Helpers
virtual bool EvaluateTask () override
 
virtual void ExecuteTask (const double _dt) override
 
Planning Helpers
virtual void GeneratePlan ()
 
void StopPlanning ()
 
Task Helpers
virtual bool SelectTask ()
 
Localization Helpers
void UpdateSimulatedState ()
 

Protected Attributes

Internal State
std::vector< Cfgm_path
 The path to follow.
 
size_t m_pathIndex {0}
 The path node that is the current subgoal.
 
std::string m_waypointDm
 
double m_waypointThreshold {.05}
 The distance threshold for waypoint proximity.
 
size_t m_pathVisualID {size_t(-1)}
 The ID of the path drawing.
 
size_t m_graphVisualID {size_t(-1)}
 The ID of the graph drawing.
 
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_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

This agent calls PPL to generate a path. It then attempts to follow the path waypoints as closely as possible by relying on the robot's controller.

Constructor & Destructor Documentation

◆ PathFollowingAgent() [1/3]

PathFollowingAgent::PathFollowingAgent ( Robot *const  _r)

Create an agent for a robot.

Parameters
_rThe robot which this agent will reason for.

◆ PathFollowingAgent() [2/3]

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

Copy an agent for another robot.

Parameters
_rThe destination robot.
_aThe agent to copy.

◆ PathFollowingAgent() [3/3]

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

Reimplemented from PlanningAgent.

◆ Uninitialize()

void PathFollowingAgent::Uninitialize ( )
overridevirtual

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

Reimplemented from PlanningAgent.

◆ HasPlan()

bool PathFollowingAgent::HasPlan ( ) const
overridevirtual

Does the agent have a plan for its current task?

Returns
True if the agent has a plan.

Reimplemented from PlanningAgent.

◆ ClearPlan()

void PathFollowingAgent::ClearPlan ( )
overridevirtual

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 from PlanningAgent.

◆ SetPlan()

void PathFollowingAgent::SetPlan ( std::vector< Cfg _path)

Sets the agent's plan.

Parameters
_pathThe set of configurations to follow.

◆ WorkFunction()

void PathFollowingAgent::WorkFunction ( std::shared_ptr< MPProblem _problem)
overrideprotectedvirtual

Function call for PPL.

Reimplemented from PlanningAgent.

◆ EvaluateTask()

bool PathFollowingAgent::EvaluateTask ( )
overrideprotectedvirtual

Evaluate the agent's progress on its current task.

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

Reimplemented from PlanningAgent.

◆ ExecuteTask()

void PathFollowingAgent::ExecuteTask ( const double  _dt)
overrideprotectedvirtual

Continue executing the agent's current task.

Parameters
_dtThe step length.

Reimplemented from PlanningAgent.

◆ Initialize()

void PlanningAgent::Initialize ( )
overridevirtualinherited

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

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.

◆ SetTask()

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

Set the task for this agent.

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

Reimplemented from Agent.

◆ IsPlanning()

bool PlanningAgent::IsPlanning ( ) const
inherited

Is the agent currently generating a plan?

Returns
True if the agent is generating a plan.

◆ GetPlanVersion()

size_t PlanningAgent::GetPlanVersion ( ) const
inherited

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

Returns
The plan version number.

◆ GetMPSolution()

MPSolution * PlanningAgent::GetMPSolution ( )
inherited

Get the pointer to this agents solution object.

Returns
The MPSolution pointer.

◆ GeneratePlan()

void PlanningAgent::GeneratePlan ( )
protectedvirtualinherited

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

◆ StopPlanning()

void PlanningAgent::StopPlanning ( )
protectedinherited

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

◆ SelectTask()

bool PlanningAgent::SelectTask ( )
protectedvirtualinherited

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.

◆ UpdateSimulatedState()

void PlanningAgent::UpdateSimulatedState ( )
protectedinherited

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_waypointDm

std::string PathFollowingAgent::m_waypointDm
protected

The distance metric for checking whether the agent has reached a path waypoint.

◆ 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: