Skip to content

Commit 02f8bcf

Browse files
committed
[update] more visualization for the notebook example
1 parent c854852 commit 02f8bcf

File tree

6 files changed

+49
-26
lines changed

6 files changed

+49
-26
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ apt install libzmq3-dev # For ubuntu
2323
brew install zmq # For Mac
2424
```
2525

26+
**Note:** this visualizer does not have a Python version requirement but
27+
IsaacGym requires Python 3.6, 3.7, or 3.8
28+
2629
```shell
27-
# git clone this repo
28-
cd sim-web-visualier && git submodule update --init --recursive
30+
git clone https://github.com/NVlabs/sim-web-visualizer
31+
cd sim-web-visualizer && git submodule update --init --recursive
2932
pip install -e .
33+
3034
```
3135

3236
## Examples

example/isaacgym/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@ pip install hydra-core gym==0.23.1 rl-games torch pyvirtualdisplay omegaconf jin
1313

1414
#### Train and visualize IsaacGym in Jupyter Notebook
1515

16-
[Jupyter Notebook Example](./train_isaacgym_remote_server.ipynb)
16+
```shell
17+
pip install jupyter
18+
# Launch Jupyter server
19+
jupyter notebook --ip 0.0.0.0
20+
21+
```
22+
23+
Follow the instruction in [Jupyter Notebook Example](./train_isaacgym_remote_server.ipynb)
24+
25+
![notebook example](docs/notebook.gif)
1726

1827
#### Visualize environment with random action agent
1928

example/isaacgym/docs/notebook.gif

6.27 MB
Loading
-179 KB
Loading

example/isaacgym/train_isaacgym_remote_server.ipynb

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@
88
"source": [
99
"# Run this cell only when you are troubled with the following error especially if you are using conda to manage python environment\n",
1010
"# `ImportError: libpython3.8.so.1.0: cannot open shared object file: No such file or directory\n",
11+
"import os\n",
12+
"from pathlib import Path\n",
1113
"from ctypes import cdll\n",
12-
"lib1 = cdll.LoadLibrary('YOUR_CONDA_PATH/envs/YOUR_CONDA_ENV_NAME/lib/libpython3.8.so.1.0')\n"
14+
"import sys\n",
15+
"is_conda = 'CONDA_PREFIX' in os.environ or 'CONDA_DEFAULT_ENV' in os.environ\n",
16+
"if is_conda:\n",
17+
" version_info = sys.version_info\n",
18+
" conda_lib_path = Path(sys.executable).parent.parent / f\"lib/libpython{version_info.major}.{version_info.minor}.so.1.0\"\n",
19+
" python_lib = cdll.LoadLibrary(str(conda_lib_path))\n",
20+
" print(f\"Load Python lib {conda_lib_path}\")\n"
1321
]
1422
},
1523
{
@@ -19,7 +27,6 @@
1927
"outputs": [],
2028
"source": [
2129
"import os\n",
22-
"import sys\n",
2330
"from datetime import datetime\n",
2431
"import numpy as np\n",
2532
"\n",
@@ -73,7 +80,7 @@
7380
"vec_task.VecTask.create_sim = wrapped_create_sim\n",
7481
"\n",
7582
"# Create web visualizer\n",
76-
"web_visualizer = create_isaac_visualizer(port=6000, host=\"localhost\", keep_default_viewer=False, max_env=4, scene_offset=np.array([10.0, 10.0]))\n",
83+
"web_visualizer = create_isaac_visualizer(port=6000, host=\"localhost\", keep_default_viewer=False, max_env=16, scene_offset=np.array([40.0, 40.0]))\n",
7784
"\n",
7885
"\n",
7986
"################################################################################################\n",
@@ -264,42 +271,45 @@
264271
{
265272
"cell_type": "code",
266273
"execution_count": null,
267-
"metadata": {},
274+
"metadata": {
275+
"collapsed": false,
276+
"jupyter": {
277+
"outputs_hidden": false
278+
}
279+
},
268280
"outputs": [],
269281
"source": [
270-
"# Modify the IP if the jupyter server is not localhost\n",
271-
"machine_ip = \"127.0.0.1\"\n",
272-
"web_visualizer.jupyter_cell(url=f\"http://{machine_ip}:7000/static/\")"
282+
"# Comment out the hydra/job_logging in the config to avoid a hydra error.\n",
283+
"# This is nothing related to the web visualizer but will raise a multiple value error without the following modification\n",
284+
"# You do not need to do that if you are not using hydra compose API.\n",
285+
"!sed -i 's/- hydra/#- hydra/g' IsaacGymEnvs/isaacgymenvs/cfg/config.yaml"
273286
]
274287
},
275288
{
276289
"cell_type": "code",
277290
"execution_count": null,
291+
"metadata": {},
278292
"outputs": [],
279293
"source": [
280-
"# Comment out the hydra/job_logging in the config to avoid a hydra error.\n",
281-
"# This is nothing related to the web visualizer but will raise a multiple value error without the following modification\n",
282-
"# You do not need to do that if you are not using hydra compose API.\n",
283-
"!sed -i 's/- hydra/#- hydra/g' IsaacGymEnvs/isaacgymenvs/cfg/config.yaml"
284-
],
285-
"metadata": {
286-
"collapsed": false
287-
}
294+
"# Modify the IP if the jupyter server is not localhost\n",
295+
"machine_ip = \"127.0.0.1\"\n",
296+
"web_visualizer.jupyter_cell(url=f\"http://{machine_ip}:7000/static/\", height=400)"
297+
]
288298
},
289299
{
290300
"cell_type": "code",
291301
"execution_count": null,
292-
"metadata": {},
302+
"metadata": {
303+
"scrolled": true
304+
},
293305
"outputs": [],
294306
"source": [
295307
"hydra.core.global_hydra.GlobalHydra.instance().clear()\n",
296308
"config_path = \"IsaacGymEnvs/isaacgymenvs/cfg\"\n",
297-
"\n",
298-
"task_name = \"AllegroHand\"\n",
309+
"task_name = \"Ant\"\n",
299310
"with hydra.initialize(version_base=None, config_path=config_path):\n",
300311
" cfg = hydra.compose(config_name='config.yaml', overrides=[f\"task={task_name}\"])\n",
301-
"\n",
302-
"launch_rlg_hydra(cfg)\n"
312+
"launch_rlg_hydra(cfg)"
303313
]
304314
},
305315
{
@@ -326,9 +336,9 @@
326336
"name": "python",
327337
"nbconvert_exporter": "python",
328338
"pygments_lexer": "ipython3",
329-
"version": "3.8.16"
339+
"version": "3.8.17"
330340
}
331341
},
332342
"nbformat": 4,
333-
"nbformat_minor": 1
343+
"nbformat_minor": 4
334344
}

sim_web_visualizer/isaac_visualizer_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def create_env(arg0: gymapi.Sim, arg1: gymapi.Vec3, arg2: gymapi.Vec3, arg3: int
167167
self.env_handle_request += 1
168168

169169
if self.num_per_row is None:
170-
self.num_per_row = arg3
170+
self.num_per_row = min(arg3, int(np.ceil(np.sqrt(self.max_env))))
171171
env_size = arg2 - arg1
172172
self.env_size = np.array([env_size.x, env_size.y, env_size.z])
173173
return env

0 commit comments

Comments
 (0)