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 #ifndef __UTILS_H_
00030 #define __UTILS_H_
00031
00032 #ifndef WIN32
00033 #define __max(x,y) (x>y?x:y)
00034 #define __min(x,y) (x>y?y:x)
00035 #endif
00036
00037
00038 #define NORMALIZEDISCTHETA(THETA, THETADIRS) (((THETA>=0)?((THETA)%(THETADIRS)):(((THETA)%(THETADIRS)+THETADIRS)%THETADIRS)))
00039
00040 #define CONTXY2DISC(X, CELLSIZE) (((X)>=0)?((int)((X)/(CELLSIZE))):((int)((X)/(CELLSIZE))-1))
00041 #define DISCXY2CONT(X, CELLSIZE) ((X)*(CELLSIZE) + (CELLSIZE)/2.0)
00042
00043
00044 #define PI_CONST 3.141592653589793238462643383279502884
00045
00046 #define UNKNOWN_COST 1000000
00047
00048 typedef struct {
00049 int X1, Y1;
00050 int X2, Y2;
00051 int Increment;
00052 int UsingYIndex;
00053 int DeltaX, DeltaY;
00054 int DTerm;
00055 int IncrE, IncrNE;
00056 int XIndex, YIndex;
00057 int Flipped;
00058 } bresenham_param_t;
00059
00060
00061 typedef struct {
00062 int x;
00063 int y;
00064 } sbpl_2Dcell_t;
00065
00066
00067 typedef struct {
00068 double x;
00069 double y;
00070 } sbpl_2Dpt_t;
00071
00072 typedef struct BINARYHIDDENVARIABLE
00073 {
00074 int h_ID;
00075 unsigned char Prob;
00076
00077 }sbpl_BinaryHiddenVar_t;
00078
00079 typedef struct BELIEFSTATEWITHBINARYHVALS
00080 {
00081 int s_ID;
00082 vector<sbpl_BinaryHiddenVar_t> updatedhvaluesV;
00083
00084
00085 }sbpl_BeliefStatewithBinaryh_t;
00086
00087 typedef struct POLICYBELIEFSTATEWITHBINARYHVALS
00088 {
00089
00090 sbpl_BeliefStatewithBinaryh_t BeliefState;
00091
00092 int nextpolicyactionID;
00093 vector<int> outcomestateIndexV;
00094
00095 }sbpl_PolicyStatewithBinaryh_t;
00096
00097
00098
00099
00100
00101 #if MEM_CHECK == 1
00102 void DisableMemCheck();
00103 void EnableMemCheck();
00104 #endif
00105 void CheckMDP(CMDP* mdp);
00106 void PrintMatrix(int** matrix, int rows, int cols, FILE* fOut);
00107 void EvaluatePolicy(CMDP* PolicyMDP, int StartStateID, int GoalStateID,
00108 double* PolValue, bool *bFullPolicy, double *Pcgoal,
00109 int* nMerges, bool *bCycles);
00110 int ComputeNumofStochasticActions(CMDP* pMDP);
00111
00115 void get_bresenham_parameters(int p1x, int p1y, int p2x, int p2y, bresenham_param_t *params);
00119 void get_current_point(bresenham_param_t *params, int *x, int *y);
00123 int get_next_point(bresenham_param_t *params);
00124
00128 double DiscTheta2Cont(int nTheta, int NUMOFANGLEVALS);
00132 int ContTheta2Disc(double fTheta, int NUMOFANGLEVALS);
00133
00138 double normalizeAngle(double angle);
00139
00142 double computeMinUnsignedAngleDiff(double angle1, double angle2);
00143
00146 bool IsInsideFootprint(sbpl_2Dpt_t pt, vector<sbpl_2Dpt_t>* bounding_polygon);
00147
00150 void computeDistancestoNonfreeAreas(unsigned char** Grid2D, int width_x, int height_y, unsigned char obsthresh, float** disttoObs_incells,
00151 float** disttoNonfree_incells);
00152
00153
00154 #if 0
00155 void CheckSearchMDP(CMDP* mdp, int ExcludeSuccStateID = -1);
00156 void CheckSearchPredSucc(CMDPSTATE* state, int ExcludeSuccStateID = -1);
00157 #endif
00158
00159 #endif