@@ -8,6 +8,7 @@ import { GamepadController } from "./gamepad_controller.js"
88import { Position } from "./trajectories/position.js"
99import { Lissajous } from "./trajectories/lissajous.js"
1010import { SecondOrderLangevin } from "./trajectories/langevin.js"
11+ import { PingPong } from "./trajectories/ping_pong.js"
1112// import Controller from "./controller.js"
1213
1314// check url for "file" parameter
@@ -119,7 +120,10 @@ class Policy{
119120 let input = math . matrix ( [ observation_description . split ( "." ) . map ( x => this . get_observation ( state , x ) ) . flat ( ) ] )
120121 const reference = references [ i ]
121122 reference . forEach ( ( x , i ) => {
122- input . _data [ 0 ] [ i ] = input . _data [ 0 ] [ i ] - x
123+ const value_raw = input . _data [ 0 ] [ i ] - x ;
124+ const clip = ( x , min , max ) => x < min ? min : ( x > max ? max : x ) ;
125+ const value_clip = i < 3 ? clip ( value_raw , - 1 , 1 ) : clip ( value_raw , - 2 , 2 ) ;
126+ input . _data [ 0 ] [ i ] = value_clip
123127 } )
124128 const [ output , new_state ] = model . evaluate_step ( input , this . policy_states [ i ] )
125129 this . policy_states [ i ] = new_state
@@ -216,7 +220,7 @@ async function main() {
216220 trajectory_offset_value . textContent = trajectory_offset . toFixed ( 2 )
217221 } )
218222 const trajectory_select = document . getElementById ( "reference-trajectory" )
219- const trajectories = { "Position" : Position , "Lissajous" : Lissajous , "Langevin" : SecondOrderLangevin }
223+ const trajectories = { "Position" : Position , "Lissajous" : Lissajous , "Langevin" : SecondOrderLangevin , "Ping Pong" : PingPong }
220224 trajectory_select . innerHTML = ""
221225 for ( const name in trajectories ) {
222226 trajectory_select . innerHTML += `<option value="${ name } ">${ name } </option>`
0 commit comments