-
Notifications
You must be signed in to change notification settings - Fork 3
/
iLQG_problem.tem
91 lines (73 loc) · 2.67 KB
/
iLQG_problem.tem
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<<gentran(literal("\/\* File generated form template iLQG_problem.tem on ", eval(timedate()), ". Do not edit! \*\/", cr, cr))>>
#ifndef ILQG_PROBLEM_H
#define ILQG_PROBLEM_H
#include <math.h>
#include "mex.h"
#ifndef HAVE_OCTAVE
#include "matrix.h"
#endif
#define isNANorINF(v) (mxIsNaN(v) || mxIsInf(v))
#define INF mxGetInf()
// #define isNANorINF(v) (isnan(v) || !finite(v))
// #define INF HUGE_VAL
#define N_X <<gentran(eval(nx))$>>
#define N_U <<gentran(eval(nu))$>>
#define sizeofQxx <<gentran(eval((nx*(nx+1))/2))$>>
#define sizeofQuu <<gentran(eval((nu*(nu+1))/2))$>>
#define sizeofQxu <<gentran(eval(nx*nu))$>>
typedef struct {
double x[N_X];
double u[N_U];
double lower[N_U];
double upper[N_U];
double lower_sign[N_U];
double upper_sign[N_U];
double lower_hx[N_X*N_U];
double upper_hx[N_X*N_U];
double l[N_U];
double L[N_U*N_X];
double c;
double cx[N_X];
double cxx[sizeofQxx];
double cu[N_U];
double cuu[sizeofQuu];
double cxu[sizeofQxu];
double fx[N_X*N_X];
double fu[N_X*N_U];
#if FULL_DDP
double fxx[N_X*sizeofQxx];
double fuu[N_X*sizeofQuu];
double fxu[N_X*sizeofQxu];
#endif
<<block([a], for a in aux_def do if get(a[1], used_by_running) then gentran(literal(" double ", eval(a[1]), "\;", cr)))>>
<<block([a], for a in aux_deriv do if get(a[1], used_by_running) then gentran(literal(" double ", eval(a[1]), "\;", cr)))>>
} trajEl_t;
typedef struct {
double x[N_X];
double c;
double cx[N_X];
double cxx[sizeofQxx];
<<block([a], for a in aux_def do if get(a[1], used_by_final) then gentran(literal(" double ", eval(a[1]), "\;", cr)))>>
<<block([a], for a in aux_deriv do if get(a[1], used_by_final) then gentran(literal(" double ", eval(a[1]), "\;", cr)))>>
} trajFin_t;
typedef struct {
trajEl_t* t;
trajFin_t f;
} traj_t;
typedef struct {
<<if n_hle#0 then gentran(literal(" double mu_le[", eval(n_hle), "]\;", cr))>>
<<if n_hle#0 then gentran(literal(" double last_hle[", eval(n_hle), "]\;", cr))>>
<<if n_hli#0 then gentran(literal(" double mu_li[", eval(n_hli), "]\;", cr))>>
<<if n_hli#0 then gentran(literal(" double last_hli[", eval(n_hli), "]\;", cr))>>
} multipliersEl_t;
typedef struct {
<<if n_hfe#0 then gentran(literal(" double mu_fe[", eval(n_hfe), "]\;", cr))>>
<<if n_hfe#0 then gentran(literal(" double last_hfe[", eval(n_hfe), "]\;", cr))>>
<<if n_hfi#0 then gentran(literal(" double mu_fi[", eval(n_hfi), "]\;", cr))>>
<<if n_hfi#0 then gentran(literal(" double last_hfi[", eval(n_hfi), "]\;", cr))>>
} multipliersFin_t;
typedef struct {
multipliersEl_t* t;
multipliersFin_t f;
} multipliers_t;
#endif // ILQG_PROBLEM_H