00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef POTENTIALFIELDCOMPOSITION_H_
00010 #define POTENTIALFIELDCOMPOSITION_H_
00011
00012
00013 #include "PfieldConfig.h"
00014 #include "PfieldDatatypes.h"
00015 #include <vector>
00016 #include <string>
00017 #include <list>
00018 #include <map>
00019
00020 class PotentialFieldsObject;
00021 class Parser;
00022 class Potentialfield;
00023
00024
00025
00026 enum SelectionProcedure {BEST_OF_N, SUCCESSIVE_N_TIMES};
00027
00028
00029 typedef std::map<std::string, unsigned int> NameToIndexMap;
00030
00031
00032
00033
00034
00035
00036
00037 class PotentialfieldResult
00038 {
00039 public:
00040
00041 double value;
00042
00043 std::string action;
00044
00045 std::string subAction;
00046
00047 PfPose motion;
00048
00049 bool actionPossible;
00050
00051 unsigned int fieldNumber;
00052
00053 unsigned long timeStamp;
00054
00055
00056
00057
00058 void operator = (const PotentialfieldResult& other)
00059 {
00060 value = other.value;
00061 action = other.action;
00062 subAction = other.subAction;
00063 motion = other.motion;
00064 actionPossible = other.actionPossible;
00065 fieldNumber = other.fieldNumber;
00066 timeStamp = other.timeStamp;
00067 }
00068 };
00069
00070
00071
00072
00073
00074
00075
00076 class ObjectStateDescription
00077 {
00078 public:
00079
00080 std::string objectName;
00081
00082 int objectId;
00083
00084 PfPose pose;
00085
00086 bool isActive;
00087
00088
00089 ObjectStateDescription()
00090 {}
00091
00092
00093
00094
00095 void operator = (const ObjectStateDescription& other)
00096 {
00097 objectName = other.objectName;
00098 objectId = other.objectId;
00099 pose = other.pose;
00100 isActive = other.isActive;
00101 }
00102
00103
00104
00105
00106 ObjectStateDescription(const ObjectStateDescription& other)
00107 {
00108 objectName = other.objectName;
00109 objectId = other.objectId;
00110 pose = other.pose;
00111 isActive = other.isActive;
00112 }
00113 };
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 class PotentialfieldComposition
00124 {
00125 public:
00126
00127 PotentialfieldComposition();
00128
00129
00130 ~PotentialfieldComposition();
00131
00132
00133
00134
00135 void load(const std::string& filename);
00136
00137
00138 void close();
00139
00140
00141
00142
00143 void execute(PotentialfieldResult& result);
00144
00145
00146
00147
00148 void setName(const std::string& name)
00149 { this->name = name;}
00150
00151
00152
00153
00154 std::string getName() const
00155 { return name;}
00156
00157
00158
00159
00160 void setObjectState(ObjectStateDescription& desc);
00161
00162
00163
00164
00165 void setOwnPose(const PfPose& pose);
00166
00167
00168
00169
00170 void addField(Potentialfield* field);
00171
00172
00173
00174
00175 void addObject(PotentialFieldsObject* object);
00176
00177
00178
00179
00180 void addDynamicObjectState(const std::string& objectName);
00181
00182
00183
00184
00185
00186 unsigned int getIdFromObjectStateSymbol(const std::string& objectName);
00187
00188
00189
00190
00191
00192 ObjectStateDescription getDescriptionFromId(unsigned int objectId);
00193
00194
00195
00196
00197 std::vector<std::string> getFieldNames();
00198
00199
00200
00201
00202
00203 void setFieldSelectionParameters(SelectionProcedure selectionProcedure,
00204 unsigned int n)
00205 { this->selectionProcedure = selectionProcedure; this->n = n;}
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218 void getValueArray(const std::string& fieldname, double x1, double y1,
00219 double x2, double y2, int xSteps, int ySteps, double value[], double& max);
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 void getDirectionArray(const std::string& fieldname, double x1, double y1,
00232 double x2, double y2, int xSteps, int ySteps, PfVec directions[]);
00233
00234
00235
00236
00237
00238 void setFieldActivation(const std::string& fieldname, bool activation);
00239
00240
00241 friend class Parser;
00242
00243 private:
00244
00245 std::string name;
00246
00247 std::vector<PotentialFieldsObject*> objects;
00248
00249 NameToIndexMap objectMap;
00250
00251 std::vector<ObjectStateDescription> dynamicObjectStates;
00252
00253 NameToIndexMap objectStateMap;
00254
00255 std::vector<Potentialfield*> fields;
00256
00257 NameToIndexMap fieldMap;
00258
00259 std::vector<PotentialfieldResult> results;
00260
00261 std::list<PotentialfieldResult> resultList;
00262
00263 PotentialfieldResult lastResult;
00264
00265 PfPose ownPose;
00266
00267 Parser* parser;
00268
00269 bool fileLoaded;
00270
00271 SelectionProcedure selectionProcedure;
00272
00273 unsigned int n;
00274
00275
00276
00277
00278 PotentialfieldResult selectNextResult();
00279
00280
00281
00282
00283 void addResultToList(const PotentialfieldResult& result);
00284
00285
00286 void updateDynamicObjects();
00287
00288
00289
00290
00291
00292 unsigned int getFieldIndexFromName(const std::string& fieldname);
00293 };
00294
00295
00296 #endif //POTENTIALFIELDCOMPOSITION_H_