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 #ifdef WIN32 00023 #include <list> 00024 #include <string> 00025 using namespace std; 00026 #else 00027 #include <list.h> 00028 #include <string> 00029 #endif 00030 00031 #include "vector.h" 00032 #include "matrix.h" 00033 00035 00043 00044 class Model { 00045 protected: 00047 double ModelDeltaT; 00048 00050 list<MSLVector> Inputs; 00051 00053 MSLVector RungeKuttaIntegrate(const MSLVector &x, const MSLVector &u, const double &h); 00054 00056 MSLVector EulerIntegrate(const MSLVector &x, const MSLVector &u, const double &h); 00057 public: 00058 00060 string FilePath; 00061 00063 MSLVector LowerState; 00064 00066 MSLVector UpperState; 00067 00069 MSLVector LowerInput; 00070 00072 MSLVector UpperInput; 00073 00075 int StateDim; 00076 00078 int InputDim; 00079 00081 Model(string path); 00082 00084 virtual ~Model() {}; 00085 00087 virtual list<MSLVector> GetInputs(const MSLVector &x); 00088 00090 virtual MSLVector StateTransitionEquation(const MSLVector &x, const MSLVector &u) = 0; 00091 00093 virtual bool Satisfied(const MSLVector &x); 00094 00096 virtual MSLVector Integrate(const MSLVector &x, const MSLVector &u, 00097 const double &h) = 0; 00098 00100 00104 virtual MSLVector LinearInterpolate(const MSLVector &x1, const MSLVector &x2, 00105 const double &a); // Depends on topology 00106 00110 virtual MSLVector StateDifference(const MSLVector &x1, const MSLVector &x2); 00111 00112 // Conversions 00114 virtual MSLVector StateToConfiguration(const MSLVector &x); 00115 00117 virtual double Metric(const MSLVector &x1, const MSLVector &x2); 00118 00119 // The following are used by optimization methods. They are empty by 00120 // default because regular planners don't need them. These could later 00121 // go in a derived class for optimization problems, but are left here 00122 // so that "regular" models can be converted to optimization models 00123 // by overriding these methods. 00124 00126 virtual void Partialf_x(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00127 00129 virtual void Partialf_u(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00130 00132 virtual void L(const MSLVector &x, const MSLVector &u, double &l) {}; 00133 00135 virtual void PartialL_x(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00136 00138 virtual void PartialL_u(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00139 00141 virtual void Phi(const MSLVector &x, const MSLVector &u, 00142 const MSLVector &goalstate, double &phi) {}; 00143 00145 virtual void PartialPhi_x(const MSLVector &x, const MSLVector &u, 00146 const MSLVector &goalstate, 00147 MSLMatrix & m) {}; 00148 00150 virtual void PartialPhi_t(const MSLVector &x, const MSLVector &u, 00151 const MSLVector &goalstate, 00152 MSLMatrix & m) {}; 00153 00155 virtual void Psi(const MSLVector &x, const MSLVector &goalstate, MSLVector& psi) {}; 00156 00158 virtual void PartialPsi_x(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00159 00161 virtual void PartialPsi_t(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00162 00163 }; 00164 00165 #endif