File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 103103
104104More details about this and other energy functions used in the simulation can be found [ here] ( https://arxiv.org/abs/2102.05791 ) .
105105
106+ ## neural controller
107+
108+ <img src =" media/locomotion.gif " width =" 250px " >
109+
110+ ``` html
111+ <!DOCTYPE html>
112+ <html >
113+ <head >
114+ <meta charset =" UTF-8" >
115+ </head >
116+ <body >
117+ <script type =" module" >
118+ import algovivo from " https://cdn.jsdelivr.net/gh/juniorrojas/algovivo@9f68b2c/build/algovivo.min.mjs" ;
119+
120+ async function loadWasm () {
121+ const response = await fetch (" https://cdn.jsdelivr.net/gh/juniorrojas/algovivo@9f68b2c/build/algovivo.wasm" );
122+ const wasm = await WebAssembly .instantiateStreaming (response);
123+ return wasm .instance ;
124+ }
125+
126+ async function main () {
127+ const meshData = await (await fetch (" https://cdn.jsdelivr.net/gh/juniorrojas/algovivo@a5e8c73/demo/public/data/biped/mesh.json" )).json ();
128+
129+ const policyData = await (await fetch (" https://cdn.jsdelivr.net/gh/juniorrojas/algovivo@a5e8c73/demo/public/data/biped/policy.json" )).json ();
130+
131+ const system = new algovivo.System ({
132+ wasmInstance: await loadWasm ()
133+ });
134+ system .set (meshData);
135+
136+ const policy = new algovivo.nn.MLPPolicy ({ system, active: true });
137+ policy .loadData (policyData);
138+
139+ const viewport = new algovivo.SystemViewport ({
140+ system,
141+ sortedVertexIds: meshData .sorted_vertex_ids ,
142+ vertexDepths: meshData .depth
143+ });
144+ document .body .appendChild (viewport .domElement );
145+ viewport .render ();
146+
147+ setInterval (() => {
148+ policy .step ();
149+ system .step ();
150+ viewport .render ();
151+ }, 1000 / 30 );
152+ }
153+
154+ main ();
155+ </script >
156+ </body >
157+ </html >
158+ ```
159+
106160## build from source
107161
108162### build JS
You can’t perform that action at this time.
0 commit comments