Skip to content

Commit

Permalink
stop
Browse files Browse the repository at this point in the history
  • Loading branch information
mayarajan3 committed Nov 21, 2024
1 parent 2301de1 commit 1d68981
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions extensions/src/doodlebot/LineFollowing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit 1d68981

Please sign in to comment.