icub-client
Classes

Module integrating an interface for dealing with homeostatic needs Version:1.0. More...

+ Collaboration diagram for homeostasis:

Classes

class  Drive
 
class  HomeostasisManager
 
class  HomeostaticModule
 

Detailed Description

Module integrating an interface for dealing with homeostatic needs Version:1.0.

Author
Jordi-Ysard Puigbò jordi.nosp@m.ysar.nosp@m.d.pui.nosp@m.gbo@.nosp@m.upf.e.nosp@m.du, Clément Moulin-Frier cleme.nosp@m.nt.m.nosp@m.oulin.nosp@m.-fri.nosp@m.er@up.nosp@m.f.ed.nosp@m.u

Description

Module that internally handles the dynamics of the defined needs. Needs are internal variables linked to external measurements (or sensations) and associated drives (e.g. the drive to ask satisfies the need of acquiring new knowledge). Needs are tipically defined by some dynamics (i.e. a decay or a direct dependence to a variable), their internal value (i.e. current state of the need) and an upper and lower boundaries, limiting a zone of confort where an action is not required. This module is strongly dependent on the allostaticController and sensationsManager. An example of how to create a drive can be found in app/reactiveLayer/homeostasis/conf/example.ini

Parameters

Input Ports

Output Ports

Services


Class Documentation

◆ Drive

class Drive

Definition at line 14 of file homeostasis.h.

Public Member Functions

 Drive (std::string d_name, double d_period, std::string d_key="default", double d_value=0.5, double d_homeo_min=0.25, double d_homeo_max=0.75, double d_decay=0.05, double d_value_min=std::numeric_limits< double >::min(), double d_value_max=std::numeric_limits< double >::max(), bool d_gradient=false)
 
 Drive ()=delete
 No default constructor! More...
 
void setKey (std::string d_key)
 
void setValue (double d_value)
 
void deltaValue (double d_value)
 
void setHomeostasisMin (double d_homeo_min)
 
void deltaHomeostasisMin (double d_homeo_min)
 
void setHomeostasisMax (double d_homeo_max)
 
void deltaHomeostasisMax (double d_homeo_max)
 
void setDecay (double d_decay)
 
void deltaDecay (double d_decay)
 
void setDecayMultiplier (double mult)
 
void sleep (double t)
 sleep Sleep drive for t seconds, i.e. More...
 
void freeze ()
 freeze Freeze (sleep) drive indefinitely More...
 
void reset ()
 reset Set value back to default_value More...
 
void unfreeze ()
 unfreeze Unfreeze drive More...
 
void update ()
 update Let drive decay More...
 
double getValue ()
 
void setName (std::string n)
 
void setGradient (bool b)
 

Public Attributes

std::string name
 Name of the drive. More...
 
std::string key
 Deprecated, not used anymore. More...
 
double period
 
double value
 
double homeostasisMin
 
double homeostasisMax
 
double decay
 
double valueMin
 
double valueMax
 
double default_value
 
double decay_multiplier
 
bool gradient
 
time_t start_sleep
 Time when the drive started to be sleeping. More...
 
bool is_sleeping
 Whether drive is sleeping. More...
 
double time_to_sleep
 Timespan to be sleeping. More...
 

Constructor & Destructor Documentation

◆ Drive() [1/2]

Drive::Drive ( std::string  d_name,
double  d_period,
std::string  d_key = "default",
double  d_value = 0.5,
double  d_homeo_min = 0.25,
double  d_homeo_max = 0.75,
double  d_decay = 0.05,
double  d_value_min = std::numeric_limits<double>::min(),
double  d_value_max = std::numeric_limits<double>::max(),
bool  d_gradient = false 
)
inline

Definition at line 26 of file homeostasis.h.

◆ Drive() [2/2]

Drive::Drive ( )
delete

No default constructor!

Member Function Documentation

◆ deltaDecay()

void Drive::deltaDecay ( double  d_decay)
inline

