00001 //---------------------------------------------------------------------- 00002 // The Motion Strategy Library (MSL) 00003 //---------------------------------------------------------------------- 00004 // 00005 // Copyright (c) 1998-2000 Iowa State University and Steve LaValle. 00006 // All Rights Reserved. 00007 // 00008 // Permission to use, copy, and distribute this software and its 00009 // documentation is hereby granted free of charge, provided that 00010 // (1) it is not a component of a commercial product, and 00011 // (2) this notice appears in all copies of the software and 00012 // related documentation. 00013 // 00014 // Iowa State University and the author make no representations 00015 // about the suitability or fitness of this software for any purpose. 00016 // It is provided "as is" without express or implied warranty. 00017 //---------------------------------------------------------------------- 00018 00019 #ifndef MSL_MODEL_H 00020 #define MSL_MODEL_H 00021 00022 #include <LEDA/file.h> 00023 #include <LEDA/list.h> 00024 #include <LEDA/matrix.h> 00025 #include <LEDA/point.h> 00026 #include <LEDA/polygon.h> 00027 #include <LEDA/random.h> 00028 #include <LEDA/stream.h> 00029 #include <LEDA/string.h> 00030 #include <LEDA/vector.h> 00031 00032 #include <LEDA/REDEFINE_NAMES.h> 00033 00035 00044 class Model { 00045 protected: 00047 double ModelDeltaT; 00048 00050 list<vector> Inputs; 00051 00053 void ReadInputs(); 00054 00056 void ReadLowerState(); 00057 00059 void ReadUpperState(); 00060 00062 vector RungeKuttaIntegrate(const vector &x, const vector &u, const double &h); 00063 00065 vector EulerIntegrate(const vector &x, const vector &u, const double &h); 00066 public: 00067 00069 string FilePath; 00070 00072 vector LowerState; 00073 00075 vector UpperState; 00076 00078 vector LowerInput; 00079 00081 vector UpperInput; 00082 00084 int StateDim; 00085 00087 int InputDim; 00088 00090 Model(string path); 00091 00093 virtual ~Model() {}; 00094 00096 virtual list<vector> GetInputs(const vector &x); 00097 00099 virtual vector StateTransitionEquation(const vector &x, const vector &u) = 0; 00100 00102 virtual bool Satisfied(const vector &x); 00103 00105 virtual vector Integrate(const vector &x, const vector &u, 00106 const double &h) = 0; 00107 00109 00113 virtual vector LinearInterpolate(const vector &x1, const vector &x2, 00114 const double &a); // Depends on topology 00115 00119 virtual vector StateDifference(const vector &x1, const vector &x2); 00120 00121 // Conversions 00123 virtual vector StateToConfiguration(const vector &x); 00124 00126 virtual point StateToLedaPoint(const vector &x); 00127 00129 virtual double Metric(const vector &x1, const vector &x2); 00130 00131 // The following are used by optimization methods. They are empty by 00132 // default because regular planners don't need them. These could later 00133 // go in a derived class for optimization problems, but are left here 00134 // so that "regular" models can be converted to optimization models 00135 // by overriding these methods. 00136 00138 virtual void Partialf_x(const vector &x, const vector &u, matrix & m) {}; 00139 00141 virtual void Partialf_u(const vector &x, const vector &u, matrix & m) {}; 00142 00144 virtual void L(const vector &x, const vector &u, double &l) {}; 00145 00147 virtual void PartialL_x(const vector &x, const vector &u, matrix & m) {}; 00148 00150 virtual void PartialL_u(const vector &x, const vector &u, matrix & m) {}; 00151 00153 virtual void Phi(const vector &x, const vector &u, 00154 const vector &goalstate, double &phi) {}; 00155 00157 virtual void PartialPhi_x(const vector &x, const vector &u, 00158 const vector &goalstate, 00159 matrix & m) {}; 00160 00162 virtual void PartialPhi_t(const vector &x, const vector &u, 00163 const vector &goalstate, 00164 matrix & m) {}; 00165 00167 virtual void Psi(const vector &x, const vector &goalstate, vector& psi) {}; 00168 00170 virtual void PartialPsi_x(const vector &x, const vector &u, matrix & m) {}; 00171 00173 virtual void PartialPsi_t(const vector &x, const vector &u, matrix & m) {}; 00174 00175 }; 00176 00177 #include <LEDA/UNDEFINE_NAMES.h> 00178 00179 #endif