icub-client
Classes

Provide a compact way to access the iCub functionalities within the icub-client framework. More...

+ Collaboration diagram for Clients:

Classes

class  icubclient::ICubClient
 Grants access to high level motor commands (grasp, touch, look, goto, etc) of the robot as well as its internal state (drives, emotions, beliefs) and its interaction means (speech). More...
 
class  icubclient::OPCClient
 An OPC client using the datastructures defined within the icub-client library. More...
 

Detailed Description

Provide a compact way to access the iCub functionalities within the icub-client framework.


Class Documentation

◆ icubclient::ICubClient

class icubclient::ICubClient

Grants access to high level motor commands (grasp, touch, look, goto, etc) of the robot as well as its internal state (drives, emotions, beliefs) and its interaction means (speech).

Definition at line 66 of file icubClient.h.

Public Member Functions

template<class T >
T * getSubSystem (const std::string &subSystemName)
 
template<class T >
T * getSubSystem (T)
 get a subsystem by just providing the type untested, just to play around with C++11 More...
 
SubSystem_agentDetectorgetAgentDetectorClient ()
 
SubSystem_AREgetARE ()
 
SubSystem_babblinggetBabblingClient ()
 
SubSystem_IOL2OPCgetIOL2OPCClient ()
 
SubSystem_KARMAgetKARMA ()
 
SubSystem_RecoggetRecogClient ()
 
SubSystem_SpeechgetSpeechClient ()
 
SubSystem_SAMgetSAMClient ()
 
SubSystem_emotiongetEmotionClient ()
 
 ICubClient (const std::string &moduleName, const std::string &context="icubClient", const std::string &clientConfigFile="client.ini", bool isRFVerbose=false)
 Create an iCub client. More...
 
bool connect (const std::string &opcName="OPC")
 Try to connect all functionalities. More...
 
bool connectOPC (const std::string &opcName="OPC")
 Try to connect to OPC. More...
 
bool connectSubSystems ()
 Try to connect to all sub-systems. More...
 
void updateAgent ()
 Retrieve fresh definition of the iCub agent from the OPC. More...
 
void commitAgent ()
 Commit the local definition of iCub agent to the OPC. More...
 
bool home (const std::string &part="all")
 Go in home position. More...
 
bool release (const std::string &oLocation, const yarp::os::Bottle &options=yarp::os::Bottle())
 Release the hand-held object on a given location. More...
 
bool release (const yarp::sig::VectorOf< double > &target, const yarp::os::Bottle &options=yarp::os::Bottle())
 Release the hand-held object on a given location. More...
 
bool point (const yarp::sig::VectorOf< double > &target, const yarp::os::Bottle &options=yarp::os::Bottle())
 Point at a specified location from the iCub. More...
 
bool point (const double x, const double y, const double z, const yarp::os::Bottle &options=yarp::os::Bottle())
 
bool point (const std::string &oLocation, const yarp::os::Bottle &options=yarp::os::Bottle())
 Point at a specified location. More...
 
bool waving (const bool sw)
 Enable/disable arms waving. More...
 
bool push (const std::string &oLocation, const yarp::os::Bottle &options=yarp::os::Bottle())
 Push at a specified location. More...
 
bool take (const std::string &oName, const yarp::os::Bottle &options=yarp::os::Bottle())
 Take (grasp) an object. More...
 
bool pushKarmaLeft (const std::string &objName, const double &targetPosYLeft, const std::string &armType="selectable", const yarp::os::Bottle &options=yarp::os::Bottle())
 pushKarmaLeft: push an object by name to left side See the SubSystem_KARMA::pushAside documentation for more details. More...
 
bool pushKarmaRight (const std::string &objName, const double &targetPosYRight, const std::string &armType="selectable", const yarp::os::Bottle &options=yarp::os::Bottle())
 pushKarmaRight: push an object by name to right side See the SubSystem_KARMA::pushAside documentation for more details. More...
 
bool pushKarmaFront (const std::string &objName, const double &targetPosXFront, const std::string &armType="selectable", const yarp::os::Bottle &options=yarp::os::Bottle())
 pushKarmaFront: push an object by name to front See the SubSystem_KARMA::pushFront documentation for more details. More...
 
bool pullKarmaBack (const std::string &objName, const double &targetPosXBack, const std::string &armType="selectable", const yarp::os::Bottle &options=yarp::os::Bottle())
 pullKarmaBack: pull an object by name back See the SubSystem_KARMA::pullBack documentation for more details. More...
 
bool pushKarma (const yarp::sig::VectorOf< double > &targetCenter, const double &theta, const double &radius, const yarp::os::Bottle &options=yarp::os::Bottle())
 pushKarma (KARMA): push to certain position, along a direction See the SubSystem_KARMA::push documentation for more details. More...
 
bool drawKarma (const yarp::sig::VectorOf< double > &targetCenter, const double &theta, const double &radius, const double &dist, const yarp::os::Bottle &options=yarp::os::Bottle())
 drawKarma (KARMA): draw action, along the positive direction of the x-axis (in robot FoR) See the SubSystem_KARMA::draw documentation for more details. More...
 
bool look (const std::string &target, const yarp::os::Bottle &options=yarp::os::Bottle())
 Look at a specified target object. More...
 
bool look (const yarp::sig::VectorOf< double > &target, const yarp::os::Bottle &options=yarp::os::Bottle())
 Look at a specified target location. More...
 
