@@ -53,19 +53,19 @@ function WebGUI() {
5353
5454 if ( dataToDraw . dynamicWindow ) {
5555 setDynamicWindow (
56- dataToDraw . dynamicWindow . map ( ( i : any ) => [ i [ 0 ] , i [ 1 ] , i [ 2 ] ] )
56+ dataToDraw . dynamicWindow . map ( ( i : any ) => [ i [ 0 ] , i [ 1 ] , i [ 2 ] ] ) ,
5757 ) ;
5858 }
5959
6060 if ( dataToDraw . pose && dataToDraw . target ) {
6161 const targetDist = Math . sqrt (
6262 Math . pow ( dataToDraw . pose [ 0 ] - dataToDraw . target [ 0 ] , 2 ) +
63- Math . pow ( dataToDraw . pose [ 1 ] - dataToDraw . target [ 1 ] , 2 )
63+ Math . pow ( dataToDraw . pose [ 1 ] - dataToDraw . target [ 1 ] , 2 ) ,
6464 ) ;
6565
6666 const targetAng = Math . atan2 (
6767 dataToDraw . pose [ 1 ] - dataToDraw . target [ 1 ] ,
68- dataToDraw . pose [ 0 ] - dataToDraw . target [ 0 ]
68+ dataToDraw . pose [ 0 ] - dataToDraw . target [ 0 ] ,
6969 ) ;
7070
7171 setTargetPose ( [
@@ -78,10 +78,13 @@ function WebGUI() {
7878 const stateCallback = ( state : string ) => {
7979 if ( state === states . TOOLS_READY ) {
8080 setTargetPose ( undefined ) ;
81+ setCurrentV ( 0 ) ;
82+ setCurrentW ( 0 ) ;
83+ setDynamicWindow ( [ ] ) ;
8184 }
8285 } ;
8386
84- connectApplication ( manager , updateCallback ) ;
87+ connectApplication ( manager , updateCallback , stateCallback ) ;
8588
8689 // =========================================================
8790 // ===================== WINDOW SCENE ======================
@@ -174,7 +177,7 @@ function WebGUI() {
174177 y2 = { 140 - VIEW_MARGIN }
175178 stroke = { w === 0 ? "#444" : "#ddd" }
176179 strokeWidth = { w === 0 ? 1.5 : 0.5 }
177- />
180+ /> ,
178181 ) ;
179182 }
180183
@@ -190,15 +193,27 @@ function WebGUI() {
190193 y2 = { y }
191194 stroke = { v === 0 ? "#444" : "#ddd" }
192195 strokeWidth = { v === 0 ? 1.5 : 0.5 }
193- />
196+ /> ,
194197 ) ;
195198 }
196199
197200 return lines ;
198201 } ) ( ) }
199202
200- < line x1 = { 130 } y1 = { VIEW_MARGIN } x2 = { 130 } y2 = { 140 - VIEW_MARGIN } stroke = "#444" />
201- < line x1 = { VIEW_MARGIN } y1 = { 70 } x2 = { 280 - VIEW_MARGIN } y2 = { 70 } stroke = "#444" />
203+ < line
204+ x1 = { 130 }
205+ y1 = { VIEW_MARGIN }
206+ x2 = { 130 }
207+ y2 = { 140 - VIEW_MARGIN }
208+ stroke = "#444"
209+ />
210+ < line
211+ x1 = { VIEW_MARGIN }
212+ y1 = { 70 }
213+ x2 = { 280 - VIEW_MARGIN }
214+ y2 = { 70 }
215+ stroke = "#444"
216+ />
202217
203218 < circle
204219 cx = { 130 - ( currentW / WMAX ) * ( 130 - VIEW_MARGIN ) }
@@ -275,16 +290,16 @@ function WebGUI() {
275290 const wContainer = HEAT_SIZE ;
276291 const hContainer = HEAT_SIZE / 2 ;
277292
278- const vValues = dynamicWindow . map ( d => d [ 0 ] ) ;
279- const wValues = dynamicWindow . map ( d => d [ 1 ] ) ;
293+ const vValues = dynamicWindow . map ( ( d ) => d [ 0 ] ) ;
294+ const wValues = dynamicWindow . map ( ( d ) => d [ 1 ] ) ;
280295
281296 const minV = Math . min ( ...vValues ) ;
282297 const maxV = Math . max ( ...vValues ) ;
283298 const minW = Math . min ( ...wValues ) ;
284299 const maxW = Math . max ( ...wValues ) ;
285300
286- const safeW = ( maxW - minW ) || 1 ;
287- const safeV = ( maxV - minV ) || 1 ;
301+ const safeW = maxW - minW || 1 ;
302+ const safeV = maxV - minV || 1 ;
288303
289304 return dynamicWindow . map ( ( [ v , w , score ] , i ) => {
290305 const x =
@@ -311,45 +326,45 @@ function WebGUI() {
311326 } ) ;
312327 } ) ( ) }
313328
314- { /* Mejor velocidad */ }
315- { currentV !== undefined &&
316- currentW !== undefined &&
317- dynamicWindow . length > 0 &&
318- ( ( ) => {
319- const wContainer = HEAT_SIZE ;
320- const hContainer = HEAT_SIZE / 2 ;
321-
322- const vValues = dynamicWindow . map ( d => d [ 0 ] ) ;
323- const wValues = dynamicWindow . map ( d => d [ 1 ] ) ;
324-
325- const minV = Math . min ( ...vValues ) ;
326- const maxV = Math . max ( ...vValues ) ;
327- const minW = Math . min ( ...wValues ) ;
328- const maxW = Math . max ( ...wValues ) ;
329-
330- const safeW = ( maxW - minW ) || 1 ;
331- const safeV = ( maxV - minV ) || 1 ;
329+ { /* Mejor velocidad */ }
330+ { currentV !== undefined &&
331+ currentW !== undefined &&
332+ dynamicWindow . length > 0 &&
333+ ( ( ) => {
334+ const wContainer = HEAT_SIZE ;
335+ const hContainer = HEAT_SIZE / 2 ;
332336
333- const x =
334- HEAT_MARGIN +
335- ( ( maxW - currentW ) / safeW ) * ( wContainer - 2 * HEAT_MARGIN ) ;
337+ const vValues = dynamicWindow . map ( ( d ) => d [ 0 ] ) ;
338+ const wValues = dynamicWindow . map ( ( d ) => d [ 1 ] ) ;
336339
337- const y =
338- hContainer -
339- HEAT_MARGIN -
340- ( ( currentV - minV ) / safeV ) * ( hContainer - 2 * HEAT_MARGIN ) ;
340+ const minV = Math . min ( ... vValues ) ;
341+ const maxV = Math . max ( ... vValues ) ;
342+ const minW = Math . min ( ... wValues ) ;
343+ const maxW = Math . max ( ... wValues ) ;
341344
342- return (
343- < circle
344- cx = { x }
345- cy = { y }
346- r = { 8 }
347- fill = "none"
348- stroke = "black"
349- strokeWidth = { 2 }
350- />
351- ) ;
352- } ) ( ) }
345+ const safeW = maxW - minW || 1 ;
346+ const safeV = maxV - minV || 1 ;
347+
348+ const x =
349+ HEAT_MARGIN +
350+ ( ( maxW - currentW ) / safeW ) * ( wContainer - 2 * HEAT_MARGIN ) ;
351+
352+ const y =
353+ hContainer -
354+ HEAT_MARGIN -
355+ ( ( currentV - minV ) / safeV ) * ( hContainer - 2 * HEAT_MARGIN ) ;
356+
357+ return (
358+ < circle
359+ cx = { x }
360+ cy = { y }
361+ r = { 8 }
362+ fill = "none"
363+ stroke = "black"
364+ strokeWidth = { 2 }
365+ />
366+ ) ;
367+ } ) ( ) }
353368 </ svg >
354369 </ div >
355370 </ div >
@@ -362,4 +377,4 @@ function WebGUI() {
362377 ) ;
363378}
364379
365- export default WebGUI ;
380+ export default WebGUI ;
0 commit comments