-
Notifications
You must be signed in to change notification settings - Fork 0
/
quadratic_regression.pde
106 lines (95 loc) · 2.23 KB
/
quadratic_regression.pde
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// scaling parameters
float max_value = PI;//0.02;
float jrkm = 0.00;//1;
float accm = 0.01;
float velm = 0.1;
float posm = 1.00;
float diffm = 50.0; // per phase//velm*10;//
// data set parameters
int num_references = 0;
int[] viewport = {0, 1000};
float dt = 0.000200;
int inspection_point = 0;
boolean use_measurement = false;
int cnt = 0;
//model parameters
float p0 = 0;
float v0 = 0;
float a0 = 0;//200;
float j0 = 0;
float s0 = 0;
float c0 = 0;
//float tt = 0.2;
//float pt = 1.5*PI/2;//PI;//PI/2;//
//float vt = 14;
//float at = 0;
float target[][] = {{0.025, 0.125, 1.0},
{0.0, PI/4, PI/4},
{0.0, 0.0, 0.0},
{0.0, 0.0, 0.0}
};
// noise parameters
float lsb = 1.0 * PI / pow(2, 14); // lsb of 14 bit rotary encoder
float an = 0;
float vn = 0;
float pn = 4.0 * lsb;
// filter parameters
float am = 0.1;
float vm = 0.1;
float pm = 1.0;
int average_samples = 32;
// regression parameters
boolean use_cubic_regression = true;
float cubic_multiplier = 2;
int regression_samples = 64;
int direction = 0;
float regression_window;
void setup() {
size(1680, 1050, P2D);
frameRate(24);
background(0);
pixelDensity(displayDensity());
compute_once();
//noLoop();
println(nf(dt, 0, 6) + ", " + regression_samples + ", " + nf(regression_window, 0, 3));
}
void draw() {
background(0);
compute_samples();
viewport[1] = (int)(target[0][1]/dt);
set_viewport(viewport);
draw_coordinate_system();
draw_graphs();
if(roll_inspection_point) {
inspection_point++;
} else {
if(mouse_inspection_point) {
inspection_point = (int)(mouseX / xwidth);
}
}
//cnt++;
//dt += 0.000001;
regression_samples = (int)(round(regression_window / dt));
if(cnt > frameRate) {
cnt = 0;
println(nf(dt, 0, 6) + ", " + regression_samples + ", " + nf(regression_window, 0, 3));
}
}
void keyPressed() {
roll_inspection_point = false;
mouse_inspection_point = false;
if(key == ' ') {
roll_inspection_point = true;
}
if(keyCode == LEFT) {
inspection_point--;
}
if(keyCode == RIGHT) {
inspection_point++;
}
}
void mousePressed() {
roll_inspection_point = false;
mouse_inspection_point = true;
inspection_point = (int)(mouseX / xwidth);
}