00001 //---------------------------------------------------------------------- 00002 // The Motion Strategy Library (MSL) 00003 //---------------------------------------------------------------------- 00004 // 00005 // Copyright (c) University of Illinois and Steven M. 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 // The University of Illinois 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 <list.h> 00023 #include <string> 00024 00025 #include "vector.h" 00026 #include "matrix.h" 00027 00029 00038 class Model { 00039 protected: 00041 double ModelDeltaT; 00042 00044 list<MSLVector> Inputs; 00045 00047 MSLVector RungeKuttaIntegrate(const MSLVector &x, const MSLVector &u, const double &h); 00048 00050 MSLVector EulerIntegrate(const MSLVector &x, const MSLVector &u, const double &h); 00051 public: 00052 00054 string FilePath; 00055 00057 MSLVector LowerState; 00058 00060 MSLVector UpperState; 00061 00063 MSLVector LowerInput; 00064 00066 MSLVector UpperInput; 00067 00069 int StateDim; 00070 00072 int InputDim; 00073 00075 Model(string path); 00076 00078 virtual ~Model() {}; 00079 00081 virtual list<MSLVector> GetInputs(const MSLVector &x); 00082 00084 virtual MSLVector StateTransitionEquation(const MSLVector &x, const MSLVector &u) = 0; 00085 00087 virtual bool Satisfied(const MSLVector &x); 00088 00090 virtual MSLVector Integrate(const MSLVector &x, const MSLVector &u, 00091 const double &h) = 0; 00092 00094 00098 virtual MSLVector LinearInterpolate(const MSLVector &x1, const MSLVector &x2, 00099 const double &a); // Depends on topology 00100 00104 virtual MSLVector StateDifference(const MSLVector &x1, const MSLVector &x2); 00105 00106 // Conversions 00108 virtual MSLVector StateToConfiguration(const MSLVector &x); 00109 00111 virtual double Metric(const MSLVector &x1, const MSLVector &x2); 00112 00113 // The following are used by optimization methods. They are empty by 00114 // default because regular planners don't need them. These could later 00115 // go in a derived class for optimization problems, but are left here 00116 // so that "regular" models can be converted to optimization models 00117 // by overriding these methods. 00118 00120 virtual void Partialf_x(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00121 00123 virtual void Partialf_u(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00124 00126 virtual void L(const MSLVector &x, const MSLVector &u, double &l) {}; 00127 00129 virtual void PartialL_x(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00130 00132 virtual void PartialL_u(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00133 00135 virtual void Phi(const MSLVector &x, const MSLVector &u, 00136 const MSLVector &goalstate, double &phi) {}; 00137 00139 virtual void PartialPhi_x(const MSLVector &x, const MSLVector &u, 00140 const MSLVector &goalstate, 00141 MSLMatrix & m) {}; 00142 00144 virtual void PartialPhi_t(const MSLVector &x, const MSLVector &u, 00145 const MSLVector &goalstate, 00146 MSLMatrix & m) {}; 00147 00149 virtual void Psi(const MSLVector &x, const MSLVector &goalstate, MSLVector& psi) {}; 00150 00152 virtual void PartialPsi_x(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00153 00155 virtual void PartialPsi_t(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00156 00157 }; 00158 00159 #endif