Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# PotentialfieldComposition Class Reference

The main class for the potential field implementation. More...

`#include <PotentialfieldComposition.h>`

Collaboration diagram for PotentialfieldComposition:

[legend]
List of all members.

## Public Member Functions
| PotentialfieldComposition ()
| Constructor.
| ~PotentialfieldComposition ()
| Destructor.
void | load (const std::string &filename)
| Loads a configuration file.
void | close ()
| Destroys all objects and fields.
void | execute (PotentialfieldResult &result)
| Executes computation.
void | setName (const std::string &name)
| Sets the name.
std::string | getName () const
| Returns the name.
void | setObjectState (ObjectStateDescription &desc)
| Sets the state of one object (may set desc.objectId).
void | setOwnPose (const PfPose &pose)
| Sets the own pose.
void | addField (Potentialfield *field)
| Adds a new field to the composition.
void | addObject (PotentialFieldsObject *object)
| Adds a new object to the composition.
void | addDynamicObjectState (const std::string &objectName)
| Adds a new symbol for external object states.
unsigned int | getIdFromObjectStateSymbol (const std::string &objectName)
| Returns the internal id of a symbol.
ObjectStateDescription | getDescriptionFromId (unsigned int objectId)
| Returns a object description.
std::vector< std::string > | getFieldNames ()
| Returns a list of the names of all fields.
void | setFieldSelectionParameters (SelectionProcedure selectionProcedure, unsigned int n)
| Sets parameters for field selection.
void | getValueArray (const std::string &fieldname, double x1, double y1, double x2, double y2, int xSteps, int ySteps, double value[], double &max)
| Computes an array of field values, used by visualization.
void | getDirectionArray (const std::string &fieldname, double x1, double y1, double x2, double y2, int xSteps, int ySteps, PfVec directions[])
| Computes an array of gradient directions, used by visualization.
void | setFieldActivation (const std::string &fieldname, bool activation)
| Activates or deactivates a field.
## Private Member Functions
PotentialfieldResult | selectNextResult ()
| Selects the next result from the list.
void | addResultToList (const PotentialfieldResult &result)
| Adds a result to the list and keeps the size of the list <= n.
void | updateDynamicObjects ()
| Updates the state of all dynamic objects.
unsigned int | getFieldIndexFromName (const std::string &fieldname)
| Returns the index of a field.
## Private Attributes
std::string | name
| The name of the composition.
std::vector< PotentialFieldsObject * > | objects
| A list of all objects.
NameToIndexMap | objectMap
| Fast mapping from object names to indizes.
std::vector< ObjectStateDescription > | dynamicObjectStates
| The states of the dynamic objects.
NameToIndexMap | objectStateMap
| Fast mapping from object state names to indizes.
std::vector< Potentialfield * > | fields
| A list of all fields.
NameToIndexMap | fieldMap
| Fast mapping from field names to indizes.
std::vector< PotentialfieldResult > | results
| A list for the results of all fields.
std::list< PotentialfieldResult > | resultList
| A list for the selected results of the last runs.
PotentialfieldResult | lastResult
| The result of the last run.
PfPose | ownPose
| The own pose.
Parser * | parser
| The parser.
bool | fileLoaded
| A flag.
SelectionProcedure | selectionProcedure
| The procedure to choose the next active field.
unsigned int | n
| A parameter for the selectionProcedure.
## Friends
class | Parser
| The PotentialfieldComposition is a friend of its parser.

## Detailed Description

The main class for the potential field implementation.

It contains all objects and fields, executes the fields and selects the best action.

Definition at line 123 of file PotentialfieldComposition.h.

## Constructor & Destructor Documentation

PotentialfieldComposition::PotentialfieldComposition | ( |  | ) |

| Constructor. Definition at line 19 of file PotentialfieldComposition.cpp. References PotentialfieldResult::action, fileLoaded, and PotentialfieldResult::timeStamp.

PotentialfieldComposition::~PotentialfieldComposition | ( |  | ) |

| Destructor. Definition at line 27 of file PotentialfieldComposition.cpp. References close(), and fileLoaded.

Here is the call graph for this function:

