libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | List of all members
HRICS::MultiAgentGrid Class Reference

Plannar HRI Grid considering multiple agents systems for HRi operations. More...

#include <HRICS_MultiAgentGrid.hpp>

Inheritance diagram for HRICS::MultiAgentGrid:
API::TwoDGrid API::BaseGrid

Classes

class  AgentInGrid
 Holds all the data concerning an agent in the MultiAgentGrid class. More...
 
struct  ComputationStat
 
class  MetaAgentInGrid
 class representing data that can be common to several agents (reachable space, cylinder, frontiers, etc...) More...
 

Public Member Functions

 MultiAgentGrid (double pace, std::vector< double > envSize)
 constructs a grid with no agents More...
 
 MultiAgentGrid (double pace, std::vector< double > envSize, std::vector< Robot * > &agents)
 specify agents list More...
 
void resetData (void)
 
void setAgents (std::vector< Robot * > &agents)
 set the agents list to use in this HRI computation. More...
 
std::vector< Robot * > & getAgents ()
 
AgentInGridgetAgentStructAt (unsigned int index)
 
void setAgentTarget (unsigned int a)
 
double getNbCellX ()
 
double getNbCellY ()
 
void setAsNotSorted ()
 
void dumpVar ()
 
void init (void)
 initialisation of the grid (find cylinders corresponding to each agent)
 
void initCylinders (void)
 init agents cylinders for reachability computation. More...
 
void computeAccessibility (void)
 compute the Accessibility for each agent. More...
 
void computeAccessAndDistCombined (void)
 
std::vector< MultiAgentCell * > computeOtherTrajectory (MultiAgentCell *cell_origin, MultiAgentCell *cell_dest, unsigned int agent_index, double epsilon=1, double dist_max=-1, int max_expansions=-1)
 computeOtherTrajectory uses A* algo to find shortest path between 2 cells. More...
 
bool areCellsInNeighbourhood (MultiAgentCell *c1, MultiAgentCell *c2, unsigned int a, double dist)
 check if the agent 'a' can go straight from one cell to another
 
API::TwoDCellcreateNewCell (unsigned int index, unsigned int x, unsigned int y)
 function that creates a new Cell.
 
void computeDistances ()
 using the method of distance propagation to compute distances.
 
void computeDistancesForAgent (MultiAgentCell *cell, unsigned int agent_index)
 
void computeAltDistancesForAgent (MultiAgentCell *origin, unsigned int agent_index)
 
void enableAltDistancesSums (bool b=true)
 
void clearAltDistancesInCells (void)
 
unsigned int getMaxAlternativeDistancesForCells (void)
 
void getMaxAlternativeDistancesForCells (unsigned int v)
 
std::pair< MultiAgentCell
*, MultiAgentCell * > 
neighborSolution (unsigned int agent_1, unsigned int agent_2, std::pair< MultiAgentCell *, MultiAgentCell * > solution)
 find a neighhbour solution for the simulated annealing algorithm. More...
 
void searchAllFrontiers ()
 
std::vector< FrontierPtr > searchFrontiers (unsigned int agent_1, unsigned int agent_2, double keep_distance)
 searchFrontiers More...
 
std::vector< FrontierPtr > simulatedAnnealingFrontierSearch (unsigned int agent_1, unsigned int agent_2, double keep_distance)
 
std::vector< MetaFrontierPtr > hillClimberFrontierSearch (unsigned int agent1, unsigned int agent2, double keep_distance)
 
std::vector< FrontierPtr > frontierSearch (unsigned int agent1, unsigned int agent2, double keep_distance)
 
std::vector< FrontierPtr > exhaustiveFrontierSearch (unsigned int agent1, unsigned int agent2, double keep_distance)
 
std::vector< FrontierPtr > handInHandFrontierSearch (unsigned int agent1, unsigned int agent2, double keep_distance)
 
void saveFrontiers (std::ofstream &output)
 
bool loadFrontiers (std::ifstream &input)
 
void initVectorFrontiers (void)
 inits the frontier container to the good size. More...
 
unsigned int getFrontierIndex (unsigned int i, unsigned int j)
 computes the index int the frontier vector corresponding to the frontiers between agents at i and j.
 
unsigned int getFrontierIndex (std::pair< unsigned int, unsigned int > ind)
 
std::pair< unsigned int,
unsigned int > 
getFrontierAgentIndices (unsigned int i)
 the reverse of getFrontierIndex().
 
std::vector< MultiAgentCell * >
const & 
getFrontierCells (unsigned int i, unsigned int j)
 
double getArmReach (unsigned int i)
 
double getArmReach (AgentInGrid *a)
 
