Reset the websocket when the server disconnects.
Also run clang-format over all the code. Mainly fixes spacing and line
breaks.
Change-Id: Icec138c3a0cf012b344cfc312deaf891a63474c0
diff --git a/y2019/vision/server/www/robot.ts b/y2019/vision/server/www/robot.ts
index 489112c..6329fb3 100644
--- a/y2019/vision/server/www/robot.ts
+++ b/y2019/vision/server/www/robot.ts
@@ -1,22 +1,28 @@
-import {IN_TO_M, FT_TO_M} from './constants';
import {CAMERA_POSES} from './camera_constants';
+import {FT_TO_M, IN_TO_M} from './constants';
const ROBOT_WIDTH = 25 * IN_TO_M;
const ROBOT_LENGTH = 31 * IN_TO_M;
const CAMERA_SCALE = 0.3;
-function drawCamera(ctx : canvasRenderingContext2d, pose : {x : number, y : number, theta : number}) : void {
+function drawCamera(
+ ctx: CanvasRenderingContext2D,
+ pose: {x: number, y: number, theta: number}): void {
ctx.beginPath();
ctx.moveTo(pose.x, pose.y);
- ctx.lineTo(pose.x + CAMERA_SCALE * Math.cos(pose.theta + Math.PI / 4.0),
- pose.y + CAMERA_SCALE * Math.sin(pose.theta + Math.PI / 4.0));
- ctx.lineTo(pose.x + CAMERA_SCALE * Math.cos(pose.theta - Math.PI / 4.0),
- pose.y + CAMERA_SCALE * Math.sin(pose.theta - Math.PI / 4.0));
+ ctx.lineTo(
+ pose.x + CAMERA_SCALE * Math.cos(pose.theta + Math.PI / 4.0),
+ pose.y + CAMERA_SCALE * Math.sin(pose.theta + Math.PI / 4.0));
+ ctx.lineTo(
+ pose.x + CAMERA_SCALE * Math.cos(pose.theta - Math.PI / 4.0),
+ pose.y + CAMERA_SCALE * Math.sin(pose.theta - Math.PI / 4.0));
ctx.closePath();
ctx.stroke();
}
-export function drawRobot(ctx : CanvasRenderingContext2D, x : number, y : number, theta : number, camera_colors : string[]) : void {
+export function drawRobot(
+ ctx: CanvasRenderingContext2D, x: number, y: number, theta: number,
+ camera_colors: string[]): void {
ctx.save();
ctx.translate(x, y);
ctx.rotate(theta);
@@ -26,9 +32,9 @@
ctx.beginPath();
ctx.strokeStyle = 'black';
- ctx.moveTo(ROBOT_LENGTH / 2, -ROBOT_WIDTH/2);
+ ctx.moveTo(ROBOT_LENGTH / 2, -ROBOT_WIDTH / 2);
ctx.lineTo(ROBOT_LENGTH / 2 + 0.1, 0);
- ctx.lineTo(ROBOT_LENGTH / 2, ROBOT_WIDTH/2);
+ ctx.lineTo(ROBOT_LENGTH / 2, ROBOT_WIDTH / 2);
ctx.closePath();
ctx.stroke();
ctx.lineWidth = 3.0 * ctx.lineWidth;