GCOP
1.0
|
00001 #ifndef GCOP_LSSENSORCOST_H 00002 #define GCOP_LSSENSORCOST_H 00003 00004 #include <Eigen/Dense> 00005 #include <iostream> 00006 #include "system.h" 00007 #include "manifold.h" 00008 #include "sensorcost.h" 00009 00010 namespace gcop { 00011 00012 using namespace Eigen; 00013 using namespace std; 00014 00031 template <typename T = VectorXd, 00032 int _nx = Dynamic, 00033 int _nu = Dynamic, 00034 int _np = Dynamic, 00035 int _ng = Dynamic, 00036 typename Tz = VectorXd, 00037 int _nz = Dynamic> class LsSensorCost : public SensorCost<T, _nx, _nu, _np, Tz, _nz> { 00038 00039 public: 00040 00041 typedef Matrix<double, _ng, 1> Vectorgd; 00042 typedef Matrix<double, _ng, _nx> Matrixgxd; 00043 typedef Matrix<double, _ng, _nu> Matrixgud; 00044 typedef Matrix<double, _ng, _np> Matrixgpd; 00045 typedef Matrix<double, _ng, _nz> Matrixgzd; 00046 00047 typedef Matrix<double, _nx, 1> Vectornd; 00048 typedef Matrix<double, _nu, 1> Vectorcd; 00049 typedef Matrix<double, _np, 1> Vectormd; 00050 00051 typedef Matrix<double, _nx, _nx> Matrixnd; 00052 typedef Matrix<double, _nx, _nu> Matrixncd; 00053 typedef Matrix<double, _nu, _nx> Matrixcnd; 00054 typedef Matrix<double, _nu, _nu> Matrixcd; 00055 00056 // typedef Matrix<double, Dynamic, 1> Vectormd; 00057 typedef Matrix<double, _np, _np> Matrixmd; 00058 typedef Matrix<double, _nx, _np> Matrixnmd; 00059 typedef Matrix<double, _np, _nx> Matrixmnd; 00060 00061 typedef Matrix<double, _nz, 1> Vectorrd; 00062 typedef Matrix<double, _nz, _nz> Matrixrd; 00063 typedef Matrix<double, _nz, _nx> Matrixrnd; 00064 typedef Matrix<double, _nz, _nu> Matrixrcd; 00065 typedef Matrix<double, _nz, _np> Matrixrmd; 00066 00073 LsSensorCost(System<T, _nx, _nu, _np> &sys, Manifold<Tz, _nz> &Z, int ng = 0); 00074 00087 virtual bool Res(Vectorgd &g, 00088 double t, const Tz &z, 00089 const Vectornd &w, const Vectormd &p, double h, 00090 Matrixgxd *dgdw = 0, Matrixgpd *dgdp = 0, 00091 Matrixgzd *dgdz = 0); 00092 00100 virtual bool Resp(Vectormd &gp, 00101 const Vectormd &p, 00102 Matrixmd *dgdp = 0); 00103 00104 int ng; 00105 Vectorgd g; 00106 Vectormd gp; 00107 }; 00108 00109 template <typename T, int _nx, int _nu, int _np, int _ng, typename Tz, int _nz> 00110 LsSensorCost<T, _nx, _nu, _np, _ng, Tz, _nz>::LsSensorCost(System<T, _nx, _nu, _np> &sys, Manifold<Tz, _nz> &Z, int ng) : 00111 SensorCost<T, _nx, _nu, _np, Tz, _nz>(sys, Z), ng(_ng != Dynamic ? _ng : ng) 00112 { 00113 assert(ng > 0); 00114 if (_ng == Dynamic) 00115 g.resize(ng); 00116 const int np = sys.P.n; 00117 if(_np == Dynamic) 00118 gp.resize(np); 00119 } 00120 00121 template <typename T, int _nx, int _nu, int _np, int _ng, typename Tz, int _nz> 00122 bool LsSensorCost<T, _nx, _nu, _np, _ng, Tz, _nz>::Res(Vectorgd &g, 00123 double t, const Tz &z, 00124 const Vectornd &w, const Vectormd &p, double h, 00125 Matrixgxd *dgdw, Matrixgpd *dgdp, 00126 Matrixgzd *dgdz) { 00127 cout << "[W] LsSensorCost:Res: unimplemented! Subclasses should override." << endl; 00128 return false; 00129 } 00130 00131 template <typename T, int _nx, int _nu, int _np, int _ng, typename Tz, int _nz> 00132 bool LsSensorCost<T, _nx, _nu, _np, _ng, Tz, _nz>::Resp(Vectormd &g, 00133 const Vectormd &p, 00134 Matrixmd *dgdp) 00135 { 00136 cout << "[W] LsSensorCost:Resp: unimplemented! Subclasses should override." << endl; 00137 return false; 00138 } 00139 } 00140 00141 #endif 00142