- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Executives::DeductiveController::Observation::DiscreteObservationConverter Class Reference

`#include <DiscreteObservationConverter.h>`

Inheritance diagram for Mers::Executives::DeductiveController::Observation::DiscreteObservationConverter:

[legend]
Collaboration diagram for Mers::Executives::DeductiveController::Observation::DiscreteObservationConverter:

[legend]
List of all members.

## Public Member Functions
| DiscreteObservationConverter (const char *fileName)
virtual | ~DiscreteObservationConverter ()
virtual void | update (ValueIdentifier value)
virtual void | update (ContinuousVariableIdentifier varID, double value)
virtual ValueIdentifier | getCurrentState (DiscreteVariableIdentifier varID)
virtual double | getCurrentState (ContinuousVariableIdentifier varID)
void | addObservationInterface (Mers::Interfaces::ObservationInterface *obsInterface)
void | connectTitanInterface (Mers::Interfaces::ObservationUpdateListener *pTitan)
void | observe (ContinuousVariableIdentifier observationUID, double observationValue)
ContinuousVariableIdentifier | getObservationUID (char *observationName, int observationIndex)
int | initialize (char *robotSensorClasses[], int *robotAvailInst, int numRobotClasses)
void | print (std::ostream &out)
## Protected Member Functions
int | useConfigFile (std::ifstream &configStream)
char | skip (std::ifstream &input)
| The following used to process a config file.
char | getWord (std::ifstream &input, char *storage)
int | process (std::ifstream &configStream)
bool | isWhiteSpace (char c)
bool | isDigit (char c)
void | displaySyntaxError (const char *expected)
int | processRangeBlock (std::ifstream &configStream, DomainLookupNodeData *current)
int | processSimplePlantVar (std::ifstream &configStream, char *word)
int | processCompoundPlantVar (std::ifstream &configStream, char *word)
bool | rangeOverlap (const double rangeStart, const double rangeEnd, const DomainLookupNodeData &head)
void | instantiateDomainData (VariableLookupNode &varNode, const DomainLookupNodeData *domainDataHead)
int | loadCompoundDomain (std::ifstream &configStream, char *word, int lowIndex, int highIndex, std::vector< VariableLookupNode * > &temp)
## Classes
class | SensorDataComparator

## Detailed Description

DiscreteObservationConverter contains an array of linked lists, in which each node contains an interval of real numbers and the UID of the symbolic representation, int Titan-RMPL, of that range of values. The correspondence between real ranges and symbolic values is specified in a configuration file. This interface assumes that data is provided to it automatically. If polling is required, it should be present in the calling object.

Author:
  Adam Kraft

  Paul Elliott

Definition at line 38 of file DiscreteObservationConverter.h.

## Constructor & Destructor Documentation

DiscreteObservationConverter::DiscreteObservationConverter | ( | const char * | fileName | ) |

Create a fully initialized observation converter. The configuration file is processed later, during initiation.

Definition at line 48 of file DiscreteObservationConverter.cpp.

DiscreteObservationConverter::~DiscreteObservationConverter | ( |  | ) | `[virtual]`

Destroys this object.

Definition at line 65 of file DiscreteObservationConverter.cpp.

## Member Function Documentation

void DiscreteObservationConverter::update | ( | ValueIdentifier | value | ) | `[virtual]`

Updates all listeners that the variable associated with value has changed state such that value is the most likely state.

Parameters:

  | value | The new value of the variable.

Implements Mers::Interfaces::ObservationUpdateListener.

Definition at line 80 of file DiscreteObservationConverter.cpp.

void DiscreteObservationConverter::update | ( | ContinuousVariableIdentifier | varID,
|  | double | value |
| ) |  |  | `[virtual]`

Updates all listeners that the variable varID has changed state such that value is the most likely state.

Parameters:

  | varID | The variable who's value has changed.
  | value | The new value of the variable.

Implements Mers::Interfaces::ObservationUpdateListener.

Definition at line 88 of file DiscreteObservationConverter.cpp.

DiscreteObservationConverter::ValueIdentifier DiscreteObservationConverter::getCurrentState | ( | DiscreteVariableIdentifier | varID | ) | `[virtual]`

Returns the most likely state of the specified variable. Note that it is guaranteed that this ValueIdentifier will be equal using == to another ValueIdentifier if and only if the states are the same.

Parameters:

  | varID | The identifier of the variable.

Returns:
  The ValueIdentifier of the most likely state.

Implements Mers::Interfaces::ObservationInterface.

Definition at line 100 of file DiscreteObservationConverter.cpp.

double DiscreteObservationConverter::getCurrentState | ( | ContinuousVariableIdentifier | varID | ) | `[virtual]`

Returns the most likely state of the specified variable. Note that it is guaranteed that this ValueIdentifier will be equal using == to another ValueIdentifier if and only if the states are the same.

Parameters:

  | varID | The identifier of the variable.

Returns:
  The ValueIdentifier of the most likely state.

Implements Mers::Interfaces::ObservationInterface.

Definition at line 108 of file DiscreteObservationConverter.cpp.

void Mers::Executives::DeductiveController::Observation::DiscreteObservationConverter::addObservationInterface | ( | Mers::Interfaces::ObservationInterface * | obsInterface | ) |

Adds an observation interface that should be used by this object. Observations will be expected from this interface and this object will register for observations from obsInterface. This function should only be called once per interface. Note that this should be called after initialize.