double getHandOverReach (unsigned int i, unsigned int j)
 an approximation of the maximal distance for a handover (touching hands) The sum of the arm reachs of each agent
 
void addFrontier (unsigned int agent, unsigned int other, MultiAgentCell *cell)
 add a frontier cell to the agent 'agent' More...
 
FrontierPtr getRandomFrontier (unsigned int a1, unsigned int a2, double timeout_ms=-1)
 
std::vector< MultiAgentCell * > & getFrontierCheckedOk (unsigned int a1, unsigned int a2)
 
double getFrontierSearchTempDecrease (void)
 
void setFrontierSearchTempDecrease (double v)
 
double getFrontierSearchStartTemp (void)
 
void setFrontierSearchStartTemp (double v)
 
unsigned int getFrontierSearchMaxIt (void)
 
void setFrontierSearchMaxIt (unsigned int v)
 set the computational cost limit in # of iterations for the frontier search algorithm. More...
 
double getFrontierSearchStopDist (void)
 
void setFrontierSearchStopDist (double v)
 set at which distance the frontier search should stop. More...
 
ComputationStatgetComputationStats (void)
 
void setCellsToblankCost ()
 call setBlankCost() in each cell
 
void initAllCellState ()
 call resetexplorationstatus() in each cell
 
void initAllTrajs ()
 call resetTrajs() in each cell
 
void resetAllAccessibility ()
 call resetReacheability() in each cell
 
void resetDistances (void)
 
- Public Member Functions inherited from API::TwoDGrid
EIGEN_MAKE_ALIGNED_OPERATOR_NEW TwoDGrid ()
 Constructor. More...
 
 TwoDGrid (Eigen::Vector2i size, std::vector< double > envSize)
 
 TwoDGrid (double samplingRate, std::vector< double > envSize)
 
 ~TwoDGrid ()
 Destructor.
 
void createAllCells ()
 Creates All Cells. More...
 
Eigen::Vector2d getCellSize ()
 
TwoDCellgetCell (const Eigen::Vector2i &cell)
 
TwoDCellgetCell (int x, int y)
 Retruns the Cell at (x,y) More...
 
TwoDCellgetCell (Eigen::Vector2d pos)
 
TwoDCellgetCell (double *pos)
 Get Cell in 3D ThreeDGrid. More...
 
TwoDCellgetCell (unsigned int index)
 Get Cell. More...
 
bool isCellCoordInGrid (const Eigen::Vector2i &coord)
 Is a Coord inside the Grid (used to debug) More...
 
Eigen::Vector2i getCellCoord (TwoDCell *ptrCell)
 Get place in grid. More...
 
int getNumberOfCells ()
 Get Number Of Cells.
 
TwoDCellgetNeighbour (const Eigen::Vector2i &pos, int i)
 Get Neighboor Cell.
 
Eigen::Vector2d getCoordinates (TwoDCell *cell)
 Retrive the X Y Z coordinate of the cell from its index.
 
- Public Member Functions inherited from API::BaseGrid
 BaseGrid (const BaseGrid &grid)
 
BaseCellgetCell (unsigned int i)
 Get Cell. More...
 
unsigned int getNumberOfCells ()
 Get Number Of Cells.
 
virtual std::vector
< Eigen::Vector3d > 
getBox ()
 
virtual bool writeToXmlFile (std::string file)
 Virtual function for creating an xml document.
 
virtual bool loadFromXmlFile (std::string file)
 Virtual function for reading from an xml document.
 
std::string getName ()
 

Display grid

methods for displaying info in openGL and setting display options

void draw ()
 drawing the grid
 
void setAgentIndexToDrawGrid (int index)
 
void setDrawAgentAccessibilityGrid (bool b, bool boundariesOnly=false)
 
void setDrawAStar (bool b)
 
void setDrawFrontiers (bool b, unsigned int i=0, unsigned int j=0)
 
void setDrawFrontiersSearchLog (bool b)
 
unsigned int getFrontierSearchLogSize (void)
 
void setFrontierSearchLogIndex (unsigned int i)
 
void setFrontierSearchLogWindow (unsigned int i)
 
void setDrawGridForOptim (bool b, std::vector< std::pair< MultiAgentCell *, unsigned int > > &cells_agents)
 
void unsetDrawGridForOptim (void)
 
void setDrawOptimizeFrontier (MultiAgentCell *c1, MultiAgentCell *c2, bool ok)
 
void unsetDrawOptimizeFrontier (void)
 
void setDrawExtraCells (std::vector< MultiAgentCell * >::iterator first, std::vector< MultiAgentCell * >::iterator last, double ratio_max)
 
void unsetDrawExtraCells ()
 

Additional Inherited Members

