Repository navigation
Expand file tree
/
Copy pathsketch8.js
More file actions
115 lines (57 loc) · 1.8 KB
/
Copy pathsketch8.js
File metadata and controls
115 lines (57 loc) · 1.8 KB
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
function init() {
_inputScale = width;
_cameraDist = 1700;
$('#systemCanvas').width(SCREEN_SIZE_W);
$('#mainTable').width(SCREEN_SIZE_W);
$('#sliderInertia').slider('value',_inertia);
$('#sliderFriction').slider('value',_friction);
$('#sliderResistance').slider('value',_resistance);
$('#sliderInductance').slider('value',_inductance);
$('#sliderKv').slider('value',_Kv);
$('#sliderKt').slider('value',_Kt);
$('#spanInertia').html(_inertia);
$('#spanFriction').html(_friction);
$('#spanResistance').html(_resistance);
$('#spanInductance').html(_inductance);
$('#spanKv').html(_Kv);
$('#spanKt').html(_Kt);
system = new DCMotor('systemCanvas', DT);
osciloscope = new Osciloscope('osciloscopeDiv', MAX_T, ['blue'],['magenta', 'green','red']);
system.load();
updateValues();
setTimeout(()=>{system.draw();}, 500);
_globalReferences = [_angRef];
$('#textReference').val(_globalReferences[0]);
}
function updateValues() {
_ang = system.ang;
_vel = system.vel;
_acc = system.acc;
_globalOutputs = [_ang, _vel];
}
function updateSystem() {
system.ang = _ang;
system.vel = _vel;
system.acc = _acc;
system.inertia = _inertia;
system.friction = _friction;
system.resistance = _resistance;
system.inductance = _inductance;
system.Kv = _Kv;
system.Kt = _Kt;
system.P = _P;
}
function draw() {
_angInput = _globalInput/20.0;
clear();
updateSystem();
system.draw(_cameraTeta, _cameraPhi, _cameraDist);
drawCursor();
if (_paused)
return;
_t += DT;
processInput();
system.update(_angInput, _ang, _vel, _acc, _inertia, _friction, _resistance, _inductance, _Kv, _Kt, _P);
osciloscope.update(_t, [_angInput], [_ang, 0.04*_vel, 0.004*_acc], _globalReferences);
updateValues();
}