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 #ifndef __ENVIRONMENT_H_
00030 #define __ENVIRONMENT_H_
00031
00038 class DiscreteSpaceInformation
00039 {
00040
00041 public:
00042
00048 std::vector<int*> StateID2IndexMapping;
00049
00052 FILE* fDeb;
00053
00056 virtual bool InitializeEnv(const char* sEnvFile) = 0;
00057
00060 virtual bool InitializeMDPCfg(MDPConfig *MDPCfg) = 0;
00061
00064 virtual int GetFromToHeuristic(int FromStateID, int ToStateID) = 0;
00067 virtual int GetGoalHeuristic(int stateID) = 0;
00070 virtual int GetStartHeuristic(int stateID) = 0;
00071
00077 virtual void GetSuccs(int SourceStateID, std::vector<int>* SuccIDV, std::vector<int>* CostV) = 0;
00080 virtual void GetPreds(int TargetStateID, std::vector<int>* PredIDV, std::vector<int>* CostV) = 0;
00083 virtual void SetAllActionsandAllOutcomes(CMDPSTATE* state) = 0;
00086 virtual void SetAllPreds(CMDPSTATE* state) = 0;
00087
00090 virtual int SizeofCreatedEnv() = 0;
00093 virtual void PrintState(int stateID, bool bVerbose, FILE* fOut=NULL) = 0;
00096 virtual void PrintEnv_Config(FILE* fOut) = 0;
00097
00100 virtual bool SetEnvParameter(const char* parameter, int value)
00101 {
00102 SBPL_ERROR("ERROR: Environment has no parameters that can be set via SetEnvParameter function\n");
00103 return false;
00104 }
00105
00107 virtual std::vector<int> GetExpandedStates()
00108 {
00109 SBPL_ERROR("Error: Not yet defined for any environment other than door environment.\n");
00110 std::vector<int> list;
00111 return list;
00112 }
00113
00119 virtual bool AreEquivalent(int StateID1, int StateID2){
00120 SBPL_ERROR("ERROR: environment does not support calls to AreEquivalent function\n");
00121 throw new SBPL_Exception();
00122 }
00123
00129 virtual void GetRandomSuccsatDistance(int SourceStateID, std::vector<int>* SuccIDV, std::vector<int>* CLowV)
00130 {
00131 SBPL_ERROR("ERROR: environment does not support calls to GetRandomSuccsatDistance function\n");
00132 throw new SBPL_Exception();
00133 }
00136 virtual void GetRandomPredsatDistance(int TargetStateID, std::vector<int>* PredIDV, std::vector<int>* CLowV)
00137 {
00138 SBPL_ERROR("ERROR: environment does not support calls to GetRandomPredsatDistance function\n");
00139 throw new SBPL_Exception();
00140 };
00141
00142
00145 virtual void EnsureHeuristicsUpdated(bool bGoalHeuristics)
00146 {
00147
00148
00149
00150
00151
00152 };
00153
00156 virtual ~DiscreteSpaceInformation(){
00157 SBPL_PRINTF("destroying discretespaceinformation\n");
00158 for(unsigned int i = 0; i < StateID2IndexMapping.size(); ++i){
00159 if(StateID2IndexMapping[i] != NULL)
00160 delete[] StateID2IndexMapping[i];
00161 }
00162 SBPL_FCLOSE(fDeb);
00163 }
00164
00165
00168 DiscreteSpaceInformation()
00169 {
00170
00171 #ifndef ROS
00172 const char* envdebug = "envdebug.txt";
00173 #endif
00174 if((fDeb = SBPL_FOPEN(envdebug, "w")) == NULL)
00175 {
00176 SBPL_ERROR("ERROR: failed to open debug file for environment\n");
00177 throw new SBPL_Exception();
00178 }
00179
00180 }
00181 };
00182
00183
00184
00185 #endif
00186