Skip to content
This repository was archived by the owner on Nov 20, 2023. It is now read-only.

Commit bb9235a

Browse files
committed
started work on debug mode
1 parent 773252a commit bb9235a

File tree

3 files changed

+98
-3
lines changed

3 files changed

+98
-3
lines changed

scripts/events.js

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,49 @@ uploadDebugBtn.onchange = function() {
440440
data = reader.result;
441441
// split the data into lines
442442
const lines = data.split('\n');
443-
// get path points
443+
444+
// loop to get path points
445+
let i = 0;
446+
while (lines[i] != 'debug') {
447+
i++;
448+
const line = lines[i].split(', ');
449+
const x = parseFloat(line[0]);
450+
const y = parseFloat(line[1]);
451+
const velocity = parseFloat(line[2]);
452+
const p = new Point(x, y);
453+
p.velocity = velocity;
454+
debugPath.push(p);
455+
}
456+
457+
458+
/*
459+
* Debug Data Format
460+
* timestamp, rbtX, rbtY, rbtH, closestX, closestY, lookaheadX, lookaheadY,
461+
* curvature, targetVel, leftTargetVel, rightTargetVel,
462+
* leftVel, rightVel
463+
*/
464+
// loop to get debug data
465+
for (i++; i < lines.length; i++) {
466+
const line = lines[i].split(', ');
467+
const timestamp = parseFloat(line[0]);
468+
const rbtX = parseFloat(line[1]);
469+
const rbtY = parseFloat(line[2]);
470+
const rbtH = parseFloat(line[3]);
471+
const closestX = parseFloat(line[4]);
472+
const closestY = parseFloat(line[5]);
473+
const lookaheadX = parseFloat(line[6]);
474+
const lookaheadY = parseFloat(line[7]);
475+
const curvature = parseFloat(line[8]);
476+
const targetVel = parseFloat(line[9]);
477+
const leftTargetVel = parseFloat(line[10]);
478+
const rightTargetVel = parseFloat(line[11]);
479+
const leftVel = parseFloat(line[12]);
480+
const rightVel = parseFloat(line[13]);
481+
const debugData = new DebugData(timestamp, rbtX, rbtY, rbtH, closestX,
482+
closestY, lookaheadX, lookaheadY, curvature, targetVel,
483+
leftTargetVel, rightTargetVel, leftVel, rightVel);
484+
debugDataList.push(debugData);
485+
}
444486
};
445487
};
446488

@@ -449,5 +491,16 @@ uploadDebugBtn.onchange = function() {
449491
* @brief mode button clicked
450492
*/
451493
modeBtn.onclick = function() {
452-
494+
const cols = document.getElementsByClassName('sliderContainer');
495+
if (cols[0].style.display === 'none') {
496+
mode = 0;
497+
for (i = 0; i < cols.length; i++) {
498+
cols[i].style.display = 'flex';
499+
}
500+
} else {
501+
mode = 1;
502+
for (i = 0; i < cols.length; i++) {
503+
cols[i].style.display = 'none';
504+
}
505+
}
453506
};

scripts/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const path = new Path(); // robot path
22
let debugPath = [];
33

44

5-
// program mode.
5+
// program mode
66
// 0 = create
77
// 1 = debug
88
let mode = 0;

scripts/spline.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,45 @@ class Path {
253253
this.genSpacedPoints(spacing);
254254
};
255255
};
256+
257+
258+
/**
259+
* @brief debugDataPoint class
260+
*/
261+
class debugDataPoint {
262+
/**
263+
* @brief constructor for debugDataPoint
264+
* @param {number} timestamp - the timestamp of the data point
265+
* @param {number} rbtX - the x position of the robot
266+
* @param {number} rbtY - the y position of the robot
267+
* @param {number} rbtH - the heading of the robot
268+
* @param {number} closestX - the x position of the closest point
269+
* @param {number} closestY - the y position of the closest point
270+
* @param {number} lookaheadX - the x position of the lookahead point
271+
* @param {number} lookaheadY - the y position of the lookahead point
272+
* @param {number} curvature - the curvature of the robot
273+
* @param {number} targetVel - the target velocity of the robot
274+
* @param {number} leftTargetVel - the target velocity of the left wheel
275+
* @param {number} rightTargetVel - the target velocity of the right wheel
276+
* @param {number} leftVel - the velocity of the left wheel
277+
* @param {number} rightVel - the velocity of the right wheel
278+
*/
279+
constructor(timestamp, rbtX, rbtY, rbtH, closestX, closestY, lookaheadX,
280+
lookaheadY, curvature, targetVel, leftTargetVel, rightTargetVel,
281+
leftVel, rightVel) {
282+
this.timestamp = timestamp();
283+
this.rbtX = rbtX;
284+
this.rbtY = rbtY;
285+
this.rbtH = rbtH;
286+
this.closestX = closestX;
287+
this.closestY = closestY;
288+
this.lookaheadX = lookaheadX;
289+
this.lookaheadY = lookaheadY;
290+
this.curvature = curvature;
291+
this.targetVel = targetVel;
292+
this.leftTargetVel = leftTargetVel;
293+
this.rightTargetVel = rightTargetVel;
294+
this.leftVel = leftVel;
295+
this.rightVel = rightVel;
296+
};
297+
};

0 commit comments

Comments
 (0)