Skip to content

Commit

Permalink
Add angry emotion and not fullscreem mode to ergoCubEmotions (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicogene authored Sep 2, 2024
2 parents 6b99e6a + c364c32 commit ce662e4
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 32 deletions.
48 changes: 46 additions & 2 deletions app/ergoCubEmotions/conf/config.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[general]
num_expressions 4
num_transitions 12
num_expressions 5
num_transitions 20
fullscreen true

#[expression_0]
#name neutral
Expand Down Expand Up @@ -42,6 +43,11 @@ name shy
type video
file expressions/videos/shy.mp4

[expression_4]
name angry
type video
file expressions/videos/angry.mp4

[transition_0]
source neutral
destination happy
Expand Down Expand Up @@ -102,4 +108,42 @@ source shy
destination happy
file expressions/videos/shy-happy.mp4

[transition_12]
source happy
destination angry
file expressions/videos/happy-angry.mp4

[transition_13]
source angry
destination happy
file expressions/videos/angry-happy.mp4

[transition_14]
source angry
destination neutral
file expressions/videos/angry-neutral.mp4

[transition_15]
source angry
destination alert
file expressions/videos/angry-alert.mp4

[transition_16]
source angry
destination shy
file expressions/videos/angry-shy.mp4

[transition_17]
source neutral
destination angry
file expressions/videos/neutral-angry.mp4

[transition_18]
source alert
destination angry
file expressions/videos/alert-angry.mp4

[transition_19]
source shy
destination angry
file expressions/videos/shy-angry.mp4
10 changes: 8 additions & 2 deletions src/modules/ergoCubEmotions/ergoCubEmotions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ bool ErgoCubEmotions::configure(ResourceFinder& rf)
Bottle &bGroup = rf.findGroup("general");
nExpressions = bGroup.find("num_expressions").asInt32();
nTransitions = bGroup.find("num_transitions").asInt32();
fullscreen = bGroup.find("fullscreen").asBool();

for(int i = 0; i < nExpressions; i++)
{
Expand Down Expand Up @@ -105,8 +106,13 @@ bool ErgoCubEmotions::configure(ResourceFinder& rf)
isTransition = true;
command = "neutral";

namedWindow("emotion", WND_PROP_FULLSCREEN);
setWindowProperty("emotion", WND_PROP_FULLSCREEN, WINDOW_FULLSCREEN);
if(fullscreen){
namedWindow("emotion", WND_PROP_FULLSCREEN);
setWindowProperty("emotion", WND_PROP_FULLSCREEN, WINDOW_FULLSCREEN);
}
else{
namedWindow("emotion", WINDOW_NORMAL);
}

cmdPort.open("/ergoCubEmotions/rpc");
attach(cmdPort);
Expand Down
58 changes: 30 additions & 28 deletions src/modules/ergoCubEmotions/ergoCubEmotions.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,36 @@
#include <map>
#include <unordered_map>

class ErgoCubEmotions : public yarp::os::RFModule, public ergoCubEmotions_IDL {
public:
ErgoCubEmotions();
~ErgoCubEmotions();

bool attach(yarp::os::RpcServer& source);
bool configure(yarp::os::ResourceFinder& config);
bool close();
bool updateModule();
double getPeriod();

bool setEmotion(const std::string& command);
std::vector<std::string> availableEmotions();
void showTransition(const std::string &current, const std::string &desired);

yarp::os::RpcServer cmdPort;
int nExpressions;
int nTransitions;
bool isTransition;
std::unordered_map<std::string, std::pair<std::string, std::string>> imgMap;
std::map<std::pair<std::string, std::string>, std::string> transitionMap;
std::string command;
std::string currentCommand;
std::vector<std::string> avlEmotions;
cv::Mat img;
std::mutex mutex;
std::vector<cv::VideoCapture> videoCaptures;
std::vector<std::string> videoFileNames;
class ErgoCubEmotions : public yarp::os::RFModule, public ergoCubEmotions_IDL
{
public:
ErgoCubEmotions();
~ErgoCubEmotions();

bool attach(yarp::os::RpcServer &source);
bool configure(yarp::os::ResourceFinder &config);
bool close();
bool updateModule();
double getPeriod();

bool setEmotion(const std::string &command);
std::vector<std::string> availableEmotions();
void showTransition(const std::string &current, const std::string &desired);

yarp::os::RpcServer cmdPort;
int nExpressions;
int nTransitions;
bool isTransition;
bool fullscreen;
std::unordered_map<std::string, std::pair<std::string, std::string>> imgMap;
std::map<std::pair<std::string, std::string>, std::string> transitionMap;
std::string command;
std::string currentCommand;
std::vector<std::string> avlEmotions;
cv::Mat img;
std::mutex mutex;
std::vector<cv::VideoCapture> videoCaptures;
std::vector<std::string> videoFileNames;
};

#endif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit ce662e4

Please sign in to comment.