## Member Function Documentation

void PotentialfieldComposition::load | ( | const std::string & | filename | ) |

  | Loads a configuration file. Parameters:
  filename | The name of the file
Definition at line 36 of file PotentialfieldComposition.cpp. References close(), fileLoaded, Parser::parse(), Parser, and parser. Referenced by GTStandardConverter::load().

Here is the call graph for this function:

void PotentialfieldComposition::close | ( |  | ) |

| Destroys all objects and fields. Definition at line 49 of file PotentialfieldComposition.cpp. References dynamicObjectStates, fields, fileLoaded, and results. Referenced by load(), and ~PotentialfieldComposition().

void PotentialfieldComposition::execute | ( | PotentialfieldResult & | result | ) |

  | Executes computation. Parameters:
  result | Returns the result
Definition at line 69 of file PotentialfieldComposition.cpp. References PotentialfieldResult::action, PotentialfieldResult::actionPossible, addResultToList(), fieldMap, PotentialfieldResult::fieldNumber, fields, PotentialfieldResult::motion, PfVec::normalize(), PfPose::normRotation(), ownPose, PfPose::pos, results, PfPose::rotation, selectNextResult(), PotentialfieldResult::timeStamp, updateDynamicObjects(), and PotentialfieldResult::value. Referenced by GTStandardConverter::execute().

Here is the call graph for this function:

void PotentialfieldComposition::setName | ( | const std::string & | name | ) | `[inline]`

  | Sets the name. Parameters:
  name | The name
Definition at line 148 of file PotentialfieldComposition.h.

std::string PotentialfieldComposition::getName | ( |  | ) | const`[inline]`

| Returns the name. Returns: The name Definition at line 154 of file PotentialfieldComposition.h.

void PotentialfieldComposition::setObjectState | ( | ObjectStateDescription & | desc | ) |

  | Sets the state of one object (may set desc.objectId). Parameters:
  desc | The description of the object and its new state
Definition at line 215 of file PotentialfieldComposition.cpp. References dynamicObjectStates, getIdFromObjectStateSymbol(), ObjectStateDescription::isActive, ObjectStateDescription::objectId, ObjectStateDescription::objectName, and ObjectStateDescription::pose. Referenced by GTStandardConverter::execute(), and GTStandardConverter::setData().

Here is the call graph for this function:

void PotentialfieldComposition::setOwnPose | ( | const PfPose & | pose | ) |

  | Sets the own pose. Parameters:
  pose | The pose
Definition at line 230 of file PotentialfieldComposition.cpp. References ownPose. Referenced by GTStandardConverter::setData().

void PotentialfieldComposition::addField | ( | Potentialfield * | field | ) |

  | Adds a new field to the composition. Parameters:
  field | The field
Definition at line 236 of file PotentialfieldComposition.cpp. References fieldMap, fields, Potentialfield::getName(), Potentialfield::init(), and results. Referenced by Parser::parseActionfield(), and Parser::parseMotionfield().

Here is the call graph for this function:

void PotentialfieldComposition::addObject | ( | PotentialFieldsObject * | object | ) |

  | Adds a new object to the composition. Parameters:
  object | The object
Definition at line 246 of file PotentialfieldComposition.cpp. References PotentialFieldsObject::getName(). Referenced by Parser::parseFormationObject(), and Parser::parseInstance().

Here is the call graph for this function:

void PotentialfieldComposition::addDynamicObjectState | ( | const std::string & | objectName | ) |

  | Adds a new symbol for external object states. Parameters:
  objectName | The name of the symbol
Definition at line 253 of file PotentialfieldComposition.cpp. References dynamicObjectStates, ObjectStateDescription::isActive, ObjectStateDescription::objectId, ObjectStateDescription::objectName, and objectStateMap. Referenced by Parser::parseObjectStateSymbol().

unsigned int PotentialfieldComposition::getIdFromObjectStateSymbol | ( | const std::string & | objectName | ) |

  | Returns the internal id of a symbol. Parameters:
  objectName | The name of the symbol
Returns: The identifier Definition at line 264 of file PotentialfieldComposition.cpp. References objectStateMap. Referenced by GTStandardConverter::load(), Parser::parseInstance(), and setObjectState().

