diff --git a/examples/main.js b/examples/main.js index 98b2b13..199f7ad 100644 --- a/examples/main.js +++ b/examples/main.js @@ -459,7 +459,7 @@ export class MuJoCoDemo { switch (this.params.scene) { case 'humanoid.xml': - modelPath = 'models/humanoid_stand_6_frams_noise_1e-4/model.json'; + modelPath = 'models/humanoid_stand_4_frams_noise_1e-4/model.json'; this.getObservation = () => this.getObservationSkeleton(0, 10, 6); break; case 'blank': @@ -544,10 +544,13 @@ export class MuJoCoDemo { const [actorMean, logStd, criticValue] = prediction; - console.log('Actor Mean:', actorMean.arraySync()); - console.log('Log Std:', logStd.arraySync()); - console.log('Critic Value:', criticValue.arraySync()); - + // console.log('Actor Mean:', actorMean.arraySync()); + // console.log('Log Std:', logStd.arraySync()); + // console.log('Critic Value:', criticValue.arraySync()); + + // Update the critic value in the GUI + this.params.criticValue = criticValue.dataSync()[0]; + // Use tf.tidy to automatically dispose of intermediate tensors tf.tidy(() => { const stdDev = tf.exp(logStd); diff --git a/examples/mujocoUtils.js b/examples/mujocoUtils.js index 0094365..30d7e94 100644 --- a/examples/mujocoUtils.js +++ b/examples/mujocoUtils.js @@ -191,36 +191,14 @@ export function setupGUI(parentContext) { dropdown.__onChange = onChangeFunc; } - // function updateSceneDropdown(dropdown, scenes) { - // // Remove all options from the underlying select element - // if (dropdown.__select && dropdown.__select.options) { - // dropdown.__select.options.length = 0; - // } - // console.log("scenes", scenes) - - // // Update the dropdown's __select property - // dropdown.__select = document.createElement('select'); - - // // Add new options - // for (let [name, file] of Object.entries(scenes)) { - // let option = document.createElement('option'); - // option.text = name; - // option.value = file; - // dropdown.__select.add(option); - // } - - // // Update the controller's object and property - // dropdown.object = scenes; - // dropdown.property = 'scene'; - - // // Rebuild the DOM elements - // dropdown.domElement.removeChild(dropdown.domElement.childNodes[0]); - // dropdown.domElement.appendChild(dropdown.__select); - - // // Update the display - // dropdown.updateDisplay(); - // dropdown.onChange(reload); - // } + + // Add a folder for critic values + let criticFolder = parentContext.gui.addFolder("Critic Values"); + + // Add a display for critic values + parentContext.params.criticValue = 0; + let criticValueDisplay = criticFolder.add(parentContext.params, 'criticValue').name('Critic Value').listen(); + criticValueDisplay.domElement.style.pointerEvents = 'none'; // Add a help menu. // Parameters: @@ -401,11 +379,17 @@ export function setupGUI(parentContext) { modelEnabledText.innerHTML = 'Model enabled'; modelEnabledText.id = 'model-enabled-text'; parentContext.container.appendChild(modelEnabledText); + + // Show critic folder when model is enabled + criticFolder.open(); } else { const modelEnabledText = document.getElementById('model-enabled-text'); if (modelEnabledText) { parentContext.container.removeChild(modelEnabledText); } + + // Hide critic folder when model is disabled + criticFolder.close(); } }); diff --git a/examples/scenes/humanoid.xml b/examples/scenes/humanoid.xml index 7b2c8d4..9bb8ccd 100644 --- a/examples/scenes/humanoid.xml +++ b/examples/scenes/humanoid.xml @@ -14,9 +14,7 @@ --> - +