-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabout.html
More file actions
202 lines (177 loc) · 9.87 KB
/
Copy pathabout.html
File metadata and controls
202 lines (177 loc) · 9.87 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" type="image/png" href="/favicon/favicon-96x96.png" sizes="96x96" />
<link rel="icon" type="image/svg+xml" href="/favicon/favicon.svg" />
<link rel="shortcut icon" href="/favicon/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png" />
<meta name="apple-mobile-web-app-title" content="PID vs MPC" />
<link rel="manifest" href="/favicon/site.webmanifest" />
<title>PID vs MPC Control | About</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style>
body {
background: black;
color: white;
font-family: monospace;
max-width: 800px;
margin: 0 auto;
padding: 20px;
font-size: 18px;
line-height: 1.6;
}
nav {
display: flex;
justify-content: space-between;
}
a {
color: gray;
text-decoration: none;
border-bottom: 1px dashed gray;
}
h1, h2 {
color: white;
margin-top: 40px;
border-bottom: 1px solid white;
}
.fun-gif {
display: block;
width: 100%;
height: auto;
margin: 20px 0;
border: 1px solid white;
}
@media (min-width: 768px) {
.fun-gif {
width: 40%;
}
}
footer {
margin-top: 60px;
padding-top: 20px;
border-top: 1px dashed gray;
text-align: center;
}
.github-link {
display: inline-flex;
align-items: center;
gap: 10px;
color: gray;
text-decoration: none;
font-size: 1em;
transition: color 0.2s;
border-bottom: none; /* prevents the global 'a' tag dashed border from showing up under the icon */
}
.github-link:hover {
color: #00ff00;
}
.github-link svg {
width: 24px;
height: 24px;
fill: currentColor;
}
</style>
</head>
<body>
<nav>
<a href="index.html">← Back to Simulation</a>
<a href="mech.html">History of Mechatronics →</a>
</nav>
<main>
<h1>SYSTEM_DOCS_V2.0</h1>
<section>
<h2>01. PROJECT_OVERVIEW</h2>
<!-- <img src="/gifs/smart1.webm" class="fun-gif" alt="smart gif"> -->
<video autoplay loop muted playsinline src="/gifs/smart1.webm" class="fun-gif" alt="smart gif"></video>
<p><strong>The Challenge:</strong> "Classical" control (PID) and "Modern" control (MPC) are fundamentally different philosophies. One reacts to the past; the other predicts the future. Seeing the difference in real-time is rare.</p>
<p><strong>The Solution:</strong> I engineered a comparative physics simulation. It allows users to switch between a standard <span style="color: cyan">PID Controller</span> and a <span style="color: #00ff00">Model Predictive Controller (MPC)</span> to visualize how they handle <span style="color: yellow">stochastic disturbances</span> and <span style="color: cyan">orbital gravity</span> differently.</p>
</section>
<section>
<h2>02. SOFTWARE_ARCHITECTURE</h2>
<!-- <img src="/gifs/frustration1.gif" class="fun-gif" alt="frustration gif"> -->
<video autoplay loop muted playsinline src="/gifs/frustration1.webm" class="fun-gif" alt="frustration gif"></video>
<p>The system now runs two distinct control engines derived from first principles:</p>
<ul>
<li><strong>PID Engine:</strong> A reactive loop using error-based feedback ($K_p$, $K_i$, $K_d$) featuring integral anti-windup to handle steady-state drift, and a low-pass filter (exponential moving average) to smooth out derivative noise on the telemetry graphs.</li>
<li><strong>MPC Engine:</strong> A predictive solver that looks $N$ seconds into the future. It calculates the exact force vector required to zero out velocity and position, utilizing <strong>Feedforward Cancellation</strong> to mathematically negate external wind/gravity forces before they affect the drone.</li>
<li><strong>Performance:</strong> Both algorithms run within the 60FPS render budget of the Three.js loop.</li>
</ul>
</section>
<section>
<h2>03. INFRASTRUCTURE_&_IOT</h2>
<!-- <img src="/gifs/lain1.gif" class="fun-gif" alt="computer gif"> -->
<video autoplay loop muted playsinline src="/gifs/lain1.webm" class="fun-gif" alt="computer gif"></video>
<p>Unlike standard cloud hosting, this project is a <strong>self-hosted hybrid system</strong> running entirely on hardware in my home lab.</p>
<ul>
<li><strong>Host:</strong> Raspberry Pi 4B (Linux/Debian).</li>
<li><strong>Network:</strong> Exposed securely to the public internet via a Tailscale Funnel (Reverse Proxy).</li>
<li><strong>Data Pipeline:</strong> A custom Python service polls a DHT22 sensor via GPIO pins and writes asynchronous telemetry data to the frontend.</li>
</ul>
</section>
<section>
<h2>04. LIVE_TELEMETRY</h2>
<!-- <img src="/gifs/science1.gif" class="fun-gif" alt="science gif"> -->
<video autoplay loop muted playsinline src="/gifs/science1.webm" class="fun-gif" alt="science gif"></video>
<div class="callout">
<strong>SERVER_STATUS:</strong> ONLINE<br>
<strong>LOCATION:</strong> HOME_LAB // VANCOUVER<br>
--------------------------------<br>
LAB_TEMP: <span id="lab-temp" style="color: cyan;">--</span>°C<br>
LAB_HUM: <span id="lab-hum" style="color: cyan;">--</span>%<br>
CPU_LOAD: <span id="lab-cpu" style="color: cyan;">--</span>%<br>
RAM_LOAD: <span id="lab-ram" style="color: cyan;">--</span>%
</div>
<p style="font-size: 0.8em; color: gray;">* Server vitals polled every 5s. Simulation power usage (Watts) calculated real-time in client.</p>
</section>
<section>
<h2>05. LEARNING_OUTCOMES</h2>
<!-- <img src="/gifs/writing1.gif" class="fun-gif" alt="writing gif"> -->
<video autoplay loop muted playsinline src="/gifs/writing1.webm" class="fun-gif" alt="writing gif"></video>
<p>Implementing the "Duel" revealed key engineering trade-offs:</p>
<ul>
<li><strong>Efficiency vs. Complexity:</strong> PID is computationally cheap but struggles with "sag" under gravity. MPC is expensive but offers perfect tracking via feedforward physics.</li>
<li><strong>Systems Integration:</strong> Managed the complexity of switching control laws dynamically without destabilizing the physics engine.</li>
<li><strong>Full Stack:</strong> Bridged the gap between hardware sensors (Python), 3D graphics (Three.js), and real-time control logic.</li>
</ul>
</section>
<section>
<h2>06. ASSET_CREDITS</h2>
<p><small>
"<a href="https://skfb.ly/pxRGB" target="_blank" style="color: #00ff00;">Hatsune Miku Plushie</a>" by revsworks is licensed under
<a href="http://creativecommons.org/licenses/by/4.0/" target="_blank" style="color: #00ff00;">Creative Commons Attribution</a>.
</small></p>
<p><small>
"<a href="https://skfb.ly/pzJqp" target="_blank" style="color: #00ff00;">Poteto</a>" by indoingard is licensed under
<a href="http://creativecommons.org/licenses/by/4.0/" target="_blank" style="color: #00ff00;">Creative Commons Attribution</a>.
</small></p>
</section>
<footer>
<a href="https://github.com/lofilobzik/website" target="_blank" class="github-link">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/>
</svg>
<span>view source</span>
</a>
</footer>
</main>
<script>
async function updateSensorData() {
try {
// We add '?t=' + Date.now() to prevent the browser from caching old data
const response = await fetch('sensor.json?t=' + Date.now());
const data = await response.json();
document.getElementById('lab-temp').innerText = data.temp;
document.getElementById('lab-hum').innerText = data.hum;
document.getElementById('lab-cpu').innerText = data.cpu;
document.getElementById('lab-ram').innerText = data.ram;
} catch (error) {
console.log("Sensor offline");
}
}
// Run immediately, then every 5 seconds
updateSensorData();
setInterval(updateSensorData, 5000);
</script>
</body>
</html>