POMDP.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef POMDP_H_DEFINED
00039 #define POMDP_H_DEFINED
00040
00041 #include "Image/OpenCVUtil.H"
00042
00043 #include "Image/Image.H"
00044 #include "Image/ImageSet.H"
00045 #include "Image/Pixels.H"
00046 #include <vector>
00047 #include <string>
00048 #include <map>
00049
00050 class POMDP
00051 {
00052 public:
00053
00054 struct StateAction
00055 {
00056 int state;
00057 int action;
00058 };
00059
00060 struct State
00061 {
00062 int x;
00063 int y;
00064 int stateID;
00065 float prob;
00066
00067 State(int in_x, int in_y) :
00068 x(in_x), y(in_y)
00069 {
00070 }
00071 };
00072
00073 enum OBJS {BACKGROUND, GOAL, AGENT, WALL, HOLE};
00074 enum ACTIONS {NORTH, SOUTH, EAST, WEST};
00075 POMDP();
00076
00077
00078 ~POMDP();
00079
00080
00081 int getAction();
00082
00083
00084 bool makeObservation(const Image<PixRGB<byte> > &img);
00085
00086 void init();
00087
00088
00089
00090 Image<float> locateObject(const Image<float>& src, Image<float>& filter);
00091 Point2D<int> findObject(const Image<PixRGB<byte> > &img, const char* filename);
00092 std::vector<Point2D<int> > findMultipleObjects(const Image<PixRGB<byte> > &img, const char* filename);
00093
00094 Point2D<int> getAgentState();
00095 Point2D<int> getGoalState();
00096
00097 Image<byte> getStateSpace();
00098 void showTransitions();
00099 float getTransProb(int state, int action, int newState);
00100
00101 int doAction(const int state, const int act);
00102 float getReward(int state);
00103 void valueIteration();
00104 ACTIONS getAction(int state);
00105
00106
00107 int getPropAction();
00108
00109 void doPolicy(const Point2D<int> &startPos);
00110
00111 Image<float> getPerception(const uint obj);
00112 Image<float> makePrediction(const ACTIONS action);
00113 float updatePerception(const Image<PixRGB<byte> > &img);
00114 void updateStateTransitions(const ACTIONS action);
00115 bool goalReached();
00116 bool isExploring() { return itsExploring;}
00117
00118 float bayesFilter(const int action, const Image<PixRGB<byte> > &img);
00119 float particleFilter(const int action, const Image<PixRGB<byte> > &img);
00120
00121 float getEntropy(Image<float> &belif);
00122
00123
00124 float getObjProb(const Image<PixRGB<byte> > &img,
00125 const State state, const int objID);
00126
00127
00128
00129
00130 private:
00131 Dims itsRetinaSize;
00132 Point2D<int> itsAgentState;
00133 Point2D<int> itsGoalState;
00134
00135 float itsLastDistance;
00136 int itsLastAction;
00137 Image<byte> itsStateSpace;
00138 ImageSet<float> itsCurrentPercep;
00139 Image<float> itsPreviousPercep;
00140 Image<float> itsPrediction;
00141 std::vector<std::vector<std::vector<float> > > itsTransitions;
00142 Image<float> itsUtility;
00143 std::map<StateAction, int> itsStateTrans;
00144 bool itsExploring;
00145 std::vector<Image<PixRGB<byte> > > itsObjects;
00146
00147 std::vector<State> itsParticleStateSpace;
00148 };
00149
00150
00151
00152
00153
00154
00155
00156 #endif