Skip to content

Commit 00525c2

Browse files
Removing unused code
1 parent 136f26b commit 00525c2

File tree

2 files changed

+104
-1
lines changed

2 files changed

+104
-1
lines changed

src/generate_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def read_json(path: Union[str, Path]) -> str:
8282

8383
def main() -> None:
8484
# Read the JSON files
85-
results_dir = join(Path(__file__).resolve().parents[1], "results")
85+
results_dir = join(Path(__file__).resolve().parents[1], "docs")
8686
data_dir = join(results_dir, "data")
8787

8888
initial_system = read_json(join(data_dir, "initial_system.json"))
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
from typing import Union
2+
from pathlib import Path
3+
from os.path import join
4+
5+
_HTML = """
6+
<html>
7+
<head>
8+
<title>Grasp - Pick-and-place robotic hand (Visualisation)</title>
9+
<style>
10+
body {
11+
margin: 0;
12+
padding: 0;
13+
}
14+
15+
h3 {
16+
display: flex;
17+
justify-content: center;
18+
padding-top: 18px;
19+
}
20+
21+
[id^='brax-viewer-'] {
22+
margin: 0;
23+
padding: 0;
24+
height: 50vh;
25+
padding-bottom: 2.5%;
26+
}
27+
</style>
28+
</head>
29+
<body>
30+
<script type="application/javascript">
31+
32+
var initial_system = <!-- initial_system -->;
33+
var sys_1K = <!-- sys_1K -->;
34+
var sys_5M = <!-- sys_5M -->;
35+
var sys_400M = <!-- sys_400M -->;
36+
var final_600M = <!-- final_600M -->;
37+
38+
</script>
39+
40+
<h3>1. Initial Agent's State </h3>
41+
<div id="brax-viewer-initial_system"></div>
42+
43+
<h3>2. Agent's state after 1K steps</h3>
44+
<div id="brax-viewer-sys_1K"></div>
45+
46+
<h3>3. Agent's state after 5 million steps</h3>
47+
<div id="brax-viewer-sys_5M"></div>
48+
49+
<h3>4. Agent's state after 400 million steps</h3>
50+
<div id="brax-viewer-sys_400M"></div>
51+
52+
<h3>5. Final Agent's state (after 600 million steps)</h3>
53+
<div id="brax-viewer-final_600M"></div>
54+
55+
<script type="module">
56+
57+
import {Viewer} from 'https://cdn.jsdelivr.net/gh/google/brax@v0.1.0/js/viewer.js';
58+
59+
const domElement_initial_system = document.getElementById('brax-viewer-initial_system');
60+
var viewer_initial_system = new Viewer(domElement_initial_system, initial_system);
61+
62+
const domElement_sys_1K = document.getElementById('brax-viewer-sys_1K');
63+
var viewer_sys_1K = new Viewer(domElement_sys_1K, sys_1K);
64+
65+
const domElement_sys_5M = document.getElementById('brax-viewer-sys_5M');
66+
var viewer_sys_5M = new Viewer(domElement_sys_5M, sys_5M);
67+
68+
const domElement_sys_400M = document.getElementById('brax-viewer-sys_400M');
69+
var viewerys_400M = new Viewer(domElement_sys_400M, sys_400M);
70+
71+
const domElement_final_600M = document.getElementById('brax-viewer-final_600M');
72+
var vieweral_600M = new Viewer(domElement_final_600M, final_600M);
73+
74+
</script>
75+
</body>
76+
</html>
77+
"""
78+
79+
def read_json(path: Union[str, Path]) -> str:
80+
with open(path, "r") as f:
81+
return f.read()
82+
83+
def main() -> None:
84+
# Read the JSON files
85+
results_dir = join(Path(__file__).resolve().parents[1], "docs")
86+
data_dir = join(results_dir, "data")
87+
88+
initial_system = read_json(join(data_dir, "initial_system.json"))
89+
sys_1K = read_json(join(data_dir, "sys_1K.json"))
90+
sys_5M = read_json(join(data_dir, "sys_5M.json"))
91+
sys_400M = read_json(join(data_dir, "sys_400M.json"))
92+
final_600M = read_json(join(data_dir, "final_600M.json"))
93+
94+
# Write the HTML file
95+
with open(join(results_dir, "index.html"), "w") as f:
96+
f.write(_HTML.replace("<!-- initial_system -->", str(initial_system))
97+
.replace("<!-- sys_1K -->", str(sys_1K))
98+
.replace("<!-- sys_5M -->", str(sys_5M))
99+
.replace("<!-- sys_400M -->", str(sys_400M))
100+
.replace("<!-- final_600M -->", str(final_600M)))
101+
102+
if __name__ == "__main__":
103+
main()

0 commit comments

Comments
 (0)