Skip to content

Commit 1a2d704

Browse files
nv-cuprightpeterd-NVnvcycoahmednvToni-SM
committed
Adds pre-trained checkpoints and tools for generating and uploading checkpoints (isaac-sim#151)
Created a standalone script that can train all our environments and publish their checkpoints to a Nucleus server. The play.py scripts were modified to add a --use_pretrained_checkpoint flag. This downloads and caches the pre-trained checkpoint to a .pretrained_checkpoints directory. - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Signed-off-by: peterd-NV <[email protected]> Signed-off-by: Kelly Guo <[email protected]> Signed-off-by: Kelly Guo <[email protected]> Co-authored-by: peterd-NV <[email protected]> Co-authored-by: CY Chen <[email protected]> Co-authored-by: oahmednv <[email protected]> Co-authored-by: Toni-SM <[email protected]> Co-authored-by: Kelly Guo <[email protected]> Co-authored-by: Kelly Guo <[email protected]>
1 parent 981ee22 commit 1a2d704

File tree

11 files changed

+652
-23
lines changed

11 files changed

+652
-23
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,6 @@ _build
5757
**/runs/*
5858
**/logs/*
5959
**/recordings/*
60+
61+
# Pre-Trained Checkpoints
62+
/.pretrained_checkpoints/

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Guidelines for modifications:
3939
* Anton Bjørndahl Mortensen
4040
* Arjun Bhardwaj
4141
* Brayden Zhang
42+
* Cameron Upright
4243
* Calvin Yu
4344
* Chenyu Yang
4445
* CY (Chien-Ying) Chen

docs/source/overview/reinforcement-learning/rl_existing_scripts.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ RL-Games
2525
./isaaclab.sh -p source/standalone/workflows/rl_games/train.py --task Isaac-Ant-v0 --headless
2626
# run script for playing with 32 environments
2727
./isaaclab.sh -p source/standalone/workflows/rl_games/play.py --task Isaac-Ant-v0 --num_envs 32 --checkpoint /PATH/TO/model.pth
28+
# run script for playing a pre-trained checkpoint with 32 environments
29+
./isaaclab.sh -p source/standalone/workflows/rl_games/play.py --task Isaac-Ant-v0 --num_envs 32 --use_pretrained_checkpoint
2830
# run script for recording video of a trained agent (requires installing `ffmpeg`)
2931
./isaaclab.sh -p source/standalone/workflows/rl_games/play.py --task Isaac-Ant-v0 --headless --video --video_length 200
3032
@@ -39,6 +41,8 @@ RL-Games
3941
isaaclab.bat -p source\standalone\workflows\rl_games\train.py --task Isaac-Ant-v0 --headless
4042
:: run script for playing with 32 environments
4143
isaaclab.bat -p source\standalone\workflows\rl_games\play.py --task Isaac-Ant-v0 --num_envs 32 --checkpoint /PATH/TO/model.pth
44+
:: run script for playing a pre-trained checkpoint with 32 environments
45+
isaaclab.bat -p source\standalone\workflows\rl_games\play.py --task Isaac-Ant-v0 --num_envs 32 --use_pretrained_checkpoint
4246
:: run script for recording video of a trained agent (requires installing `ffmpeg`)
4347
isaaclab.bat -p source\standalone\workflows\rl_games\play.py --task Isaac-Ant-v0 --headless --video --video_length 200
4448
@@ -62,6 +66,8 @@ RSL-RL
6266
./isaaclab.sh -p source/standalone/workflows/rsl_rl/train.py --task Isaac-Reach-Franka-v0 --headless
6367
# run script for playing with 32 environments
6468
./isaaclab.sh -p source/standalone/workflows/rsl_rl/play.py --task Isaac-Reach-Franka-v0 --num_envs 32 --load_run run_folder_name --checkpoint model.pt
69+
# run script for playing a pre-trained checkpoint with 32 environments
70+
./isaaclab.sh -p source/standalone/workflows/rsl_rl/play.py --task Isaac-Reach-Franka-v0 --num_envs 32 --use_pretrained_checkpoint
6571
# run script for recording video of a trained agent (requires installing `ffmpeg`)
6672
./isaaclab.sh -p source/standalone/workflows/rsl_rl/play.py --task Isaac-Reach-Franka-v0 --headless --video --video_length 200
6773
@@ -76,6 +82,8 @@ RSL-RL
7682
isaaclab.bat -p source\standalone\workflows\rsl_rl\train.py --task Isaac-Reach-Franka-v0 --headless
7783
:: run script for playing with 32 environments
7884
isaaclab.bat -p source\standalone\workflows\rsl_rl\play.py --task Isaac-Reach-Franka-v0 --num_envs 32 --load_run run_folder_name --checkpoint model.pt
85+
:: run script for playing a pre-trained checkpoint with 32 environments
86+
isaaclab.bat -p source\standalone\workflows\rsl_rl\play.py --task Isaac-Reach-Franka-v0 --num_envs 32 --use_pretrained_checkpoint
7987
:: run script for recording video of a trained agent (requires installing `ffmpeg`)
8088
isaaclab.bat -p source\standalone\workflows\rsl_rl\play.py --task Isaac-Reach-Franka-v0 --headless --video --video_length 200
8189
@@ -103,6 +111,8 @@ SKRL
103111
./isaaclab.sh -p source/standalone/workflows/skrl/train.py --task Isaac-Reach-Franka-v0 --headless
104112
# run script for playing with 32 environments
105113
./isaaclab.sh -p source/standalone/workflows/skrl/play.py --task Isaac-Reach-Franka-v0 --num_envs 32 --checkpoint /PATH/TO/model.pt
114+
# run script for playing a pre-trained checkpoint with 32 environments
115+
./isaaclab.sh -p source/standalone/workflows/skrl/play.py --task Isaac-Reach-Franka-v0 --num_envs 32 --use_pretrained_checkpoint
106116
# run script for recording video of a trained agent (requires installing `ffmpeg`)
107117
./isaaclab.sh -p source/standalone/workflows/skrl/play.py --task Isaac-Reach-Franka-v0 --headless --video --video_length 200
108118
@@ -117,6 +127,8 @@ SKRL
117127
isaaclab.bat -p source\standalone\workflows\skrl\train.py --task Isaac-Reach-Franka-v0 --headless
118128
:: run script for playing with 32 environments
119129
isaaclab.bat -p source\standalone\workflows\skrl\play.py --task Isaac-Reach-Franka-v0 --num_envs 32 --checkpoint /PATH/TO/model.pt
130+
:: run script for playing a pre-trained checkpoint with 32 environments
131+
isaaclab.bat -p source\standalone\workflows\skrl\play.py --task Isaac-Reach-Franka-v0 --num_envs 32 --use_pretrained_checkpoint
120132
:: run script for recording video of a trained agent (requires installing `ffmpeg`)
121133
isaaclab.bat -p source\standalone\workflows\skrl\play.py --task Isaac-Reach-Franka-v0 --headless --video --video_length 200
122134
@@ -191,6 +203,8 @@ Stable-Baselines3
191203
./isaaclab.sh -p source/standalone/workflows/sb3/train.py --task Isaac-Cartpole-v0 --headless --device cpu
192204
# run script for playing with 32 environments
193205
./isaaclab.sh -p source/standalone/workflows/sb3/play.py --task Isaac-Cartpole-v0 --num_envs 32 --checkpoint /PATH/TO/model.zip
206+
# run script for playing a pre-trained checkpoint with 32 environments
207+
./isaaclab.sh -p source/standalone/workflows/sb3/play.py --task Isaac-Cartpole-v0 --num_envs 32 --use_pretrained_checkpoint
194208
# run script for recording video of a trained agent (requires installing `ffmpeg`)
195209
./isaaclab.sh -p source/standalone/workflows/sb3/play.py --task Isaac-Cartpole-v0 --headless --video --video_length 200
196210
@@ -206,6 +220,8 @@ Stable-Baselines3
206220
isaaclab.bat -p source\standalone\workflows\sb3\train.py --task Isaac-Cartpole-v0 --headless --device cpu
207221
:: run script for playing with 32 environments
208222
isaaclab.bat -p source\standalone\workflows\sb3\play.py --task Isaac-Cartpole-v0 --num_envs 32 --checkpoint /PATH/TO/model.zip
223+
:: run script for playing a pre-trained checkpoint with 32 environments
224+
isaaclab.bat -p source\standalone\workflows\sb3\play.py --task Isaac-Cartpole-v0 --num_envs 32 --use_pretrained_checkpoint
209225
:: run script for recording video of a trained agent (requires installing `ffmpeg`)
210226
isaaclab.bat -p source\standalone\workflows\sb3\play.py --task Isaac-Cartpole-v0 --headless --video --video_length 200
211227

source/extensions/omni.isaac.lab/docs/CHANGELOG.rst

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Added
163163
* Added full buffer property to :class:`omni.isaac.lab.utils.buffers.circular_buffer.CircularBuffer`
164164

165165

166-
0.27.32 (2024-12-15)
166+
0.27.33 (2024-12-15)
167167
~~~~~~~~~~~~~~~~~~~~
168168

169169
Added
@@ -172,7 +172,7 @@ Added
172172
* Added action clip to all :class:`omni.isaac.lab.envs.mdp.actions`.
173173

174174

175-
0.27.31 (2024-12-14)
175+
0.27.32 (2024-12-14)
176176
~~~~~~~~~~~~~~~~~~~~
177177

178178
Changed
@@ -181,7 +181,7 @@ Changed
181181
* Added check for error below threshold in state machines to ensure the state has been reached.
182182

183183

184-
0.27.30 (2024-12-13)
184+
0.27.31 (2024-12-13)
185185
~~~~~~~~~~~~~~~~~~~~
186186

187187
Fixed
@@ -190,7 +190,7 @@ Fixed
190190
* Fixed the shape of ``quat_w`` in the ``apply_actions`` method of :attr:`~omni.isaac.lab.env.mdp.NonHolonomicAction` (previously (N,B,4), now (N,4) since the number of root bodies B is required to be 1). Previously ``apply_actions`` errored because ``euler_xyz_from_quat`` requires inputs of shape (N,4).
191191

192192

193-
0.27.29 (2024-12-11)
193+
0.27.30 (2024-12-11)
194194
~~~~~~~~~~~~~~~~~~~~
195195

196196
Changed
@@ -201,7 +201,7 @@ Changed
201201
* Improved documentation to clarify the usage of the :meth:`~omni.isaac.lab.envs.mdp.rewards.base_height_l2` function in both flat and rough terrain settings.
202202

203203

204-
0.27.28 (2024-12-11)
204+
0.27.29 (2024-12-11)
205205
~~~~~~~~~~~~~~~~~~~~
206206

207207
Fixed
@@ -211,7 +211,7 @@ Fixed
211211
Jacobian computed w.r.t. to the root frame of the robot. This helps ensure that root pose does not affect the tracking.
212212

213213

214-
0.27.27 (2024-12-09)
214+
0.27.28 (2024-12-09)
215215
~~~~~~~~~~~~~~~~~~~~
216216

217217
Fixed
@@ -221,7 +221,7 @@ Fixed
221221
return only the states of the specified environment IDs.
222222

223223

224-
0.27.26 (2024-12-06)
224+
0.27.27 (2024-12-06)
225225
~~~~~~~~~~~~~~~~~~~~
226226

227227
Fixed
@@ -231,7 +231,7 @@ Fixed
231231
:attr:`~omni.isaac.lab.assets.Articulation.root_physx_view` level.
232232

233233

234-
0.27.25 (2024-12-06)
234+
0.27.26 (2024-12-06)
235235
~~~~~~~~~~~~~~~~~~~~
236236

237237
Changed
@@ -242,7 +242,7 @@ Changed
242242
disabled. Using an articulation root for rigid bodies is not needed and decreases overall performance.
243243

244244

245-
0.27.24 (2024-12-06)
245+
0.27.25 (2024-12-06)
246246
~~~~~~~~~~~~~~~~~~~~
247247

248248
Fixed
@@ -252,7 +252,7 @@ Fixed
252252
Earlier, the projection names used snakecase instead of camelcase.
253253

254254

255-
0.27.23 (2024-12-06)
255+
0.27.24 (2024-12-06)
256256
~~~~~~~~~~~~~~~~~~~~
257257

258258
Added
@@ -270,7 +270,7 @@ Changed
270270
:class:`~omni.isaac.lab.sensors.Camera` did not clip them and had a different behavior for both types.
271271

272272

273-
0.27.22 (2024-12-05)
273+
0.27.23 (2024-12-05)
274274
~~~~~~~~~~~~~~~~~~~~
275275

276276
Fixed
@@ -279,7 +279,7 @@ Fixed
279279
* Fixed the condition in ``isaaclab.sh`` that checks whether ``pre-commit`` is installed before attempting installation.
280280

281281

282-
0.27.21 (2024-12-04)
282+
0.27.22 (2024-12-04)
283283
~~~~~~~~~~~~~~~~~~~~
284284

285285
Fixed
@@ -288,7 +288,7 @@ Fixed
288288
* Fixed the order of the incoming parameters in :class:`omni.isaac.lab.envs.DirectMARLEnv` to correctly use ``NoiseModel`` in marl-envs.
289289

290290

291-
0.27.20 (2024-12-04)
291+
0.27.21 (2024-12-04)
292292
~~~~~~~~~~~~~~~~~~~~
293293

294294
Added
@@ -303,7 +303,7 @@ Added
303303
* Added ``replay_demos.py`` script to replay demos loaded from an HDF5 file.
304304

305305

306-
0.27.19 (2024-12-02)
306+
0.27.20 (2024-12-02)
307307
~~~~~~~~~~~~~~~~~~~~
308308

309309
Changed
@@ -312,6 +312,16 @@ Changed
312312
* Changed :class:`omni.isaac.lab.envs.DirectMARLEnv` to inherit from ``Gymnasium.Env`` due to requirement from Gymnasium v1.0.0 requiring all environments to be a subclass of ``Gymnasium.Env`` when using the ``make`` interface.
313313

314314

315+
0.27.19 (2024-12-02)
316+
~~~~~~~~~~~~~~~~~~~~
317+
318+
Added
319+
^^^^^
320+
321+
* Added ``omni.isaac.lab.utils.pretrained_checkpoints`` containing constants and utility functions used to manipulate
322+
paths and load checkpoints from Nucleus.
323+
324+
315325
0.27.18 (2024-11-28)
316326
~~~~~~~~~~~~~~~~~~~~
317327

source/extensions/omni.isaac.lab/omni/isaac/lab/utils/assets.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def check_file_path(path: str) -> Literal[0, 1, 2]:
4949
"""
5050
if os.path.isfile(path):
5151
return 1
52-
elif omni.client.stat(path)[0] == omni.client.Result.OK:
52+
# we need to convert backslash to forward slash on Windows for omni.client API
53+
elif omni.client.stat(path.replace(os.sep, "/"))[0] == omni.client.Result.OK:
5354
return 2
5455
else:
5556
return 0
@@ -91,12 +92,12 @@ def retrieve_file_path(path: str, download_dir: str | None = None, force_downloa
9192
if not os.path.exists(download_dir):
9293
os.makedirs(download_dir)
9394
# download file in temp directory using os
94-
file_name = os.path.basename(omni.client.break_url(path).path)
95+
file_name = os.path.basename(omni.client.break_url(path.replace(os.sep, "/")).path)
9596
target_path = os.path.join(download_dir, file_name)
9697
# check if file already exists locally
9798
if not os.path.isfile(target_path) or force_download:
9899
# copy file to local machine
99-
result = omni.client.copy(path, target_path)
100+
result = omni.client.copy(path.replace(os.sep, "/"), target_path)
100101
if result != omni.client.Result.OK and force_download:
101102
raise RuntimeError(f"Unable to copy file: '{path}'. Is the Nucleus Server running?")
102103
return os.path.abspath(target_path)
@@ -122,7 +123,7 @@ def read_file(path: str) -> io.BytesIO:
122123
with open(path, "rb") as f:
123124
return io.BytesIO(f.read())
124125
elif file_status == 2:
125-
file_content = omni.client.read_file(path)[2]
126+
file_content = omni.client.read_file(path.replace(os.sep, "/"))[2]
126127
return io.BytesIO(memoryview(file_content).tobytes())
127128
else:
128129
raise FileNotFoundError(f"Unable to find the file: {path}")

0 commit comments

Comments
 (0)