bool lookAtPartner ()
 Looks at the agent if present in the scene. More...
 
bool lookAtBodypart (const std::string &sBodypartName)
 Looks at the agent specific bodypart if present in the scene. More...
 
std::string getPartnerName (bool verbose=true)
 Extract the name of the agent interaction with the iCub (present, not iCub nor 'unnamed' partner) More...
 
yarp::sig::VectorOf< double > getPartnerBodypartLoc (std::string sBodypartName)
 Extract the location of the bodypart name of the partner. More...
 
bool babbling (int jointNumber, const std::string &babblingArm, double train_dur=-1.0)
 Babbling using a single joint. More...
 
bool babbling (const std::string &bpName, const std::string &babblingArm, double train_dur=-1.0)
 Babbling with a single joint using the name of a corresponding bodypart See the SubSystem_babbling::babbling documentation for more details. More...
 
bool say (const std::string &text, bool shouldWait=true)
 Ask the robot to perform speech synthesis of a given sentence. More...
 
bool changeName (Entity *e, const std::string &newName)
 Change the name of a given entity. More...
 
std::tuple< std::string, double > getHighestEmotion ()
 Get the strongest emotion. More...
 
std::list< Action * > getKnownActions ()
 Get the list of actions known the iCub. More...
 
std::list< Object * > getObjectsInSight ()
 Get the list of object that are in front of the iCub Warning: this will update the local icubAgent. More...
 
std::list< Object * > getObjectsInRange ()
 Get the list of objects that are graspable by the iCub See isTargetInRange() for a definition of how an object is defined to be in range Warning: this will update the local icubAgent. More...
 
bool isTargetInRange (const yarp::sig::VectorOf< double > &target) const
 Check if a given cartesian position is within the reach of the robot This can be adjusted using the reachingRangeMin and reachingRangeMax parameters in the configuration file (client.ini) More...
 
void close ()
 Properly closes all ports which were opened. More...
 
virtual ~ICubClient ()
 Destructor. More...
 

Public Attributes

OPCClientopc
 
AgenticubAgent
 

Protected Attributes

std::map< std::string, SubSystem * > subSystems
 
bool closed
 
std::list< Action * > actionsKnown
 
double xRangeMin
 
double yRangeMin
 
double zRangeMin
 
double xRangeMax
 
double yRangeMax
 
double zRangeMax
 
std::string robot
 

Constructor & Destructor Documentation

◆ ICubClient()

ICubClient::ICubClient ( const std::string &  moduleName,
const std::string &  context = "icubClient",
const std::string &  clientConfigFile = "client.ini",
bool  isRFVerbose = false 
)

Create an iCub client.

Parameters
moduleNameThe port namespace that will precede the client ports names.
contextThe yarp context to be used.
clientConfigFileThe yarp config file to be used.
isRFVerboseWhether the yarp resource finder should be verbose

Definition at line 37 of file icubClient.cpp.

◆ ~ICubClient()

ICubClient::~ICubClient ( )
virtual

Destructor.

Definition at line 161 of file icubClient.cpp.

Member Function Documentation

◆ babbling() [1/2]

bool ICubClient::babbling ( int  jointNumber,
const std::string &  babblingArm,
double  train_dur = -1.0 
)

Babbling using a single joint.

See the SubSystem_babbling::babbling documentation for more details.

Parameters
jointNumbercontains the int corresponding to an arm joint
babblingArmcontains the string corresponding to the side of the arm used ("left" or "right")
train_durset the babbling time, if "-1" use default time
Returns
true in case of success release, false otherwise

Definition at line 344 of file icubClient.cpp.

◆ babbling() [2/2]

bool ICubClient::babbling ( const std::string &  bpName,
const std::string &  babblingArm,
double  train_dur = -1.0 
)

Babbling with a single joint using the name of a corresponding bodypart See the SubSystem_babbling::babbling documentation for more details.

Parameters
bpNamecontains the string with the name of the bodypart
babblingArmcontains the string corresponding to the side of the arm used ("left" or "right")
train_durset the babbling time, if "-1" use default time
Returns
true in case of success release, false otherwise (bodypart non existing, no joint number assigned, etc.).

Definition at line 312 of file icubClient.cpp.

◆ changeName()

bool ICubClient::changeName ( Entity e,
const std::string &  newName 
)

Change the name of a given entity.

Parameters
e- the entity whose name should be changed
newName- the new name of the entity
Returns
true in case the name was changed, false otherwise

Definition at line 183 of file icubClient.cpp.

◆ close()

void ICubClient::close ( )

Properly closes all ports which were opened.

This is being called automatically in the destructor, there is typically no need to call this manually.

Definition at line 140 of file icubClient.cpp.

◆ commitAgent()

void ICubClient::commitAgent ( )

Commit the local definition of iCub agent to the OPC.

Definition at line 245 of file icubClient.cpp.

◆ connect()

bool ICubClient::connect ( const std::string &  opcName = "OPC")

Try to connect all functionalities.

Parameters
opcNamethe stem-name of the OPC server.
Returns
true in case of success false if some connections are missing.

Definition at line 132 of file icubClient.cpp.

◆ connectOPC()

bool ICubClient::connectOPC ( const std::string &  opcName = "OPC")

Try to connect to OPC.

Parameters
opcNamethe stem-name of the OPC server.
Returns
true on success.

Definition at line 107 of file icubClient.cpp.

◆ connectSubSystems()

bool ICubClient::connectSubSystems ( )

