Public Member Functions

AutoAssociativeMemoryModule Class Reference

AssociativeMemoryModule Class. More...

#include <autoAssociativeMemoryModule.h>

Public Member Functions

virtual bool configure (yarp::os::ResourceFinder &rf)
 AAM Module open.
virtual bool updateModule ()
virtual bool interruptModule ()
virtual bool close ()
virtual double getPeriod ()
virtual bool respond (const Bottle &command, Bottle &reply)

Detailed Description

AssociativeMemoryModule Class.

Brief AAM module, as outlined in the iCub cognitive architecture spec. This particular implementation uses color histogram intersection methods to recall images from stored memories. For more information on this spec, see the Wiki.

Definition at line 261 of file autoAssociativeMemoryModule.h.


Member Function Documentation

bool AutoAssociativeMemoryModule::configure ( yarp::os::ResourceFinder &  rf  )  [virtual]

AAM Module open.

This is inherited from the module class.

Definition at line 307 of file autoAssociativeMemoryModule.cpp.

{
    /* get the module name which will form the stem of all module port names */

    moduleName            = rf.check("name", 
                            Value("aam"), 
                            "module name (string)").asString(); 

    /*
     * before continuing, set the module name before getting any other parameters, 
     * specifically the port names which are dependent on the module name
     */
   
    setName(moduleName.c_str());

  
    // parse parameters or assign default values (append to getName=="/aam")

    _namePortImageIn     = "/";
    _namePortImageIn    += getName(
                           rf.check("portImageIn",
                                           Value("/image:i"),
                                           "Input image port (string)").asString()
                           );

    _namePortThresholdIn = "/";
    _namePortThresholdIn+= getName(
                           rf.check("portThresholdIn",
                                               Value("/threshold:i"),
                                               "Input threshold port (string)").asString()
                           );

    _namePortImageOut    = "/";
    _namePortImageOut   += getName(
                           rf.check("portImageOut",
                                           Value("/image:o"),
                                           "Output image port (string)").asString()
                           );

    _namePortValueOut    = "/";
    _namePortValueOut   += getName(
                           rf.check("portValueOut",
                                           Value("/value:o"),
                                           "Output value port (string)").asString()
                           );

    string databaseName  = rf.check("database",
                                               Value("defaultDatabase"),
                                               "Database name (string)").asString().c_str();

    string path          = rf.check("path",
                                           Value("~/iCub/app/autoAssociativeMemory"),
                                   "complete path to context").asString().c_str(); 

    double thr           = rf.check("threshold",
                           Value(0.6),
                           "initial threshold value (double)").asDouble();

    // printf("autoAssociativeMemory: parameters are \n%s\n%s\n%s\n%s\n%s\n%s\n%f\n\n",
    //       _namePortImageIn.c_str(),_namePortThresholdIn.c_str(), _namePortImageOut.c_str(), _namePortValueOut.c_str(), databaseName.c_str(), path.c_str(), thr);
    
    data.setThreshold(thr);
   

    /* Changed the way the database context is handled:
     * it used to be the concatenation of the path parameter and the context parameter
     * however, at present, there is no way to find out the context if it is not set explicitly as a parameter, 
     * either in the config file on the command line, such as would be the case when using the default configuration
     * In addition, the current policy is for the context to be $ICUB_ROOT/app/moduleName/conf and this means that
     * the database directory would be under the conf directory and this doesn't make much sense.
     * Consequently, the path parameter is now redefined to be the full path to the database directory
     * and can, therefore, be located anywhere you like (specifically, it doesn't have to be located in the iCub repository)
     */

    data.setDatabaseContext(path);
    //std::cout << "autoAssociativeMemory: databaseContext " << path.c_str() << endl << endl;
    
        data.setDatabaseName(databaseName);
    //std::cout << "autoAssociativeMemory: databaseName    " << databaseName.c_str() << endl << endl;
    
    data.loadDatabase();

    // create AAM ports
    _portThresholdIn = new ThresholdReceiver(&data, &_portImageIn, &_portImageOut, &_portValueOut);

    _portThresholdIn->useCallback();

    _portImageIn.open(_namePortImageIn.c_str());
    _portThresholdIn->open(_namePortThresholdIn.c_str());
    _portImageOut.open(_namePortImageOut.c_str());
    _portValueOut.open(_namePortValueOut.c_str());

    // attach a port to the module
    // so that messages received from the port are redirected
    // to the respond method
   
    _nameHandlerPort =  "/";
    _nameHandlerPort += getName();          
 
    handlerPort.open(_nameHandlerPort.c_str());  
 
    attach(handlerPort);   
    attachTerminal();     //attach to terminal
        
    return true;
}


The documentation for this class was generated from the following files:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Friends Defines