costfunction.hh
Go to the documentation of this file.
1 #ifndef COSTFUNCTION_H
2 #define COSTFUNCTION_H
3 
4 #include <Eigen/Core>
5 
6 template <typename precision, int stateSize, int commandSize>
7 class CostFunction {
8  public:
9  typedef Eigen::Matrix<precision, stateSize, 1> stateVec_t; // 1 x stateSize
10  typedef Eigen::Matrix<precision, 1, stateSize>
11  stateVecTrans_t; // 1 x stateSize
12  typedef Eigen::Matrix<precision, stateSize, stateSize>
13  stateMat_t; // stateSize x stateSize
14  typedef Eigen::Matrix<precision, stateSize, stateSize>
15  stateTens_t[stateSize]; // stateSize x stateSize x stateSize
16 
17  // typedef for commandSize types
18  typedef Eigen::Matrix<precision, commandSize, 1>
19  commandVec_t; // commandSize x 1
20  typedef Eigen::Matrix<precision, 1, commandSize>
21  commandVecTrans_t; // 1 x commandSize
22  typedef Eigen::Matrix<precision, commandSize, commandSize>
23  commandMat_t; // commandSize x commandSize
24  typedef Eigen::Matrix<precision, commandSize, commandSize>
25  commandTens_t[commandSize]; // stateSize x commandSize x commandSize
26 
27  // typedef for mixed stateSize and commandSize types
28  typedef Eigen::Matrix<precision, stateSize, commandSize>
29  stateR_commandC_t; // stateSize x commandSize
30  typedef Eigen::Matrix<precision, stateSize, commandSize>
31  stateR_commandC_stateD_t[stateSize]; // stateSize x commandSize x
32  // stateSize
33  typedef Eigen::Matrix<precision, stateSize, commandSize>
34  stateR_commandC_commandD_t[commandSize]; // stateSize x commandSize x
35  // commandSize
36  typedef Eigen::Matrix<precision, commandSize, stateSize>
37  commandR_stateC_t; // commandSize x stateSize
38  typedef Eigen::Matrix<precision, commandSize, stateSize>
39  commandR_stateC_stateD_t[stateSize]; // commandSize x stateSize x
40  // stateSize
41  typedef Eigen::Matrix<precision, commandSize, stateSize>
42  commandR_stateC_commandD_t[commandSize]; // commandSize x stateSize x
43  // commandSize
44  typedef Eigen::Matrix<precision, stateSize, stateSize>
45  stateR_stateC_commandD_t[commandSize]; // stateSize x stateSize x
46  // commandSize
47  typedef Eigen::Matrix<precision, commandSize, commandSize>
48  commandR_commandC_stateD_t[stateSize]; // commandSize x commandSize x
49  // stateSize
50 
51  public:
52  private:
53  protected:
54  // attributes //
55  public:
56  private:
57  protected:
58  double dt;
59  double final_cost;
60  double running_cost;
67  // methods //
68  public:
69  virtual void computeCostAndDeriv(const stateVec_t& X, const stateVec_t& Xdes,
70  const commandVec_t& U) = 0;
71  virtual void computeFinalCostAndDeriv(const stateVec_t& X,
72  const stateVec_t& Xdes) = 0;
73 
74  private:
75  protected:
76  // accessors //
77  public:
78  double& getRunningCost() { return running_cost; }
79  double& getFinalCost() { return final_cost; }
80  stateVec_t& getlx() { return lx; }
81  stateMat_t& getlxx() { return lxx; }
82  commandVec_t& getlu() { return lu; }
83  commandMat_t& getluu() { return luu; }
84  commandR_stateC_t& getlux() { return lux; }
85  stateR_commandC_t& getlxu() { return lxu; }
86 };
87 
88 #endif // COSTFUNCTION_H
Definition: costfunction.hh:7
commandR_stateC_t & getlux()
Definition: costfunction.hh:84
stateR_commandC_t lxu
Definition: costfunction.hh:66
virtual void computeFinalCostAndDeriv(const stateVec_t &X, const stateVec_t &Xdes)=0
double running_cost
Definition: costfunction.hh:60
stateMat_t & getlxx()
Definition: costfunction.hh:81
stateVec_t & getlx()
Definition: costfunction.hh:80
Eigen::Matrix< precision, 1, commandSize > commandVecTrans_t
Definition: costfunction.hh:21
Eigen::Matrix< precision, commandSize, commandSize > commandR_commandC_stateD_t[stateSize]
Definition: costfunction.hh:48
commandR_stateC_t lux
Definition: costfunction.hh:65
commandMat_t & getluu()
Definition: costfunction.hh:83
Eigen::Matrix< precision, stateSize, commandSize > stateR_commandC_t
Definition: costfunction.hh:29
double & getFinalCost()
Definition: costfunction.hh:79
Eigen::Matrix< precision, commandSize, 1 > commandVec_t
Definition: costfunction.hh:19
double dt
Definition: costfunction.hh:58
Eigen::Matrix< precision, commandSize, stateSize > commandR_stateC_t
Definition: costfunction.hh:37
Eigen::Matrix< precision, stateSize, 1 > stateVec_t
Definition: costfunction.hh:9
stateMat_t lxx
Definition: costfunction.hh:62
Eigen::Matrix< precision, commandSize, commandSize > commandMat_t
Definition: costfunction.hh:23
virtual void computeCostAndDeriv(const stateVec_t &X, const stateVec_t &Xdes, const commandVec_t &U)=0
commandVec_t lu
Definition: costfunction.hh:63
commandVec_t & getlu()
Definition: costfunction.hh:82
Eigen::Matrix< precision, 1, stateSize > stateVecTrans_t
Definition: costfunction.hh:11
Eigen::Matrix< precision, stateSize, stateSize > stateMat_t
Definition: costfunction.hh:13
commandMat_t luu
Definition: costfunction.hh:64
stateVec_t lx
Definition: costfunction.hh:61
Eigen::Matrix< precision, commandSize, stateSize > commandR_stateC_commandD_t[commandSize]
Definition: costfunction.hh:42
stateR_commandC_t & getlxu()
Definition: costfunction.hh:85
Eigen::Matrix< precision, stateSize, stateSize > stateR_stateC_commandD_t[commandSize]
Definition: costfunction.hh:45
Eigen::Matrix< precision, stateSize, commandSize > stateR_commandC_commandD_t[commandSize]
Definition: costfunction.hh:34
Eigen::Matrix< precision, commandSize, commandSize > commandTens_t[commandSize]
Definition: costfunction.hh:25
double & getRunningCost()
Definition: costfunction.hh:78
Eigen::Matrix< precision, commandSize, stateSize > commandR_stateC_stateD_t[stateSize]
Definition: costfunction.hh:39
Eigen::Matrix< precision, stateSize, stateSize > stateTens_t[stateSize]
Definition: costfunction.hh:15
double final_cost
Definition: costfunction.hh:59
Eigen::Matrix< precision, stateSize, commandSize > stateR_commandC_stateD_t[stateSize]
Definition: costfunction.hh:31