Try to connect to all sub-systems.

Returns
true on success.

Definition at line 117 of file icubClient.cpp.

◆ drawKarma()

bool ICubClient::drawKarma ( const yarp::sig::VectorOf< double > &  targetCenter,
const double &  theta,
const double &  radius,
const double &  dist,
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

drawKarma (KARMA): draw action, along the positive direction of the x-axis (in robot FoR) See the SubSystem_KARMA::draw documentation for more details.

Parameters
targetCentercenter of a circle
thetaangle between the y-axis (in robot FoR) and starting position of draw action.
radiusradius of the circle with center at
See also
targetCenter
Parameters
distmoving distance of draw action
optionsoptions to be passed to Karma
Returns
true in case of success release, false otherwise

Definition at line 199 of file icubClient_KARMArelated.cpp.

◆ getAgentDetectorClient()

SubSystem_agentDetector * ICubClient::getAgentDetectorClient ( )

Definition at line 454 of file icubClient.cpp.

◆ getARE()

SubSystem_ARE * ICubClient::getARE ( )

Definition at line 474 of file icubClient.cpp.

◆ getBabblingClient()

SubSystem_babbling * ICubClient::getBabblingClient ( )

Definition at line 459 of file icubClient.cpp.

◆ getEmotionClient()

SubSystem_emotion * ICubClient::getEmotionClient ( )

Definition at line 501 of file icubClient.cpp.

◆ getHighestEmotion()

std::tuple< std::string, double > ICubClient::getHighestEmotion ( )

Get the strongest emotion.

Returns
tuple with name of emotion and intensity of emotion as items

Definition at line 354 of file icubClient.cpp.

◆ getIOL2OPCClient()

SubSystem_IOL2OPC * ICubClient::getIOL2OPCClient ( )

Definition at line 464 of file icubClient.cpp.

◆ getKARMA()

SubSystem_KARMA * ICubClient::getKARMA ( )

Definition at line 479 of file icubClient.cpp.

◆ getKnownActions()

list< Action * > ICubClient::getKnownActions ( )

Get the list of actions known the iCub.

Returns
list of pointers to actions

Definition at line 387 of file icubClient.cpp.

◆ getObjectsInRange()

list< Object * > ICubClient::getObjectsInRange ( )

Get the list of objects that are graspable by the iCub See isTargetInRange() for a definition of how an object is defined to be in range Warning: this will update the local icubAgent.

Definition at line 422 of file icubClient.cpp.

◆ getObjectsInSight()

list< Object * > ICubClient::getObjectsInSight ( )

Get the list of object that are in front of the iCub Warning: this will update the local icubAgent.

Returns
list of pointers to objects which are front of the iCub (x<0.0)

Definition at line 399 of file icubClient.cpp.

◆ getPartnerBodypartLoc()

yarp::sig::VectorOf< double > ICubClient::getPartnerBodypartLoc ( std::string  sBodypartName)

Extract the location of the bodypart name of the partner.

Parameters
sBodypartNameis the name of the bodypart (kinect skeleton node) to be looked at
Returns
vLoc, the vector of the bodypart localisation

Definition at line 274 of file icubClient.cpp.

◆ getPartnerName()

std::string ICubClient::getPartnerName ( bool  verbose = true)

Extract the name of the agent interaction with the iCub (present, not iCub nor 'unnamed' partner)

Parameters
verbose- whether a yInfo output should happen if the partner is found
Returns
string: the name of the agent

Definition at line 251 of file icubClient.cpp.

◆ getRecogClient()

SubSystem_Recog * ICubClient::getRecogClient ( )

Definition at line 469 of file icubClient.cpp.

◆ getSAMClient()

SubSystem_SAM * ICubClient::getSAMClient ( )

Definition at line 496 of file icubClient.cpp.

◆ getSpeechClient()

SubSystem_Speech * ICubClient::getSpeechClient ( )

Definition at line 484 of file icubClient.cpp.

◆ getSubSystem() [1/2]

template<class T >
T* icubclient::ICubClient::getSubSystem ( const std::string &  subSystemName)
inline

Definition at line 81 of file icubClient.h.

◆ getSubSystem() [2/2]

template<class T >
T* icubclient::ICubClient::getSubSystem ( )
inline

get a subsystem by just providing the type untested, just to play around with C++11

Definition at line 93 of file icubClient.h.

◆ home()

bool ICubClient::home ( const std::string &  part = "all")

Go in home position.

See the SubSystem_ARE::home documentation for more details.

Parameters
partthe part to be homed ("gaze", "head", "arms", "fingers", "all"; "all" by default).
Returns
true in case of successful motor command, false otherwise (e.g. wrong part name)

Definition at line 27 of file icubClient_ARErelated.cpp.

◆ isTargetInRange()

bool ICubClient::isTargetInRange ( const yarp::sig::VectorOf< double > &  target) const

Check if a given cartesian position is within the reach of the robot This can be adjusted using the reachingRangeMin and reachingRangeMax parameters in the configuration file (client.ini)

Definition at line 444 of file icubClient.cpp.

◆ look() [1/2]

bool ICubClient::look ( const std::string &  target,
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

Look at a specified target object.

See the subSystem_ARE::look documentation for more details.

Parameters
targetis the name of the entity in the OPC where the robot should look.
optionscontains options to be passed on the gaze controller.

Definition at line 162 of file icubClient_ARErelated.cpp.

◆ look() [2/2]

bool ICubClient::look ( const yarp::sig::VectorOf< double > &  target,
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

Look at a specified target location.

See the subSystem_ARE::look documentation for more details.

Parameters
targetis a vector where the robot should look.
optionscontains options to be passed on the gaze controller.

Definition at line 178 of file icubClient_ARErelated.cpp.

◆ lookAtBodypart()

bool ICubClient::lookAtBodypart ( const std::string &  sBodypartName)

Looks at the agent specific bodypart if present in the scene.

Parameters
sBodypartNameis the name of the bodypart (kinect skeleton node) to be looked at

Definition at line 189 of file icubClient_ARErelated.cpp.

◆ lookAtPartner()

bool ICubClient::lookAtPartner ( )

Looks at the agent if present in the scene.

Definition at line 307 of file icubClient.cpp.

◆ point() [1/3]

bool icubclient::ICubClient::point ( const yarp::sig::VectorOf< double > &  target,
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

Point at a specified location from the iCub.

See the SubSystem_ARE::point documentation for more details.

Parameters
targetcontains spatial information about the location where pointing at. The target can be far away from the iCub
optionsbottle containing a list of options (e.g. force to use specific hand with "left"|"right" option).
Returns
true in case of success release, false otherwise (Entity non existing, impossible to reach, etc.).

Definition at line 89 of file icubClient_ARErelated.cpp.

◆ point() [2/3]

bool icubclient::ICubClient::point ( const double  x,
const double  y,
const double  z,
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)
inline

Definition at line 203 of file icubClient.h.

◆ point() [3/3]

bool icubclient::ICubClient::point ( const std::string &  oLocation,
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

Point at a specified location.

See the SubSystem_ARE::point documentation for more details.

Parameters
oLocationis the name of the entity in the OPC where the robot should point at.
optionsbottle containing a list of options (e.g. force to use specific hand with "left"|"right" option).
Returns
true in case of success release, false otherwise (Entity non existing, impossible to reach, etc.).

Definition at line 104 of file icubClient_ARErelated.cpp.

◆ pullKarmaBack()

bool ICubClient::pullKarmaBack ( const std::string &  objName,
const double &  targetPosXBack,
const std::string &  armType = "selectable",
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

pullKarmaBack: pull an object by name back See the SubSystem_KARMA::pullBack documentation for more details.

Parameters
objNamename of object, which will be looked for in OPC
targetPosXBackX coordinate of object to pull back
armType"left" or "right" arm to conduct action, otherwise arm will be chosen by KARMA
optionsoptions to be passed to Karma
Returns
true in case of success release, false otherwise

Definition at line 160 of file icubClient_KARMArelated.cpp.

◆ push()

bool ICubClient::push ( const std::string &  oLocation,
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

Push at a specified location.

This method is deprecated, and ICubClient::pushKarmaLeft or ICubClient::pushKarmaRight should be used instead. See the SubSystem_ARE::push documentation for more details.

Parameters
oLocationis the name of the entity in the OPC where the robot should push at.
optionsbottle containing a list of options (e.g. force to use specific hand with "left"|"right" option).
Returns
true in case of success release, false otherwise (Entity non existing, impossible to reach, etc.).

Definition at line 131 of file icubClient_ARErelated.cpp.

◆ pushKarma()

bool ICubClient::pushKarma ( const yarp::sig::VectorOf< double > &  targetCenter,
const double &  theta,
const double &  radius,
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

pushKarma (KARMA): push to certain position, along a direction See the SubSystem_KARMA::push documentation for more details.

Parameters
targetCenterposition to push to.
thetaangle between the y-axis (in robot FoR) and starting position of push action, defines the direction of push action
radiusradius of the circle with center at
See also
targetCenter
Parameters
optionsoptions to be passed to Karma
Returns
true in case of success release, false otherwise

Definition at line 147 of file icubClient_KARMArelated.cpp.

◆ pushKarmaFront()

bool ICubClient::pushKarmaFront ( const std::string &  objName,
const double &  targetPosXFront,
const std::string &  armType = "selectable",
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

pushKarmaFront: push an object by name to front See the SubSystem_KARMA::pushFront documentation for more details.

Parameters
objNamename of object, which will be looked for in OPC
targetPosXFrontX coordinate of object to push to
armType"left" or "right" arm to conduct action, otherwise arm will be chosen by KARMA
optionsoptions to be passed to Karma
Returns
true in case of success release, false otherwise

Definition at line 108 of file icubClient_KARMArelated.cpp.

◆ pushKarmaLeft()

bool ICubClient::pushKarmaLeft ( const std::string &  objName,
const double &  targetPosYLeft,
const std::string &  armType = "selectable",
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

pushKarmaLeft: push an object by name to left side See the SubSystem_KARMA::pushAside documentation for more details.

Parameters
objNameis the name of object, which will be looked for in OPC
targetPosYLeftY coordinate of object to push to
armType"left" or "right" arm to conduct action, otherwise arm will be chosen by KARMA
optionsoptions to be passed to Karma
Returns
true in case of success release, false otherwise

Definition at line 30 of file icubClient_KARMArelated.cpp.

◆ pushKarmaRight()

bool ICubClient::pushKarmaRight ( const std::string &  objName,
const double &  targetPosYRight,
const std::string &  armType = "selectable",
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

pushKarmaRight: push an object by name to right side See the SubSystem_KARMA::pushAside documentation for more details.

Parameters
objNameis the name of object, which will be looked for in OPC
targetPosYRightY coordinate of object to push to
armType"left" or "right" arm to conduct action, otherwise arm will be chosen by KARMA
optionsoptions to be passed to Karma
Returns
true in case of success release, false otherwise

Definition at line 69 of file icubClient_KARMArelated.cpp.

◆ release() [1/2]

bool ICubClient::release ( const std::string &  oLocation,
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

Release the hand-held object on a given location.

See the SubSystem_ARE::release documentation for more details.

Parameters
oLocationis the name of the entity in the OPC where the robot should release.
optionsbottle containing a list of options (e.g. force to use specific hand with "left"|"right" option).
Returns
true in case of success release, false otherwise (Entity non existing, impossible to reach, etc.).

Definition at line 39 of file icubClient_ARErelated.cpp.

◆ release() [2/2]

bool ICubClient::release ( const yarp::sig::VectorOf< double > &  target,
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

Release the hand-held object on a given location.

See the SubSystem_ARE::release documentation for more details.

Parameters
targetcontains spatial information about the location where releasing the object.
optionsbottle containing a list of options (e.g. force to use specific hand with "left"|"right" option).
Returns
true in case of success release, false otherwise (Entity non existing, impossible to reach, etc.).

Definition at line 59 of file icubClient_ARErelated.cpp.

◆ say()

bool ICubClient::say ( const std::string &  text,
bool  shouldWait = true 
)

Ask the robot to perform speech synthesis of a given sentence.

Parameters
textto be said.
shouldWaitWhether the method should wait until the speech was produced, or return immediately
Returns
true in case the sentence was uttered, false otherwise (speech subsystem not available)

Definition at line 374 of file icubClient.cpp.

◆ take()

bool ICubClient::take ( const std::string &  oName,
const yarp::os::Bottle &  options = yarp::os::Bottle() 
)

Take (grasp) an object.

See the subSystem_ARE::take documentation for more details.

Parameters
oNameis the name of the entity in the OPC where the robot should take at.
optionsbottle containing a list of options (e.g. force to use specific hand with "left"|"right" option).
Returns
true in case of success grasp, false otherwise (Entity non existing, impossible to reach, etc.).

Definition at line 147 of file icubClient_ARErelated.cpp.

◆ updateAgent()

void ICubClient::updateAgent ( )

Retrieve fresh definition of the iCub agent from the OPC.

Definition at line 169 of file icubClient.cpp.

◆ waving()

bool ICubClient::waving ( const bool  sw)

Enable/disable arms waving.

See the SubSystem_ARE::waving documentation for more details.

Parameters
swenable/disable if true/false.
Returns
true in case of successful request, false otherwise.

Definition at line 77 of file icubClient_ARErelated.cpp.

Member Data Documentation

◆ actionsKnown

std::list<Action*> icubclient::ICubClient::actionsKnown
protected

Definition at line 71 of file icubClient.h.

◆ closed

bool icubclient::ICubClient::closed
protected

Definition at line 70 of file icubClient.h.

◆ icubAgent

Agent* icubclient::ICubClient::icubAgent

Definition at line 113 of file icubClient.h.

◆ opc

OPCClient* icubclient::ICubClient::opc

Definition at line 112 of file icubClient.h.

◆ robot

std::string icubclient::ICubClient::robot
protected

Definition at line 77 of file icubClient.h.

◆ subSystems

std::map<std::string, SubSystem*> icubclient::ICubClient::subSystems
protected

Definition at line 69 of file icubClient.h.

◆ xRangeMax

double icubclient::ICubClient::xRangeMax
protected

Definition at line 75 of file icubClient.h.

◆ xRangeMin

double icubclient::ICubClient::xRangeMin
protected

Definition at line 74 of file icubClient.h.

◆ yRangeMax

double icubclient::ICubClient::yRangeMax
protected

Definition at line 75 of file icubClient.h.

◆ yRangeMin

double icubclient::ICubClient::yRangeMin
protected

Definition at line 74 of file icubClient.h.

◆ zRangeMax

double icubclient::ICubClient::zRangeMax
protected

Definition at line 75 of file icubClient.h.

◆ zRangeMin

double icubclient::ICubClient::zRangeMin
protected

Definition at line 74 of file icubClient.h.

◆ icubclient::OPCClient

class icubclient::OPCClient

An OPC client using the datastructures defined within the icub-client library.

Using this ensures you that your manipulation of the OPC will be done with correct formatting.

Definition at line 35 of file opcClient.h.

Public Member Functions

 OPCClient (const std::string &moduleName)
 Create an OPC client. More...
 
template<class T >
T * addEntity (const std::string &name)
 Creates a new entity. More...
 
template<class T >
T * addOrRetrieveEntity (const std::string &name)
 Obtains an entity with the given name. More...
 
bool isConnected ()
 Check if the client is already connected to the OPC server. More...
 
bool connect (const std::string &opcName)
 Try to connect the client to an OPC server. More...
 
void interrupt ()
 Interrupt communications of the client ports. More...
 
void close ()
 Close the client ports. More...
 
void clear ()
 Clear the OPC content. More...
 
bool setEntityProperty (std::string sourceEntityName, std::string propertyName, std::string targetEntityName)
 Try to assign a property from an entity to another entity, using a specific property name. More...
 
bool addRelation (const Relation &r, double lifeTime=-1)
 Obtains a relation between two entities. More...
 
bool addRelation (Entity *subject, Entity *verb, Entity *object=nullptr, double lifeTime=-1, Entity *complement_place=nullptr, Entity *complement_time=nullptr, Entity *complement_manner=nullptr)
 Obtains a relation between two entities. More...
 
bool removeRelation (const Relation &r)
 Try to remove a relation between two entities. More...
 
bool removeRelation (Entity *subject, Entity *verb, Entity *object=nullptr, Entity *complement_place=nullptr, Entity *complement_time=nullptr, Entity *complement_manner=nullptr)
 Try to remove a relation between two entities. More...
 
bool containsRelation (Entity *subject, Entity *verb, Entity *object=nullptr, Entity *complement_place=nullptr, Entity *complement_time=nullptr, Entity *complement_manner=nullptr)
 Check if a relation exists. More...
 
bool containsRelation (const Relation &r)
 Check if a relation exists. More...
 
std::list< RelationgetRelations ()
 Returns a list of all existing relations between entities. More...
 
std::list< RelationgetRelations (std::string entity)
 Returns a list of all existing relations involving a specific entities. More...
 
std::list< RelationgetRelations (Entity *entity)
 Returns a list of all existing relations involving a specific entities. More...
 
std::list< RelationgetRelationsMatching (std::string subject="any", std::string verb="any", std::string object="any", std::string c_place="any", std::string c_time="any", std::string c_manner="any")
 Returns a list of all existing relations between entities. More...
 
std::list< RelationgetRelationsMatchingLoosly (std::string subject="any", std::string verb="any", std::string object="any", std::string c_place="any", std::string c_time="any", std::string c_manner="any")
 Returns a list of all existing relations between entities. More...
 
bool setLifeTime (int id, double lifeTime)
 Set the lifetime property of a relation in the OPC. More...
 
EntitygetEntity (const std::string &name, bool forceUpdate=false)
 Gets an entity based on its name, but do no create it if it doesn't exist yet. More...
 
EntitygetEntity (int id, bool forceUpdate=false)
 Gets an entity based on its id, but do no create it if it doesn't exist yet. More...
 
bool removeEntity (const std::string &name)
 Removes an entity based on its name. More...
 
bool removeEntity (int id)
 Removes an entity based on its id. More...
 
void checkout (bool updateCache=true)
 Poll the OPC for all entities and relations and store them locally. More...
 
void update ()
 Update the properties of all locally stored entities & relations. More...
 
void update (Entity *e)
 Poll the OPC for updating a given entity properties. More...
 
void commit ()
 Commit all the entities & relations stored locally, erasing the server copies. More...
 
void commit (Entity *e)
 Commit a single local entity, erasing the server copies. More...
 
std::list< Entity * > Entities (const yarp::os::Bottle &condition)
 Getter of the list of entities of matching a complex condition (e.g "(entity "==" agent) "&&" (isPresent "==" 1) ) and update them locally. More...
 
std::list< Entity * > Entities (const std::string &prop, const std::string &op, const std::string &value)
 Getter of the list of entities matching a condition and update them locally. More...
 
std::list< Entity * > EntitiesCache () const
 Getter of the list of entities stored locally. More...
 
std::list< std::shared_ptr< Entity > > EntitiesCacheCopy () const
 Getter of the list of the copies of the entities stored locally. More...
 
std::string toString ()
 Returns a human readable description of the client content (Entities & Relations) More...
 

Public Attributes

bool isVerbose
 

Protected Member Functions

bool write (yarp::os::Bottle &cmd, yarp::os::Bottle &reply, bool Verbose=false)
 Send a command to the OPC and return the reply. More...
 
void addEntity (Entity *e)
 Send a the request to add a new entity to the OPC. More...
 
int getRelationID (Entity *subject, Entity *verb, Entity *object=nullptr, Entity *complement_place=nullptr, Entity *complement_time=nullptr, Entity *complement_manner=nullptr)
 
bool changeName (Entity *e, const std::string &newName)
 Change the name of an entity and send messages to relevant subsystems. More...
 

Protected Attributes

yarp::os::Port opc
 Port which connects to /OPC/rpc. More...
 
std::map< int, Entity * > entitiesByID
 
std::string opcName
 

Friends

class ICubClient
 

Constructor & Destructor Documentation

◆ OPCClient()

OPCClient::OPCClient ( const std::string &  moduleName)

Create an OPC client.

Parameters
moduleNameThe port namespace that will precede the client ports names.

Definition at line 32 of file opcClient.cpp.

Member Function Documentation

◆ addEntity() [1/2]

void OPCClient::addEntity ( Entity e)
protected

Send a the request to add a new entity to the OPC.

Parameters
ePointer to the entity to be added. After executing the method, it will contain the updated entity.

Definition at line 95 of file opcClient.cpp.

◆ addEntity() [2/2]

template<class T >
T* icubclient::OPCClient::addEntity ( const std::string &  name)
inline

Creates a new entity.

If an Entity with the provided name is already existing, a new Entity with an appended number is returned. It is a template method, so all subclasses of Entity can be created like this

Parameters
nameName of the new entity
Returns
Newly created entity

Definition at line 92 of file opcClient.h.

◆ addOrRetrieveEntity()

template<class T >
T* icubclient::OPCClient::addOrRetrieveEntity ( const std::string &  name)
inline

Obtains an entity with the given name.

If this name is already present, then the existing entity is returned, otherwise a new one is created. It is a template method, so all subclasses of Entity can be created like this

Parameters
nameName of the entity to be retrieved / created
Returns
Entity

Definition at line 119 of file opcClient.h.

◆ addRelation() [1/2]

bool OPCClient::addRelation ( const Relation r,
double  lifeTime = -1 
)

Obtains a relation between two entities.

If this relation is already present on the server side then the local relations are updated, else a new one is created. The relation is directly added on the server side.

Parameters
r- The relation to be added on the server
lifeTime- how long the relation should last for
Returns
true in case of success (relation was not present and was successfuly added), false in other cases.

Definition at line 390 of file opcClient.cpp.

◆ addRelation() [2/2]

bool OPCClient::addRelation ( Entity subject,
Entity verb,
Entity object = nullptr,
double  lifeTime = -1,
Entity complement_place = nullptr,
Entity complement_time = nullptr,
Entity complement_manner = nullptr 
)

Obtains a relation between two entities.

If this relation already present on the server side then the local relations are updated, else a new one is created. The relation is directly added on the server side.

Parameters
lifeTime- how long the relation should last for
Returns
true in case of success (relation was not present and was successfuly added), false in other cases.

Definition at line 408 of file opcClient.cpp.

◆ changeName()

bool OPCClient::changeName ( Entity e,
const std::string &  newName 
)
protected

Change the name of an entity and send messages to relevant subsystems.

Parameters
eEntity whose name is to be changed
newNameDesired name of e

Definition at line 969 of file opcClient.cpp.

◆ checkout()

void OPCClient::checkout ( bool  updateCache = true)

Poll the OPC for all entities and relations and store them locally.

Parameters
updateCacheIf this option is turned on the local cache will be wiped

Definition at line 754 of file opcClient.cpp.

◆ clear()

void OPCClient::clear ( )

Clear the OPC content.

Definition at line 80 of file opcClient.cpp.

◆ close()

void OPCClient::close ( )

Close the client ports.

Definition at line 69 of file opcClient.cpp.

◆ commit() [1/2]

void OPCClient::commit ( )

Commit all the entities & relations stored locally, erasing the server copies.

Definition at line 835 of file opcClient.cpp.

◆ commit() [2/2]

void OPCClient::commit ( Entity e)

Commit a single local entity, erasing the server copies.

Parameters
eA pointer to the entity to be commited

Definition at line 844 of file opcClient.cpp.

◆ connect()

bool icubclient::OPCClient::connect ( const std::string &  opcName)
inline

Try to connect the client to an OPC server.

Parameters
opcNamethe name of the OPC module to connect to.

Definition at line 157 of file opcClient.h.

◆ containsRelation() [1/2]

bool OPCClient::containsRelation ( Entity subject,
Entity verb,
Entity object = nullptr,
Entity complement_place = nullptr,
Entity complement_time = nullptr,
Entity complement_manner = nullptr 
)

Check if a relation exists.

Returns
true in case the relation exists, false otherwise

Definition at line 501 of file opcClient.cpp.

◆ containsRelation() [2/2]

bool OPCClient::containsRelation ( const Relation r)

Check if a relation exists.

Parameters
r- relation to be checked
Returns
true in case the relation exists, false otherwise

Definition at line 513 of file opcClient.cpp.

◆ Entities() [1/2]

std::list< Entity * > OPCClient::Entities ( const yarp::os::Bottle &  condition)

Getter of the list of entities of matching a complex condition (e.g "(entity "==" agent) "&&" (isPresent "==" 1) ) and update them locally.

Definition at line 865 of file opcClient.cpp.

◆ Entities() [2/2]

list< Entity * > OPCClient::Entities ( const std::string &  prop,
const std::string &  op,
const std::string &  value 
)

Getter of the list of entities matching a condition and update them locally.

Definition at line 893 of file opcClient.cpp.

◆ EntitiesCache()

list< Entity * > OPCClient::EntitiesCache ( ) const

Getter of the list of entities stored locally.

Definition at line 905 of file opcClient.cpp.

◆ EntitiesCacheCopy()

std::list< std::shared_ptr< Entity > > OPCClient::EntitiesCacheCopy ( ) const

Getter of the list of the copies of the entities stored locally.

Definition at line 917 of file opcClient.cpp.

◆ getEntity() [1/2]

Entity * OPCClient::getEntity ( const std::string &  name,
bool  forceUpdate = false 
)

Gets an entity based on its name, but do no create it if it doesn't exist yet.

Parameters
nameThe name of the entity to retrieve.
forceUpdateUpdate the entity instead of retrieving from the cache. (false by default)
Returns
Pointer to the entity or nullptr if not existing

Definition at line 134 of file opcClient.cpp.

◆ getEntity() [2/2]

Entity * OPCClient::getEntity ( int  id,
bool  forceUpdate = false 
)

Gets an entity based on its id, but do no create it if it doesn't exist yet.

Parameters
idThe ID of the entity to retrieve.
forceUpdateUpdate the entity instead of retrieving from the cache. (false by default)
Returns
Pointer to the entity or nullptr if not existing

Definition at line 181 of file opcClient.cpp.

◆ getRelationID()

int OPCClient::getRelationID ( Entity subject,
Entity verb,
Entity object = nullptr,
Entity complement_place = nullptr,
Entity complement_time = nullptr,
Entity complement_manner = nullptr 
)
protected

Definition at line 302 of file opcClient.cpp.

◆ getRelations() [1/3]

list< Relation > OPCClient::getRelations ( )

Returns a list of all existing relations between entities.

Definition at line 570 of file opcClient.cpp.

◆ getRelations() [2/3]

std::list< Relation > OPCClient::getRelations ( std::string  entity)

Returns a list of all existing relations involving a specific entities.

Definition at line 729 of file opcClient.cpp.

◆ getRelations() [3/3]

std::list< Relation > OPCClient::getRelations ( Entity entity)

Returns a list of all existing relations involving a specific entities.

Definition at line 748 of file opcClient.cpp.

◆ getRelationsMatching()

std::list< Relation > OPCClient::getRelationsMatching ( std::string  subject = "any",
std::string  verb = "any",
std::string  object = "any",
std::string  c_place = "any",
std::string  c_time = "any",
std::string  c_manner = "any" 
)

Returns a list of all existing relations between entities.

All the roles with something other than "any" will act as filters for the relation.

Definition at line 617 of file opcClient.cpp.

◆ getRelationsMatchingLoosly()

std::list< Relation > OPCClient::getRelationsMatchingLoosly ( std::string  subject = "any",
std::string  verb = "any",
std::string  object = "any",
std::string  c_place = "any",
std::string  c_time = "any",
std::string  c_manner = "any" 
)

Returns a list of all existing relations between entities.

All the roles with something else than "any" will act as filters for the relation. All relations with at least one role matching will be returned.

Definition at line 710 of file opcClient.cpp.

◆ interrupt()

void OPCClient::interrupt ( )

Interrupt communications of the client ports.

Definition at line 64 of file opcClient.cpp.

◆ isConnected()

bool icubclient::OPCClient::isConnected ( )
inline

Check if the client is already connected to the OPC server.

Warning, this method tries to connect to the OPC again in case it is not connected yet.

Returns
Whether the OPC was already connected OR whether the new connect was successful

Definition at line 141 of file opcClient.h.

◆ removeEntity() [1/2]

bool OPCClient::removeEntity ( const std::string &  name)

Removes an entity based on its name.

Parameters
nameThe name of the entity to remove.
Returns
true/false if succeeded/failed.

Definition at line 246 of file opcClient.cpp.

◆ removeEntity() [2/2]

bool OPCClient::removeEntity ( int  id)

Removes an entity based on its id.

Parameters
idThe ID of the entity to retrieve.
Returns
true/false if succeeded/failed.

Definition at line 273 of file opcClient.cpp.

◆ removeRelation() [1/2]

bool OPCClient::removeRelation ( const Relation r)

Try to remove a relation between two entities.

The relation is directly removed on the server side.

Parameters
r- relation to be removed
Returns
true in case of success (final state no relation locally/server), false otherwise

Definition at line 450 of file opcClient.cpp.

◆ removeRelation() [2/2]

bool OPCClient::removeRelation ( Entity subject,
Entity verb,
Entity object = nullptr,
Entity complement_place = nullptr,
Entity complement_time = nullptr,
Entity complement_manner = nullptr 
)

Try to remove a relation between two entities.

The relation is directly removed on the server side.

Returns
true in case of success (final state no relation locally/server), false otherwise

Definition at line 462 of file opcClient.cpp.

◆ setEntityProperty()

bool OPCClient::setEntityProperty ( std::string  sourceEntityName,
std::string  propertyName,
std::string  targetEntityName 
)

Try to assign a property from an entity to another entity, using a specific property name.

Parameters
sourceEntityNameName of the entity the property should be copied from
propertyNameName of the property to be copied
targetEntityNameName of the entity where the property should be copied into

Definition at line 122 of file opcClient.cpp.

◆ setLifeTime()

bool OPCClient::setLifeTime ( int  id,
double  lifeTime 
)

Set the lifetime property of a relation in the OPC.

Returns
true in case of success, false otherwise

Definition at line 524 of file opcClient.cpp.

◆ toString()

string OPCClient::toString ( )

Returns a human readable description of the client content (Entities & Relations)

Definition at line 954 of file opcClient.cpp.

◆ update() [1/2]

void OPCClient::update ( )

Update the properties of all locally stored entities & relations.

Definition at line 794 of file opcClient.cpp.

◆ update() [2/2]

void OPCClient::update ( Entity e)

Poll the OPC for updating a given entity properties.

Parameters
eA pointer on the entity to update.

Definition at line 803 of file opcClient.cpp.

◆ write()

bool OPCClient::write ( yarp::os::Bottle &  cmd,
yarp::os::Bottle &  reply,
bool  Verbose = false 
)
protected

Send a command to the OPC and return the reply.

Parameters
cmdthe command to be send to the OPC
replyreference to the reply of the OPC
VerboseWhether to output additional information using yInfo()

Definition at line 39 of file opcClient.cpp.

Friends And Related Function Documentation

◆ ICubClient

friend class ICubClient
friend

Definition at line 37 of file opcClient.h.

Member Data Documentation

◆ entitiesByID

std::map<int, Entity*> icubclient::OPCClient::entitiesByID
protected

Definition at line 50 of file opcClient.h.

◆ isVerbose

bool icubclient::OPCClient::isVerbose

Definition at line 82 of file opcClient.h.

◆ opc

yarp::os::Port icubclient::OPCClient::opc
protected

Port which connects to /OPC/rpc.

Definition at line 40 of file opcClient.h.

◆ opcName

std::string icubclient::OPCClient::opcName
protected

Definition at line 73 of file opcClient.h.