-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathilqr_diffdrive.h
59 lines (50 loc) · 1.74 KB
/
ilqr_diffdrive.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "ilqr.h"
// Set dimensions
const int X_DIM = 3;
const int U_DIM = 2;
const int DIM = 2;
struct Obstacle {
// spherical obstacle
Vector<DIM> pos;
double radius;
int dim;
};
struct DiffDriveEnv {
// obstacles
std::vector<Obstacle> obstacles;
double obstacleFactor;
double scaleFactor;
// robot
double robotRadius;
double rotCost;
// other attributes
SymmetricMatrix<X_DIM> Q;
Vector<X_DIM> xGoal, xStart;
SymmetricMatrix<U_DIM> R;
Vector<U_DIM> uNominal;
Vector<DIM> bottomLeft, topRight;
double dt;
int ell;
double obstacleCost(const Vector<X_DIM>& x);
void quadratizeObstacleCost(const Vector<X_DIM>& x, SymmetricMatrix<X_DIM>& Q, Vector<X_DIM>& q);
// Continuous-time dynamics \dot{x} = f(x, u)
Vector<X_DIM> f(const Vector<X_DIM>& x, const Vector<U_DIM>& u);
void regularize(SymmetricMatrix<DIM>& Q);
};
// local cost function c_t(x_t, u_t)
double ct(void* env, const Vector<X_DIM>& x, const Vector<U_DIM>& u, const int& t);
void quadratizeCost(void* env,
const Vector<X_DIM>& x,
const Vector<U_DIM>& u,
const int& t,
Matrix<U_DIM,X_DIM>& Pt,
SymmetricMatrix<X_DIM>& Qt,
SymmetricMatrix<U_DIM>& Rt,
Vector<X_DIM>& qt,
Vector<U_DIM>& rt,
const int& iter);
// final cost function
double cell(void* env, const Vector<X_DIM>& x);
void quadratizeFinalCost(void* env, const Vector<X_DIM>& x, SymmetricMatrix<X_DIM>& Qell, Vector<X_DIM>& qell, const int& iter);
// Discrete-time dynamics x_{t+1} = g(x_t, u_t)
Vector<X_DIM> g(void* env, const Vector<X_DIM>& x, const Vector<U_DIM>& u);