- Protected Member Functions inherited from API::TwoDGrid
Eigen::Vector2d computeCellCorner (int x, int y)
 Computes the corner of a cell. More...
 
- Protected Attributes inherited from API::TwoDGrid
Eigen::Vector2d _originCorner
 
Eigen::Vector2d _cellSize
 
unsigned int _nbCellsX
 
unsigned int _nbCellsY
 
- Protected Attributes inherited from API::BaseGrid
std::vector< BaseCell * > _cells
 
std::string m_name
 

Detailed Description

Plannar HRI Grid considering multiple agents systems for HRi operations.

Developped for Multiple Handover problems.

Constructor & Destructor Documentation

HRICS::MultiAgentGrid::MultiAgentGrid ( double  pace,
std::vector< double >  envSize 
)

constructs a grid with no agents

Parameters
pace
envSize
See Also
API::TwoDGrid
HRICS::MultiAgentGrid::MultiAgentGrid ( double  pace,
std::vector< double >  envSize,
std::vector< Robot * > &  agents 
)

specify agents list

Parameters
pace
envSize
agents

Member Function Documentation

void MultiAgentGrid::addFrontier ( unsigned int  agent,
unsigned int  other,
MultiAgentCell cell 
)

add a frontier cell to the agent 'agent'

Parameters
agentthe agent index that will be modified
otherthe other agent concerned by the frontier (not modified)
cellthe cell which is accessible for 'agent' the cell have to be accessible to agent by definition (not checked)
void HRICS::MultiAgentGrid::computeAccessibility ( void  )

compute the Accessibility for each agent.

Accessibility test if an agent can fit in a cell, not if it is reachable

std::vector< MultiAgentCell * > MultiAgentGrid::computeOtherTrajectory ( MultiAgentCell cell_origin,
MultiAgentCell cell_dest,
unsigned int  agent_index,
double  epsilon = 1,
double  dist_max = -1,
int  max_expansions = -1 
)

computeOtherTrajectory uses A* algo to find shortest path between 2 cells.

Parameters
cell_origin
cell_dest
agent_index
epsilonto apply a weighted A*, 1 for classic A*
dist_maxthe maximum distance of the path to find
max_expansionsthe maximum number of expansions accepted, used to limit time when nothing found; use with care, kills all A* properties
Returns
the path found or empty vector.

When an epsilon and a max distance are provided, the max distance actually considered is epsilon times the distance provided, to stay consistent with the fact that the shortest path found in Weighted A* is at most epsilon times that of the least cost path.

void MultiAgentGrid::initCylinders ( void  )

init agents cylinders for reachability computation.

find by name two cylinders (HUMAN... and PR2_CYLINDER) and associate them to agents according to their name (HUMAN or not)

void MultiAgentGrid::initVectorFrontiers ( void  )

inits the frontier container to the good size.

the container is a vector representing a null diagonal symetric matrix.

pair< MultiAgentCell *, MultiAgentCell * > MultiAgentGrid::neighborSolution ( unsigned int  agent_1,
unsigned int  agent_2,
std::pair< MultiAgentCell *, MultiAgentCell * >  solution 
)

find a neighhbour solution for the simulated annealing algorithm.

Parameters
agent_1the first agent index
agent_2the second agent index
solutionthe pair of cells that describes the base solution
Returns
a new random solution within a certain range defined by..
Todo:
attribute for neighbourhood size (hardcoded)
std::vector< FrontierPtr > MultiAgentGrid::searchFrontiers ( unsigned int  agent_1,
unsigned int  agent_2,
double  keep_distance 
)

searchFrontiers

Parameters
agent_1
agent_2
keep_distance
Returns
Simulated annealing
void MultiAgentGrid::setAgents ( std::vector< Robot * > &  agents)

set the agents list to use in this HRI computation.

Parameters
agentspointers to the Robot classes to uses, does not copy.
Todo:
set agentsInGrid structures
void HRICS::MultiAgentGrid::setFrontierSearchMaxIt ( unsigned int  v)
inline

set the computational cost limit in # of iterations for the frontier search algorithm.

Parameters
vas the frontier search (simulated annealing algo) may be called several times for each pair of agent, the real worst number of iterations in total is: c * n!/(2!(n-2)!) = c * C(n,k) . where :
  • c is the number of searchs for each pair
  • n is the total number of agents (note the binomial coefficient C(n,k) (n choose 2).
void HRICS::MultiAgentGrid::setFrontierSearchStopDist ( double  v)
inline

set at which distance the frontier search should stop.

Parameters
vthe distance, in meters, or whichever measure unit is used. If v==0, the distance is set to the cellsize, so that the search stops when the agents appears to be abble to meet each other

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