From 1d6898159ab951aada4423cbd09301583d69e1bf Mon Sep 17 00:00:00 2001 From: ymayarajan3 Date: Thu, 21 Nov 2024 17:58:30 -0500 Subject: [PATCH] stop --- extensions/src/doodlebot/LineFollowing.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/extensions/src/doodlebot/LineFollowing.ts b/extensions/src/doodlebot/LineFollowing.ts index 36a4aadd9..17d3a74d8 100644 --- a/extensions/src/doodlebot/LineFollowing.ts +++ b/extensions/src/doodlebot/LineFollowing.ts @@ -11,6 +11,7 @@ const bezierSamples = 2; const controlLength = .01; const lookahead = .07; const start = 0.04; +const spin = 10; const imageDimensions = [640, 480]; const horizontalFOV = 53.4; @@ -488,6 +489,26 @@ export function followLine(previousLine: Point[], pixels: Point[], next: Point[] return true; }); + if (line.length == 0) { + let angle: number; + if (previousCommands[0].radius == 2) { + if (previousCommands[0].angle > 0) { + angle = previousCommands[0].angle + spin; + } else { + angle = previousCommands[0].angle - spin; + } + } else { + if (previousCommands[0].angle < 0) { + angle = spin; + } else { + angle = -1 * spin; + } + } + const motorCommands = { radius: 2, angle: angle, distance: 0 } + const bezierPoints = []; + return { motorCommands, bezierPoints, line }; + } + // Create the spline const xs = line.map((point: Point) => point[0]); const ys = line.map((point: Point) => point[1]);