Parameters:

  | obsInterface | The ObservationInterface that will issue observations to this object.

void Mers::Executives::DeductiveController::Observation::DiscreteObservationConverter::connectTitanInterface | ( | Mers::Interfaces::ObservationUpdateListener * | pTitan | ) |

Sets the interface to which this object will post the discretized observations.

Parameters:

  | pCopyTitan | A handle to the Deductive Controller RTAPI which will receive observations.

Use addUpdateListener()

void DiscreteObservationConverter::observe | ( | ContinuousVariableIdentifier | observationUID,
|  | double | observationValue |
| ) |  |  |

This routine is called to provide an observation that will be converted into a discrete value and enqueued into titan.

Parameters:

  | observationUID | the UID associated with the observation. Note that this name is specific to the subsystem, and should be queried first by a call to getObservationUID().
  | observationValue | the value that was observed.

Definition at line 136 of file DiscreteObservationConverter.cpp.

References Mers::Interfaces::DiscreteValue::getName(), Mers::Interfaces::Variable::getName(), Mers::Executives::DeductiveController::Observation::DomainLookupNode::m_dVal, Mers::Executives::DeductiveController::Observation::DomainLookupNode::pNext, Mers::Executives::DeductiveController::Observation::DomainLookupNode::rangeHighBound, Mers::Executives::DeductiveController::Observation::DomainLookupNode::rangeLowBound, and Mers::Interfaces::ObservationInterface::updateListeners().

Here is the call graph for this function:

DiscreteObservationConverter::ContinuousVariableIdentifier DiscreteObservationConverter::getObservationUID | ( | char * | observationName,
|  | int | observationIndex |
| ) |  |  |

Returns the UID of the specified observation. It returns an invalid identifier if no information exists for that observation.

Parameters:

  | observationName | the name of the class of observation being looked up. (for example: "Laser", "Sonar", etc.)
  | observationIndex | the index of a particular observation within the class specified by observationName (refers to Laser[40], Sonar[6] etc.)

Returns:
  the UID of the observation variable, or -1 if it was not present in the config file.

Definition at line 199 of file DiscreteObservationConverter.cpp.

int DiscreteObservationConverter::initialize | ( | char * | robotSensorClasses[],
|  | int * | robotAvailInst,
|  | int | numRobotClasses |
| ) |  |  |

This function initializes the set of sensors available as well as their corresponding channel numbers.

Parameters:

  | robotSensorClasses | The set of named sensor instances supported by this observation converter.
  | robotAvailInst | The a list of instance numbers for each sensor class.
  | numRobotClasses | The number of classes available.

Definition at line 216 of file DiscreteObservationConverter.cpp.

References Mers::Interfaces::ObservationInterface::addContinuousVariable(), Mers::Interfaces::ObservationInterface::getContinuousVariable(), Mers::Interfaces::ObservationInterface::isValid(), and useConfigFile().

Here is the call graph for this function:

void DiscreteObservationConverter::print | ( | std::ostream & | out | ) |

Prints the data stored in this object.

Parameters:

  | out | Data about this object is printed here.

Definition at line 283 of file DiscreteObservationConverter.cpp.

References Mers::Interfaces::ObservationInterface::mContinuousVars, and Mers::Interfaces::ObservationInterface::mDiscreteVars.

int Mers::Executives::DeductiveController::Observation::DiscreteObservationConverter::useConfigFile | ( | std::ifstream & | configStream | ) | `[protected]`

Called by initilaize to build the internal representation based on the config file.

Referenced by initialize().

void DiscreteObservationConverter::instantiateDomainData | ( | VariableLookupNode & | varNode,
|  | const DomainLookupNodeData * | domainDataHead |
| ) |  |  | `[protected]`

Loads a set of values for the specified VariableLookupNode give the DomainLookupNodeData.

Parameters:

  | varNode | The node containing the variable data that will be used to instantiate the DomainLookupNodeData.
  | domainDataHead | The head of the domain data that will be instantiated with the variable data.

Definition at line 861 of file DiscreteObservationConverter.cpp.

References Mers::Interfaces::ObservationInterface::addDiscreteValue(), Mers::Executives::DeductiveController::Observation::VariableLookupNode::m_dVar, Mers::Executives::DeductiveController::Observation::VariableLookupNode::pDomainList, Mers::Executives::DeductiveController::Observation::DomainLookupNode::pNext, Mers::Executives::DeductiveController::Observation::DomainLookupNodeData::pNext, Mers::Executives::DeductiveController::Observation::DomainLookupNodeData::rangeHighBound, Mers::Executives::DeductiveController::Observation::DomainLookupNodeData::rangeLowBound, and Mers::Executives::DeductiveController::Observation::DomainLookupNodeData::valueName.

Here is the call graph for this function:

int Mers::Executives::DeductiveController::Observation::DiscreteObservationConverter::loadCompoundDomain | ( | std::ifstream & | configStream,
|  | char * | word,
|  | int | lowIndex,
|  | int | highIndex,
|  | std::vector< VariableLookupNode * > & | temp |
| ) |  |  | `[protected]`

Loads a compound domain. The last character read should be ':' and the next word read from the stream should be the prefix of a titan variable. A VariableLookupNode will be created for each sensor instance.

Parameters:

  | configStream |

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

- /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Observation/DiscreteObservationConverter.h
- /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Observation/DiscreteObservationConverter.cpp