1 #include <yarp/os/all.h> 7 if(yarp::os::Network::isConnected(
portRPC.getName(),
"/icub/face/emotions/in")) {
10 return yarp::os::Network::connect(
portRPC.getName(),
"/icub/face/emotions/in");
25 std::pair<std::string, std::string> emPair;
28 std::transform(emotion.begin(), emotion.end(), emotion.begin(), ::tolower);
29 std::transform(part.begin(), part.end(), part.begin(), ::tolower);
31 if(mapToEmotion.find(emotion) != mapToEmotion.end() &&
32 mapToPart.find(part) != mapToPart.end())
34 emPair.first = mapToEmotion.find(emotion)->second;
35 emPair.second = mapToPart.find(part)->second;
37 return sendEmotion(emPair);
39 else if(mapToEmotion.find(emotion) == mapToEmotion.end())
41 yError() <<
"Emotion " << emotion <<
" not found";
44 else if(mapToPart.find(part) == mapToPart.end())
46 yError() <<
"Part " << part <<
" not found";
51 yError() <<
"Uncaught error";
56 bool icubclient::SubSystem_emotion::sendEmotion(std::pair<std::string, std::string> emPair) {
57 yarp::os::Bottle bReq, bResp;
59 bReq.addString(
"set");
60 bReq.addString(emPair.second);
61 bReq.addString(emPair.first);
63 yInfo()<<
"Sending " << bReq.toString();
66 if (bResp.toString() ==
"[ok]")
68 currentEmotionPair = emPair;
73 yError()<<bResp.toString();
80 return currentEmotionPair;
#define SUBSYSTEM_EMOTION
SubSystem_emotion(const std::string &masterName)
Default constructor.
yarp::os::RpcClient portRPC
virtual void Close()
Clean up resources.
bool setEmotion(std::string emotion, std::string part="all")
Method to switch iCub emotion for different parts of face.
Abstract class to handle sub-systems of the icub-client.
std::pair< std::string, std::string > getEmotion()
Method to get current iCub emotion.