Add time-since-last-target to server
And draw little cameras on the robot that turn green when we got a
target from that camera in the last 0.25sec.
Change-Id: Icd6107163fd3f5145fcba69ac6ebb2700f602f8d
diff --git a/y2019/vision/server/www/main.ts b/y2019/vision/server/www/main.ts
index 17b7139..a9a57bd 100644
--- a/y2019/vision/server/www/main.ts
+++ b/y2019/vision/server/www/main.ts
@@ -16,6 +16,7 @@
private targetX = 0;
private targetY = 0;
private targetTheta = 0;
+ private cameraColors = ['red', 'red', 'red', 'red', 'red'];
constructor() {
const canvas = <HTMLCanvasElement>document.getElementById('field');
@@ -37,6 +38,13 @@
this.targetY = j.target.y;
this.targetTheta = j.target.theta;
}
+ for (let ii of [0, 1, 2, 3, 4]) {
+ if (j.last_target_age[ii] > 0.25) {
+ this.cameraColors[ii] = 'red';
+ } else {
+ this.cameraColors[ii] = 'green';
+ }
+ }
});
socket.addEventListener('message', (event) => {
reader.readAsText(event.data);
@@ -63,7 +71,7 @@
this.reset(ctx);
drawField(ctx);
- drawRobot(ctx, this.x, this.y, this.theta);
+ drawRobot(ctx, this.x, this.y, this.theta, this.cameraColors);
ctx.save();
ctx.lineWidth = 2.0 * ctx.lineWidth;
if (this.targetLocked) {