ObjectStateDescription PotentialfieldComposition::getDescriptionFromId | ( | unsigned int | objectId | ) |

  | Returns a object description. Parameters:
  objectId | The object identifier
Returns: The description Definition at line 273 of file PotentialfieldComposition.cpp. References dynamicObjectStates. Referenced by PotentialFieldsObject::updateData().

std::vector< std::string > PotentialfieldComposition::getFieldNames | ( |  | ) |

| Returns a list of the names of all fields. Returns: A vector containing the names Definition at line 280 of file PotentialfieldComposition.cpp. References fields. Referenced by GTStandardConverter::getFieldNames().

void PotentialfieldComposition::setFieldSelectionParameters | ( | SelectionProcedure | selectionProcedure,
|  | unsigned int | n
| ) | `[inline]`

  | Sets parameters for field selection. Parameters:
  selectionProcedure | The selection mechanism
  n | A parameter for selectionProcedure
Definition at line 203 of file PotentialfieldComposition.h. Referenced by Parser::parseComposition().

void PotentialfieldComposition::getValueArray | ( | const std::string & | fieldname,
|  | double | x1,
|  | double | y1,
|  | double | x2,
|  | double | y2,
|  | int | xSteps,
|  | int | ySteps,
|  | double | value[],
|  | double & | max
| ) |

  | Computes an array of field values, used by visualization. Parameters:
  fieldname | The name of the potential field
  x1 | Minimum x-coordinate to compute
  y1 | Minimum y-coordinate to compute
  x2 | Maximum x-coordinate to compute
  y2 | Maximum y-coordinate to compute
  xSteps | The computation steps in x-direction
  ySteps | The computation steps in y-direction
  value | An array containing all computed values, memory has to be allocated BEFORE calling the function
  max | Returns the maximum value
Definition at line 309 of file PotentialfieldComposition.cpp. References fields, getFieldIndexFromName(), Potentialfield::getValueArray(), max, and updateDynamicObjects(). Referenced by GTStandardConverter::getValueArray().

Here is the call graph for this function:

void PotentialfieldComposition::getDirectionArray | ( | const std::string & | fieldname,
|  | double | x1,
|  | double | y1,
|  | double | x2,
|  | double | y2,
|  | int | xSteps,
|  | int | ySteps,
|  | PfVec | directions[]
| ) |

  | Computes an array of gradient directions, used by visualization. Parameters:
  fieldname | The name of the potential field
  x1 | Minimum x-coordinate to compute
  y1 | Minimum y-coordinate to compute
  x2 | Maximum x-coordinate to compute
  y2 | Maximum y-coordinate to compute
  xSteps | The computation steps in x-direction
  ySteps | The computation steps in y-direction
  directions | An array containing all computed gradients, memory has to be allocated BEFORE calling the function
Definition at line 319 of file PotentialfieldComposition.cpp. References fields, Potentialfield::getDirectionArray(), getFieldIndexFromName(), and updateDynamicObjects(). Referenced by GTStandardConverter::getDirectionArray().

Here is the call graph for this function:

void PotentialfieldComposition::setFieldActivation | ( | const std::string & | fieldname,
|  | bool | activation
| ) |

  | Activates or deactivates a field. Parameters:
  fieldname | The name of the field
  activation | true, if the field is to be activated; false, otherwise
Definition at line 292 of file PotentialfieldComposition.cpp. References fields, and getFieldIndexFromName().

Here is the call graph for this function:

PotentialfieldResult PotentialfieldComposition::selectNextResult | ( |  | ) | `[private]`

| Selects the next result from the list. Returns: The result Definition at line 143 of file PotentialfieldComposition.cpp. References BEST_OF_N, resultList, and selectionProcedure. Referenced by execute().

void PotentialfieldComposition::addResultToList | ( | const PotentialfieldResult & | result | ) | `[private]`

  | Adds a result to the list and keeps the size of the list <= n. Parameters:
  result | The result
Definition at line 205 of file PotentialfieldComposition.cpp. References resultList. Referenced by execute().

