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

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

    00001
    00002 //
    00003 // Copyright (c) 2004           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00010
    00011 #ifndef MERS_EXECUTIVES_DEDUCTIVECONTROLLER_OBSERVATION_DISCRETEOBSERVATIONCONVERTER_H
    00012 #define MERS_EXECUTIVES_DEDUCTIVECONTROLLER_OBSERVATION_DISCRETEOBSERVATIONCONVERTER_H
    00013
    00014 #include <Mers/Executives/DeductiveController/DCInterface.h>
    00015 #include <Mers/Utils/Containers/IntegerArray.h>
    00016 #include <Mers/Utils/Lang/String.h>
    00017 #include <fstream>
    00018 #include "ConversionNodes.h"
    00019
    00020 namespace Mers {
    00021         namespace Executives {
    00022                 namespace DeductiveController {
    00023                         namespace Observation {
    00024
    00038                                 class DiscreteObservationConverter :
    00039                                         public Mers::Interfaces::ObservationTransformationInterface
    00040                                 {
    00041                                 public:
    00043                                         // Constructors & Destructors
    00045
    00050                                         DiscreteObservationConverter(const char * fileName);
    00051
    00055                                         virtual ~DiscreteObservationConverter();
    00056
    00058                                         // ObservationUpdateListener interfaces.
    00060
    00067                                         virtual void update(ValueIdentifier value);
    00068
    00077                                         virtual void update(ContinuousVariableIdentifier varID,
    00078                                                 double value);
    00079
    00081                                         // ObservationInterface interfaces.
    00083
    00094                                         virtual ValueIdentifier getCurrentState(DiscreteVariableIdentifier varID);
    00095
    00106                                         virtual double getCurrentState(ContinuousVariableIdentifier varID);
    00107
    00109                                         // Other functions.
    00111
    00123                                         void addObservationInterface(Mers::Interfaces::ObservationInterface * obsInterface);
    00124
    00134                                         void connectTitanInterface(
    00135                                                 Mers::Interfaces::ObservationUpdateListener * pTitan);
    00136
    00137
    00150                                         void observe(ContinuousVariableIdentifier observationUID, double observationValue);
    00151
    00168                                         ContinuousVariableIdentifier getObservationUID(char * observationName,int observationIndex );
    00169
    00182                                         int initialize(char* robotSensorClasses[], int * robotAvailInst,
    00183                                                 int numRobotClasses);
    00184                                         // initialize is called by RobotListener to link
    00185                                         // robot-specific information into the
    00186                                         // discreteObservationConverter
    00187
    00193                                         void print(std::ostream & out);
    00194
    00195                                 private:
    00197                                         char m_ConfigFileName[256];
    00198
    00200                                         int m_CurrentLine;
    00201
    00204                                         typedef std::map<ContinuousVariableIdentifier, VariableLookupNode *>
    00205                                                 t_CVarDiscMap;
    00206
    00209                                         t_CVarDiscMap m_DiscritizationMap;
    00210
    00212                                         typedef std::map<ContinuousVariableIdentifier, double>
    00213                                                 t_CVarStateMap;
    00215                                         t_CVarStateMap m_CurrentStateMap;
    00216
    00218                                         typedef std::pair<char *, int> t_SensorData;
    00219
    00223                                         class SensorDataComparator {
    00224                                         public:
    00235                                                 bool operator()(t_SensorData p1, t_SensorData p2) const;
    00236                                         };
    00237
    00239                                         typedef std::map<t_SensorData, ContinuousVariableIdentifier,
    00240                                                 SensorDataComparator> t_SensorMap;
    00242                                         t_SensorMap m_SensorMap;
    00243
    00244                                 protected:
    00249                                         int useConfigFile (std::ifstream &configStream);
    00250
    00252                                         char skip(std::ifstream & input);
    00253                                         char getWord(std::ifstream & input, char * storage);
    00254                                         int process(std::ifstream &configStream);
    00255                                         bool isWhiteSpace( char c);
    00256                                         bool isDigit(char c);
    00257                                         void displaySyntaxError(const char *expected);
    00258                                         int processRangeBlock( std::ifstream &configStream,
    00259                                                 DomainLookupNodeData * current);
    00260                                         int processSimplePlantVar( std::ifstream &configStream, char *word);
    00261                                         int processCompoundPlantVar( std::ifstream &configStream, char *word);
    00262                                         bool rangeOverlap(const double rangeStart, const double rangeEnd,
    00263                                                 const DomainLookupNodeData &head );
    00264
    00275                                         void instantiateDomainData(VariableLookupNode &varNode,
    00276                                                 const DomainLookupNodeData * domainDataHead);
    00277
    00286                                         int loadCompoundDomain( std::ifstream &configStream, char * word,
    00287                                                 int lowIndex, int highIndex,
    00288                                                 std::vector<VariableLookupNode *> &temp);
    00289                                 };
    00290                         }
    00291                 }
    00292         }
    00293 }
    00294
    00295
    00296 #endif
    00297
    00298