forked from CBA2011/WASABIEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmotionContainer.h
More file actions
165 lines (137 loc) · 6.36 KB
/
Copy pathEmotionContainer.h
File metadata and controls
165 lines (137 loc) · 6.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/********************************************************************************
**
** [W]ASABI [A]ffect [S]imulation [A]rchitecture for [B]elievable [I]nteractivity
**
** Copyright (C) 2011 Christian Becker-Asano.
** All rights reserved.
** Contact: Christian Becker-Asano (christian@becker-asano.de)
**
** This file is part of the WASABIEngine library.
**
** The WASABIEngine library is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** The WASABIEngine library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with the WASABIEngine library. If not, see <http://www.gnu.org/licenses/>
**
********************************************************************************/
#ifndef EmotionContainer_H
#define EmotionContainer_H
#include <iostream>
#include "AffectiveState.h"
#include "WASABIEngine_global.h"
typedef std::multimap<AffectiveState*, std::vector<AffectVertex*> > ASVectorMMap;
typedef std::multimap<std::string, std::vector<float> > AffectTypeLikelihoodsMMap;
/*!
* Container-Klasse fuer die Position, die im Dynamik-Raum erreicht werden soll.
* Hier wird die Gueltigkeit der Koordinaten verwaltet.
*/
class WASABIENGINESHARED_EXPORT EmoPos2Reach
{
public:
EmoPos2Reach ();
EmoPos2Reach(const EmoPos2Reach &emoPos);
virtual ~EmoPos2Reach ();
int getXPos2Reach();
int getYPos2Reach();
void setPositions2Reach(int xPos, int yPos);
void setXValid(bool valid);
void setYValid(bool valid);
bool getXValid();
bool getYValid();
protected:
int xPos2Reach, yPos2Reach;
bool xValid, yValid;
};
/*!
* Diese Klasse kapselt alle physikalischen Variablen des Dynamik-Raumes.
*/
class WASABIENGINESHARED_EXPORT EmotionContainer
{
friend class WASABIENGINESHARED_EXPORT cogaEmotionalAttendee;
public:
// Konstruktor
EmotionContainer ();
EmotionContainer(const EmotionContainer &emoCon);
// Destruktor
virtual ~EmotionContainer ();
//protected:
double dt; // time difference (see timer_calculate!)
//void setUID(std::string uid);
//std::string getUID();
virtual void writeTransferable(std::ostream &ostr) const;
virtual void readTransferable(std::istream&);
virtual void update(float _dt);
virtual void init();
//void update();
std::string getType() {return type;}
//* NEW: We keep a list of affective states here:
// As every EmotionalAttendee automatically generates an EmotionContainer
// we keep track of possible AffectiveStates here. These AffectiveStates might
// be realized as Primary or Secondary Emotions both of them being derived from
// AffectiveState.
// These AffectiveStates have a function "getLikelihood(std::vector<int> PAD)" returning
// the awareness likelihood as a float value. We just have to iterate this vector at every
// simulation step now, calling the "update(float dt)" functions of each AffectiveState.
std::vector<AffectiveState*> affectiveStates;
//* To read the actual MultiMap of likelihoods > 0.0
// Format: ((AffectiveState*, vector<AffectVertex*>), ..)
// We may directly access the highest likelihood using:
// > ASVectorMMap::iterator asvmmapiter = asvmmap.begin();
// > iter_asvmmap->second.at(0)->likelihood;
ASVectorMMap getAffectLikelihoods() {return asvmmap;}
//* Useful if we only now the type name
AffectiveState* getAffectiveStateByType(std::string type);
void dumpAffectiveStates(std::ostream &ostr);
//* Returns the MOOD_ID of the AffectiveState with the highest likelihood
// emotionclass might be given as either any, primary or secondary, so far.
// DEFAULT: any
int getASId(std::string emotionclass = "any");
//* Returns the type of the AffectiveState with the highest likelihood
// emotionclass might be given as either any, primary or secondary, so far.
// DEFAULT: any
std::string getASType(std::string emotionclass = "any");
//* Returns the highest likelihood of all AffectiveStates
// emotionclass might be given as either any, primary or secondary, so far.
// DEFAULT: any
float getASLikelihood(std::string emotionclass = "any");
//* Returns the bool isActive
bool isActive() {return active;}
//* Holds a simpler representation of the actual affective states together with
// the likelihoods.
// Format: ((string type, vector<float> (MOOD_ID, likelihoods), ..)
// This is needed, if the affectiveStates Vector is not neccessary and thus not present.
// We keep it up to date whenever updateAffectLikelihoods is called!
// Only this mmap is transfered in the EmotionMessage!
AffectTypeLikelihoodsMMap atlmmap;
//* To trigger an AS from the outside, i.e. the EmotionAgent.
// Returning true in case of success, false otherwise (e.g., if type not found)
bool triggerAS(std::string _type, double newLifetime = -1.0);
//* To update the MultiMap containing the likelihoods > 0.0.
// Is called automatically within update(float dt).
// NEW: by setting forcePADupdate = true we can force the EmotionContainer to call as->updateLikelihood(),
// which will use the current PAD values to calculate each AffectiveState's likelihood accordingly.
// This is used when we don't want to call "update" before calling this function.
void updateAffectLikelihoods(bool forcePADupdate = false);
protected:
//std::string _uid;
std::string type;
ASVectorMMap asvmmap;
//bool uid_protected; // should be set, if EmotionContainer belongs to an EmotionalAttendee
//* The active indicates whether we are continously updating our
// affectiveStates ourselves (active = true) by update() being called
// or if we are just parsing EmotionMessages and copy their values into
// our affectiveStates (active = false).
// DEFAULT: false, i.e. we are only listening.
bool active;
bool buildPrimaryEmotion(std::vector<float> v, std::string type, std::string decayFunc);
bool buildSecondaryEmotion(std::string secfilename);
};
#endif