Definition at line 88 of file homeostasis.h.

◆ deltaHomeostasisMax()

void Drive::deltaHomeostasisMax ( double  d_homeo_max)
inline

Definition at line 79 of file homeostasis.h.

◆ deltaHomeostasisMin()

void Drive::deltaHomeostasisMin ( double  d_homeo_min)
inline

Definition at line 70 of file homeostasis.h.

◆ deltaValue()

void Drive::deltaValue ( double  d_value)
inline

Definition at line 61 of file homeostasis.h.

◆ freeze()

void Drive::freeze ( )
inline

freeze Freeze (sleep) drive indefinitely

Definition at line 111 of file homeostasis.h.

◆ getValue()

double Drive::getValue ( )
inline

Definition at line 146 of file homeostasis.h.

◆ reset()

void Drive::reset ( )
inline

reset Set value back to default_value

Definition at line 120 of file homeostasis.h.

◆ setDecay()

void Drive::setDecay ( double  d_decay)
inline

Definition at line 84 of file homeostasis.h.

◆ setDecayMultiplier()

void Drive::setDecayMultiplier ( double  mult)
inline

Definition at line 93 of file homeostasis.h.

◆ setGradient()

void Drive::setGradient ( bool  b)
inline

Definition at line 156 of file homeostasis.h.

◆ setHomeostasisMax()

void Drive::setHomeostasisMax ( double  d_homeo_max)
inline

Definition at line 75 of file homeostasis.h.

◆ setHomeostasisMin()

void Drive::setHomeostasisMin ( double  d_homeo_min)
inline

Definition at line 66 of file homeostasis.h.

◆ setKey()

void Drive::setKey ( std::string  d_key)
inline

Definition at line 53 of file homeostasis.h.

◆ setName()

void Drive::setName ( std::string  n)
inline

Definition at line 151 of file homeostasis.h.

◆ setValue()

void Drive::setValue ( double  d_value)
inline

Definition at line 57 of file homeostasis.h.

◆ sleep()

void Drive::sleep ( double  t)
inline

sleep Sleep drive for t seconds, i.e.

drive won't decay

Parameters
ttime to sleep

Definition at line 102 of file homeostasis.h.

◆ unfreeze()

void Drive::unfreeze ( )
inline

unfreeze Unfreeze drive

Definition at line 127 of file homeostasis.h.

◆ update()

void Drive::update ( )
inline

update Let drive decay

Definition at line 134 of file homeostasis.h.

Member Data Documentation

◆ decay

double Drive::decay

Definition at line 20 of file homeostasis.h.

◆ decay_multiplier

double Drive::decay_multiplier

Definition at line 20 of file homeostasis.h.

◆ default_value

double Drive::default_value

Definition at line 20 of file homeostasis.h.

◆ gradient

bool Drive::gradient

Definition at line 21 of file homeostasis.h.

◆ homeostasisMax

double Drive::homeostasisMax

Definition at line 20 of file homeostasis.h.

◆ homeostasisMin

double Drive::homeostasisMin

Definition at line 20 of file homeostasis.h.

◆ is_sleeping

bool Drive::is_sleeping

Whether drive is sleeping.

Definition at line 23 of file homeostasis.h.

◆ key

std::string Drive::key

Deprecated, not used anymore.

Definition at line 18 of file homeostasis.h.

◆ name

std::string Drive::name

Name of the drive.

Definition at line 17 of file homeostasis.h.

◆ period

double Drive::period

Definition at line 19 of file homeostasis.h.

◆ start_sleep

time_t Drive::start_sleep

Time when the drive started to be sleeping.

Definition at line 22 of file homeostasis.h.

◆ time_to_sleep

double Drive::time_to_sleep

Timespan to be sleeping.

Definition at line 24 of file homeostasis.h.

◆ value

double Drive::value

Definition at line 20 of file homeostasis.h.

◆ valueMax

double Drive::valueMax

Definition at line 20 of file homeostasis.h.

