This repository was archived by the owner on Nov 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +34
-2
lines changed Expand file tree Collapse file tree 4 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 109
109
< button type ="button " id ="debugBackBtn "> ⏮</ button >
110
110
< button type ="button " id ="debugPauseBtn "> ⏯</ button >
111
111
< button type ="button " id ="debugForwardBtn "> ⏭</ button >
112
- < input type ="range " value ="0 " min ="0 " max ="100 " step ="0. 1 " oninput ="this.nextElementSibling.value = this.value " id ="timeSlider ">
112
+ < input type ="range " value ="0 " min ="0 " max ="100 " step ="1 " oninput ="this.nextElementSibling.value = this.value " id ="timeSlider ">
113
113
< output class ="text " id ="timeSliderVal "> 0</ output >
114
114
115
115
</ div >
Original file line number Diff line number Diff line change @@ -460,7 +460,7 @@ uploadDebugBtn.onchange = function() {
460
460
// leftVel, rightVel
461
461
//
462
462
// loop to get debug data
463
- for ( i ++ ; i < lines . length ; i ++ ) {
463
+ for ( i ++ ; i < lines . length - 1 ; i ++ ) {
464
464
const line = lines [ i ] . split ( ', ' ) ;
465
465
const timestamp = parseFloat ( line [ 0 ] ) ;
466
466
const rbtX = parseFloat ( line [ 1 ] ) ;
@@ -541,6 +541,9 @@ rewindBtn.onclick = function() {
541
541
pauseBtn . onclick = function ( ) {
542
542
debugRun = ! debugRun ;
543
543
if ( debugRun == true ) {
544
+ if ( debugDataTime == debugDataList . length - 1 ) {
545
+ debugDataTime = 0 ;
546
+ }
544
547
clearInterval ( intervalId ) ;
545
548
intervalId = setInterval ( render , 10 ) ;
546
549
} else {
@@ -557,3 +560,15 @@ forwardBtn.onclick = function() {
557
560
debugDataTime ++ ;
558
561
}
559
562
} ;
563
+
564
+
565
+ /**
566
+ * @brief debug time slider changed
567
+ */
568
+ debugTimeSlider . oninput = function ( ) {
569
+ debugDataTime = this . value ;
570
+ if ( debugSet == true ) {
571
+ renderField ( ) ;
572
+ renderDebug ( ) ;
573
+ }
574
+ } ;
Original file line number Diff line number Diff line change @@ -159,6 +159,10 @@ function renderCreate() {
159
159
* @brief render for debug mode
160
160
*/
161
161
function renderDebug ( ) {
162
+ // get debug data time
163
+ debugTimeSlider . max = debugDataList . length - 1 ;
164
+ const debugTime = debugTimeSlider . value ;
165
+
162
166
// render the path
163
167
for ( let i = 0 ; i < debugPath . length ; i ++ ) {
164
168
const p1 = coordToPx ( debugPath [ i ] ) ;
@@ -214,6 +218,15 @@ function renderDebug() {
214
218
ctx . lineTo ( headingVecPx . x , headingVecPx . y ) ;
215
219
ctx . stroke ( ) ;
216
220
ctx . closePath ( ) ;
221
+
222
+ // update the time
223
+ if ( debugDataTime < debugDataList . length - 1 ) {
224
+ debugDataTime ++ ;
225
+ } else {
226
+ debugRun = false ;
227
+ clearInterval ( intervalId ) ;
228
+ }
229
+ debugTimeSlider . value = debugDataTime ;
217
230
} ;
218
231
219
232
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ const rDSlider = document.getElementById('rD');
26
26
const rBSlider = document . getElementById ( 'rB' ) ;
27
27
const rGSlider = document . getElementById ( 'rG' ) ;
28
28
29
+ const debugTimeSlider = document . getElementById ( 'timeSlider' ) ;
30
+
29
31
// slider values
30
32
const lookaheadVal = document . getElementById ( 'lookaheadVal' ) ;
31
33
const decelVal = document . getElementById ( 'decelVal' ) ;
@@ -54,6 +56,8 @@ const rDVal = document.getElementById('rDVal');
54
56
const rBVal = document . getElementById ( 'rBVal' ) ;
55
57
const rGVal = document . getElementById ( 'rGVal' ) ;
56
58
59
+ const debugTimeVal = document . getElementById ( 'timeSliderVal' ) ;
60
+
57
61
58
62
// buttons
59
63
const downloadRobotBtn = document . getElementById ( 'downloadRobotBtn' ) ;
You can’t perform that action at this time.
0 commit comments