@@ -402,7 +402,19 @@ async function main() {
402402
403403 const sim_container = document . getElementById ( "sim-container" )
404404 proxy_controller = new ProxyController ( new Policy ( model ) )
405- const l2f = new L2F ( sim_container , 10 , proxy_controller , seed )
405+
406+
407+ const platforms_text = await ( await fetch ( "./blob/registry/index.json" ) ) . text ( )
408+ const platforms = platforms_text . split ( "\n" ) . filter ( line => line . trim ( ) !== "" ) . sort ( )
409+ const platform_select = document . getElementById ( "vehicle-load-dynamics-selector" )
410+ platforms . forEach ( platform => {
411+ platform_select . innerHTML += `<option value="${ platform } ">${ platform } </option>`
412+ } )
413+ platform_select . value = "x500"
414+
415+ const default_parameters = await ( await fetch ( `./blob/registry/${ platform_select . value } .json` ) ) . json ( )
416+
417+ const l2f = new L2F ( sim_container , Array ( 10 ) . fill ( default_parameters ) , proxy_controller , seed )
406418
407419 l2f . state_update_callbacks . push ( ( states ) => {
408420 const vehicle_container = document . getElementById ( "vehicle-list" )
@@ -445,8 +457,27 @@ async function main() {
445457
446458 } )
447459
460+ l2f . initialized . then ( async ( ) => {
461+ await parameter_manager . initialized
462+ const sim_container_cover = document . getElementById ( "sim-container-cover" )
463+ sim_container_cover . style . display = "none"
464+ const pause_button = document . getElementById ( "pause" )
465+ if ( pause_button . innerText === "Resume" ) {
466+ pause_button . click ( )
467+ }
468+
469+ const perturbation_id_input = document . getElementById ( "perturbation-id-input" )
470+ perturbation_id_input . value = "parameters.dynamics.mass"
471+ perturbation_id_input . dispatchEvent ( new Event ( "input" ) )
472+ const event = new Event ( 'keydown' )
473+ event . key = "Enter"
474+ perturbation_id_input . dispatchEvent ( event )
475+ } )
476+
477+
478+
448479 const parameter_manager = new ParameterManager ( l2f )
449- const sim_controls = new SimControls ( l2f , proxy_controller , parameter_manager )
480+ const sim_controls = new SimControls ( l2f , proxy_controller )
450481
451482
452483 const set_parameters = async ( parameters ) => {
@@ -461,9 +492,7 @@ async function main() {
461492 } )
462493 console . log ( "setting parameters for vehicles: " , ids )
463494 console . log ( "parameters: " , parameters )
464- parameter_manager . set_parameters ( ids , ids . map ( ( ) => parameters ) )
465- await l2f . initialized
466- await l2f . ui . episode_init_multi ( l2f . ui_state , l2f . parameters )
495+ await l2f . set_parameters ( ids , ids . map ( ( ) => parameters ) )
467496 }
468497 document . getElementById ( "vehicle-load-dynamics-btn-backend" ) . addEventListener ( "change" , async ( ) => {
469498 const file = event . target . files [ 0 ] ;
@@ -484,44 +513,9 @@ async function main() {
484513 }
485514 else {
486515 const platform = document . getElementById ( "vehicle-load-dynamics-selector" ) . value
487- fetch ( `./blob/registry/${ platform } .json` ) . then ( async ( response ) => {
488- const parameters = await response . json ( )
489- set_parameters ( parameters )
490- } )
491- }
492- } )
493- fetch ( "./blob/registry/index.json" ) . then ( async ( response ) => {
494- const text = await response . text ( )
495- const platforms = text . split ( "\n" ) . filter ( line => line . trim ( ) !== "" ) . sort ( )
496- const platform_select = document . getElementById ( "vehicle-load-dynamics-selector" )
497- platforms . forEach ( platform => {
498- platform_select . innerHTML += `<option value="${ platform } ">${ platform } </option>`
499- } )
500-
501- await l2f . initialized
502- await sleep ( 500 )
503- const selectAllBtn = document . getElementById ( "vehicle-select-all-btn" )
504- selectAllBtn . click ( )
505-
506- const dynamicsSelector = document . getElementById ( "vehicle-load-dynamics-selector" )
507- dynamicsSelector . value = "x500"
508- const parameters_response = await fetch ( `./blob/registry/${ dynamicsSelector . value } .json` )
509- const parameters = await parameters_response . json ( )
510- await set_parameters ( parameters )
511-
512- const sim_container_cover = document . getElementById ( "sim-container-cover" )
513- sim_container_cover . style . display = "none"
514- const pause_button = document . getElementById ( "pause" )
515- if ( pause_button . innerText === "Resume" ) {
516- pause_button . click ( )
516+ const parameters = await ( await fetch ( `./blob/registry/${ platform } .json` ) ) . json ( )
517+ set_parameters ( parameters )
517518 }
518-
519- const perturbation_id_input = document . getElementById ( "perturbation-id-input" )
520- perturbation_id_input . value = "parameters.dynamics.mass"
521- perturbation_id_input . dispatchEvent ( new Event ( "input" ) )
522- const event = new Event ( 'keydown' )
523- event . key = "Enter"
524- perturbation_id_input . dispatchEvent ( event )
525519 } )
526520
527521
0 commit comments