@@ -323,41 +323,35 @@ function renderGraphs() {
323
323
// draw the left motor actual velocity graph
324
324
leftMotorCtx . strokeStyle = 'red' ;
325
325
for ( let i = 0 ; i <= debugDataTime ; i ++ ) {
326
- leftMotorCtx . beginPath ( ) ;
327
- // get the x and y coordinates
328
- let x0 = 20 ;
329
- let y0 = 75 ;
330
326
if ( i > 0 ) {
327
+ leftMotorCtx . beginPath ( ) ;
331
328
x0 = 20 + ( ( i - 1 ) / ( debugDataList . length - 1 ) ) * 260 ;
332
329
y0 = 75 - ( debugDataList [ i - 1 ] . leftVel / debugData . maxVel ) * 55 ;
330
+ const x1 = 20 + ( i / ( debugDataList . length - 1 ) ) * 260 ;
331
+ const y1 = 75 - ( debugDataList [ i ] . leftVel / debugData . maxVel ) * 55 ;
332
+ leftMotorCtx . moveTo ( x0 , y0 ) ;
333
+ leftMotorCtx . lineTo ( x1 , y1 ) ;
334
+ // draw the line
335
+ leftMotorCtx . stroke ( ) ;
336
+ leftMotorCtx . closePath ( ) ;
333
337
}
334
- const x1 = 20 + ( i / ( debugDataList . length - 1 ) ) * 260 ;
335
- const y1 = 75 - ( debugDataList [ i ] . leftVel / debugData . maxVel ) * 55 ;
336
- leftMotorCtx . moveTo ( x0 , y0 ) ;
337
- leftMotorCtx . lineTo ( x1 , y1 ) ;
338
- // draw the line
339
- leftMotorCtx . stroke ( ) ;
340
- leftMotorCtx . closePath ( ) ;
341
338
}
342
339
343
340
// draw the left motor target velocity graph
344
341
leftMotorCtx . strokeStyle = 'blue' ;
345
342
for ( let i = 0 ; i <= debugDataTime ; i ++ ) {
346
- leftMotorCtx . beginPath ( ) ;
347
- // get the x and y coordinates
348
- let x0 = 20 ;
349
- let y0 = 75 ;
350
343
if ( i > 0 ) {
344
+ leftMotorCtx . beginPath ( ) ;
351
345
x0 = 20 + ( ( i - 1 ) / ( debugDataList . length - 1 ) ) * 260 ;
352
346
y0 = 75 - ( debugDataList [ i - 1 ] . leftTargetVel / debugData . maxVel ) * 55 ;
347
+ const x1 = 20 + ( i / ( debugDataList . length - 1 ) ) * 260 ;
348
+ const y1 = 75 - ( debugDataList [ i ] . leftTargetVel / debugData . maxVel ) * 55 ;
349
+ leftMotorCtx . moveTo ( x0 , y0 ) ;
350
+ leftMotorCtx . lineTo ( x1 , y1 ) ;
351
+ // draw the line
352
+ leftMotorCtx . stroke ( ) ;
353
+ leftMotorCtx . closePath ( ) ;
353
354
}
354
- const x1 = 20 + ( i / ( debugDataList . length - 1 ) ) * 260 ;
355
- const y1 = 75 - ( debugDataList [ i ] . leftTargetVel / debugData . maxVel ) * 55 ;
356
- leftMotorCtx . moveTo ( x0 , y0 ) ;
357
- leftMotorCtx . lineTo ( x1 , y1 ) ;
358
- // draw the line
359
- leftMotorCtx . stroke ( ) ;
360
- leftMotorCtx . closePath ( ) ;
361
355
}
362
356
363
357
// reset right motor canvas
0 commit comments