◆ valueMin

double Drive::valueMin

Definition at line 20 of file homeostasis.h.

◆ HomeostasisManager

class HomeostasisManager

Definition at line 13 of file homeostasisManager.h.

Public Member Functions

void addDrive (Drive *D)
 addDrive Generates a drive in the homeostasis manager. More...
 
void removeDrive (int D)
 removeDrive Removes a drive in homeostasis manager. More...
 
void sleep (int D, double time)
 sleep cancels update function for a time More...
 
bool updateDrives ()
 updateDrives updates all internal values More...
 

Public Attributes

std::vector< Drive * > drives
 

Member Function Documentation

◆ addDrive()

void HomeostasisManager::addDrive ( Drive D)

addDrive Generates a drive in the homeostasis manager.

Homeostasis manager will take care of updating it. Input must be a drive and its position

Parameters
Ddrive instance to add

Definition at line 13 of file homeostasisManager.cpp.

◆ removeDrive()

void HomeostasisManager::removeDrive ( int  D)

removeDrive Removes a drive in homeostasis manager.

Anything related to this drive outside here should also be removed. This is specially useful for temporal needs or subgoals.

Parameters
Ddrive ID to remove

Definition at line 18 of file homeostasisManager.cpp.

◆ sleep()

void HomeostasisManager::sleep ( int  D,
double  time 
)

sleep cancels update function for a time

Parameters
DID drive to add
timetime to sleep

Definition at line 23 of file homeostasisManager.cpp.

◆ updateDrives()

bool HomeostasisManager::updateDrives ( )

updateDrives updates all internal values

Returns
bool success

Definition at line 4 of file homeostasisManager.cpp.

Member Data Documentation

◆ drives

std::vector<Drive*> HomeostasisManager::drives

Definition at line 18 of file homeostasisManager.h.

◆ HomeostaticModule

class HomeostaticModule

Definition at line 18 of file homeostasisManagerIcub.h.

+ Inheritance diagram for HomeostaticModule:

Public Member Functions

Drive bDrive (yarp::os::Bottle *b)
 bDrive Create Drive from Bottle More...
 
int openPorts (std::string driveName)
 openPorts opens default ports for external communication More...
 
bool configure (yarp::os::ResourceFinder &rf)
 
bool interruptModule ()
 
bool close ()
 
double getPeriod ()
 
bool updateModule ()
 
bool respond (const yarp::os::Bottle &cmd, yarp::os::Bottle &reply)
 

Member Function Documentation

◆ bDrive()

Drive HomeostaticModule::bDrive ( yarp::os::Bottle *  b)
inline

bDrive Create Drive from Bottle

Parameters
bBottle from which to create drive from
Returns
Drive newly created Drive

Definition at line 61 of file homeostasisManagerIcub.h.

◆ close()

bool HomeostaticModule::close ( )

Definition at line 451 of file homeostasisManagerIcub.cpp.

◆ configure()

bool HomeostaticModule::configure ( yarp::os::ResourceFinder &  rf)

Definition at line 79 of file homeostasisManagerIcub.cpp.

◆ getPeriod()

double HomeostaticModule::getPeriod ( )
inline

Definition at line 82 of file homeostasisManagerIcub.h.

◆ interruptModule()

bool HomeostaticModule::interruptModule ( )
inline

Definition at line 75 of file homeostasisManagerIcub.h.

◆ openPorts()

int HomeostaticModule::openPorts ( std::string  driveName)

openPorts opens default ports for external communication

Parameters
driveNamename of the drive
Returns
int success

Definition at line 49 of file homeostasisManagerIcub.cpp.

◆ respond()

bool HomeostaticModule::respond ( const yarp::os::Bottle &  cmd,
yarp::os::Bottle &  reply 
)

Definition at line 135 of file homeostasisManagerIcub.cpp.

◆ updateModule()

bool HomeostaticModule::updateModule ( )

Definition at line 394 of file homeostasisManagerIcub.cpp.