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> 00023 #include <string> 00024 using namespace std; 00025 00026 00027 #include "vector.h" 00028 #include "matrix.h" 00029 00031 00040 class Model { 00041 protected: 00043 double ModelDeltaT; 00044 00046 list<MSLVector> Inputs; 00047 00049 MSLVector RungeKuttaIntegrate(const MSLVector &x, const MSLVector &u, const double &h); 00050 00052 MSLVector EulerIntegrate(const MSLVector &x, const MSLVector &u, const double &h); 00053 public: 00054 00056 string FilePath; 00057 00059 MSLVector LowerState; 00060 00062 MSLVector UpperState; 00063 00065 MSLVector LowerInput; 00066 00068 MSLVector UpperInput; 00069 00071 int StateDim; 00072 00074 int InputDim; 00075 00077 Model(string path); 00078 00080 virtual ~Model() {}; 00081 00083 virtual list<MSLVector> GetInputs(const MSLVector &x); 00084 00086 virtual MSLVector StateTransitionEquation(const MSLVector &x, const MSLVector &u) = 0; 00087 00089 virtual bool Satisfied(const MSLVector &x); 00090 00092 virtual MSLVector Integrate(const MSLVector &x, const MSLVector &u, 00093 const double &h) = 0; 00094 00096 00100 virtual MSLVector LinearInterpolate(const MSLVector &x1, const MSLVector &x2, 00101 const double &a); // Depends on topology 00102 00106 virtual MSLVector StateDifference(const MSLVector &x1, const MSLVector &x2); 00107 00108 // Conversions 00110 virtual MSLVector StateToConfiguration(const MSLVector &x); 00111 00113 virtual double Metric(const MSLVector &x1, const MSLVector &x2); 00114 00115 // The following are used by optimization methods. They are empty by 00116 // default because regular planners don't need them. These could later 00117 // go in a derived class for optimization problems, but are left here 00118 // so that "regular" models can be converted to optimization models 00119 // by overriding these methods. 00120 00122 virtual void Partialf_x(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00123 00125 virtual void Partialf_u(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00126 00128 virtual void L(const MSLVector &x, const MSLVector &u, double &l) {}; 00129 00131 virtual void PartialL_x(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00132 00134 virtual void PartialL_u(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00135 00137 virtual void Phi(const MSLVector &x, const MSLVector &u, 00138 const MSLVector &goalstate, double &phi) {}; 00139 00141 virtual void PartialPhi_x(const MSLVector &x, const MSLVector &u, 00142 const MSLVector &goalstate, 00143 MSLMatrix & m) {}; 00144 00146 virtual void PartialPhi_t(const MSLVector &x, const MSLVector &u, 00147 const MSLVector &goalstate, 00148 MSLMatrix & m) {}; 00149 00151 virtual void Psi(const MSLVector &x, const MSLVector &goalstate, MSLVector& psi) {}; 00152 00154 virtual void PartialPsi_x(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00155 00157 virtual void PartialPsi_t(const MSLVector &x, const MSLVector &u, MSLMatrix & m) {}; 00158 00159 }; 00160 00161 #endif