void PotentialfieldComposition::updateDynamicObjects | ( |  | ) | `[private]`

| Updates the state of all dynamic objects. Definition at line 329 of file PotentialfieldComposition.cpp. Referenced by execute(), getDirectionArray(), and getValueArray().

unsigned int PotentialfieldComposition::getFieldIndexFromName | ( | const std::string & | fieldname | ) | `[inline, private]`

  | Returns the index of a field. Parameters:
  fieldname | The name of the field
Returns: The index Definition at line 299 of file PotentialfieldComposition.cpp. References fieldMap. Referenced by getDirectionArray(), getValueArray(), and setFieldActivation().

## Friends And Related Function Documentation

friend class Parser`[friend]`

| The PotentialfieldComposition is a friend of its parser. Definition at line 241 of file PotentialfieldComposition.h. Referenced by load().

## Member Data Documentation

std::string PotentialfieldComposition::name`[private]`

| The name of the composition. Definition at line 245 of file PotentialfieldComposition.h.

std::vector<PotentialFieldsObject*> PotentialfieldComposition::objects`[private]`

| A list of all objects. Definition at line 247 of file PotentialfieldComposition.h. Referenced by Parser::getInstance().

NameToIndexMap PotentialfieldComposition::objectMap`[private]`

| Fast mapping from object names to indizes. Definition at line 249 of file PotentialfieldComposition.h. Referenced by Parser::getInstance().

std::vector<ObjectStateDescription> PotentialfieldComposition::dynamicObjectStates`[private]`

| The states of the dynamic objects. Definition at line 251 of file PotentialfieldComposition.h. Referenced by addDynamicObjectState(), close(), getDescriptionFromId(), and setObjectState().

NameToIndexMap PotentialfieldComposition::objectStateMap`[private]`

| Fast mapping from object state names to indizes. Definition at line 253 of file PotentialfieldComposition.h. Referenced by addDynamicObjectState(), and getIdFromObjectStateSymbol().

std::vector<Potentialfield*> PotentialfieldComposition::fields`[private]`

| A list of all fields. Definition at line 255 of file PotentialfieldComposition.h. Referenced by addField(), close(), execute(), getDirectionArray(), getFieldNames(), getValueArray(), and setFieldActivation().

NameToIndexMap PotentialfieldComposition::fieldMap`[private]`

| Fast mapping from field names to indizes. Definition at line 257 of file PotentialfieldComposition.h. Referenced by addField(), execute(), and getFieldIndexFromName().

std::vector<PotentialfieldResult> PotentialfieldComposition::results`[private]`

| A list for the results of all fields. Definition at line 259 of file PotentialfieldComposition.h. Referenced by addField(), close(), and execute().

std::list<PotentialfieldResult> PotentialfieldComposition::resultList`[private]`

| A list for the selected results of the last runs. Definition at line 261 of file PotentialfieldComposition.h. Referenced by addResultToList(), and selectNextResult().

PotentialfieldResult PotentialfieldComposition::lastResult`[private]`

| The result of the last run. Definition at line 263 of file PotentialfieldComposition.h.

PfPose PotentialfieldComposition::ownPose`[private]`

| The own pose. Definition at line 265 of file PotentialfieldComposition.h. Referenced by execute(), and setOwnPose().

Parser* PotentialfieldComposition::parser`[private]`

| The parser. Definition at line 267 of file PotentialfieldComposition.h. Referenced by load().

bool PotentialfieldComposition::fileLoaded`[private]`

| A flag. Definition at line 269 of file PotentialfieldComposition.h. Referenced by close(), load(), PotentialfieldComposition(), and ~PotentialfieldComposition().

SelectionProcedure PotentialfieldComposition::selectionProcedure`[private]`

| The procedure to choose the next active field. Definition at line 271 of file PotentialfieldComposition.h. Referenced by selectNextResult().

unsigned int PotentialfieldComposition::n`[private]`

| A parameter for the selectionProcedure. Definition at line 273 of file PotentialfieldComposition.h.

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

- Tools/PotentialFields/PotentialfieldComposition.h
- Tools/PotentialFields/PotentialfieldComposition.cpp