Skip to content

Commit 2ff6148

Browse files
authored
Merge pull request #79 from MuammerBay/project-scripts
Adds scripts as project's scripts
2 parents 6919ed7 + d825bde commit 2ff6148

File tree

13 files changed

+115
-206
lines changed

13 files changed

+115
-206
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
44
[![Isaac Sim](https://img.shields.io/badge/IsaacSim-5.1.0-76B900.svg)](https://docs.isaacsim.omniverse.nvidia.com/latest/index.html)
55
[![Isaac Lab](https://img.shields.io/badge/IsaacLab-2.3.0-8A2BE2.svg)](https://isaac-sim.github.io/IsaacLab/main/index.html)
6-
[![Python](https://img.shields.io/badge/python-3.11-3776AB.svg)](https://docs.python.org/3/whatsnew/3.11.html)
6+
[![Python](https://img.shields.io/badge/python-3.11-3776AB.svg)](https://docsthon.org/3/whatsnew/3.11.html)
77

88
This repository implements tasks for the SO‑ARM100 and SO‑ARM101 robots using Isaac Lab. It serves as the foundation for several tutorials in the LycheeAI Hub series [Project: SO‑ARM101 × Isaac Sim × Isaac Lab](https://lycheeai-hub.com/project-so-arm101-x-isaac-sim-x-isaac-lab-tutorial-series).
99

@@ -33,28 +33,28 @@ uv sync
3333
List available environments.
3434

3535
```bash
36-
uv run scripts/list_envs.py
36+
uv run list_envs
3737
```
3838

3939
Test with dummy agents.
4040

4141
```bash
42-
uv run scripts/zero_agent.py --task SO-ARM100-Reach-Play-v0 # send zero actions
43-
uv run scripts/random_agent.py --task SO-ARM100-Reach-Play-v0 # send random actions
42+
uv run zero_agent --task SO-ARM100-Reach-Play-v0 # send zero actions
43+
uv run random_agent --task SO-ARM100-Reach-Play-v0 # send random actions
4444
```
4545

4646
## Reaching
4747

4848
Train a RL-based IK policy.
4949

5050
```bash
51-
uv run scripts/rsl_rl/train.py --task SO-ARM100-Reach-v0 --headless
51+
uv run train --task SO-ARM100-Reach-v0 --headless
5252
```
5353

5454
Evaluate a trained policy.
5555

5656
```bash
57-
uv run scripts/rsl_rl/play.py --task SO-ARM100-Reach-Play-v0
57+
uv run play --task SO-ARM100-Reach-Play-v0
5858
```
5959

6060
## Sim2Real Transfer

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ dependencies = [
1313
"torchvision==0.22.0",
1414
]
1515

16+
[project.scripts]
17+
train = "isaac_so_arm101.scripts.rsl_rl.train:main"
18+
play = "isaac_so_arm101.scripts.rsl_rl.play:main"
19+
list_envs = "isaac_so_arm101.scripts.list_envs:main"
20+
zero_agent = "isaac_so_arm101.scripts.zero_agent:main"
21+
random_agent = "isaac_so_arm101.scripts.random_agent:main"
22+
1623
[tool.uv]
1724
index-strategy = "unsafe-best-match"
1825
environments = [

src/isaac_so_arm101/__init__.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
# Copyright (c) 2024-2025, Muammer Bay (LycheeAI), Louis Le Lay
2-
# All rights reserved.
3-
#
4-
# SPDX-License-Identifier: BSD-3-Clause
5-
#
6-
# Copyright (c) 2022-2025, The Isaac Lab Project Developers.
7-
# All rights reserved.
8-
#
9-
# SPDX-License-Identifier: BSD-3-Clause
10-
111
"""
122
Python module serving as a project/extension template.
13-
"""
14-
15-
# Register Gym environments.
16-
from .tasks import *
17-
18-
# Register UI extensions.
19-
from .ui_extension_example import *
3+
"""
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
# Copyright (c) 2024-2025, Muammer Bay (LycheeAI), Louis Le Lay
2-
# All rights reserved.
3-
#
4-
# SPDX-License-Identifier: BSD-3-Clause
5-
#
6-
# Copyright (c) 2022-2025, The Isaac Lab Project Developers.
1+
# Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
72
# All rights reserved.
83
#
94
# SPDX-License-Identifier: BSD-3-Clause
@@ -14,8 +9,7 @@
149
The script iterates over all registered environments and stores the details in a table.
1510
It prints the name of the environment, the entry point and the config file.
1611
17-
All the environments are registered in the `import isaac_so_arm101.tasks # noqa: F401
18-
` extension. They start
12+
All the environments are registered in the `isaaclab_tasks` extension. They start
1913
with `Isaac` in their name.
2014
"""
2115

@@ -31,13 +25,13 @@
3125
"""Rest everything follows."""
3226

3327
import gymnasium as gym
34-
import isaac_so_arm101.tasks # noqa: F401
3528
from prettytable import PrettyTable
3629

30+
import isaac_so_arm101.tasks # noqa: F401
31+
3732

3833
def main():
39-
"""Print all environments registered in `import isaac_so_arm101.tasks # noqa: F401
40-
` extension."""
34+
"""Print all environments registered in `isaaclab_tasks` extension."""
4135
# print all the available environments
4236
table = PrettyTable(["S. No.", "Task Name", "Entry Point", "Config"])
4337
table.title = "Available Environments in Isaac Lab"
@@ -50,7 +44,7 @@ def main():
5044
index = 0
5145
# acquire all Isaac environments names
5246
for task_spec in gym.registry.values():
53-
if "SO-ARM100-" in task_spec.id:
47+
if "SO-ARM" in task_spec.id:
5448
# add details to table
5549
table.add_row([index + 1, task_spec.id, task_spec.entry_point, task_spec.kwargs["env_cfg_entry_point"]])
5650
# increment count
@@ -60,11 +54,7 @@ def main():
6054

6155

6256
if __name__ == "__main__":
63-
try:
64-
# run the main function
65-
main()
66-
except Exception as e:
67-
raise e
68-
finally:
69-
# close the app
70-
simulation_app.close()
57+
# run the main function
58+
main()
59+
# close sim app
60+
simulation_app.close()

scripts/random_agent.py renamed to src/isaac_so_arm101/scripts/random_agent.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
# Copyright (c) 2024-2025, Muammer Bay (LycheeAI), Louis Le Lay
2-
# All rights reserved.
3-
#
4-
# SPDX-License-Identifier: BSD-3-Clause
5-
#
6-
# Copyright (c) 2022-2025, The Isaac Lab Project Developers.
1+
# Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
72
# All rights reserved.
83
#
94
# SPDX-License-Identifier: BSD-3-Clause
@@ -35,11 +30,14 @@
3530
"""Rest everything follows."""
3631

3732
import gymnasium as gym
33+
import torch
34+
3835
import isaaclab_tasks # noqa: F401
3936
import isaac_so_arm101.tasks # noqa: F401
40-
import torch
4137
from isaaclab_tasks.utils import parse_env_cfg
4238

39+
# PLACEHOLDER: Extension template (do not remove this comment)
40+
4341

4442
def main():
4543
"""Random actions agent with Isaac Lab environment."""
@@ -72,4 +70,4 @@ def main():
7270
# run the main function
7371
main()
7472
# close sim app
75-
simulation_app.close()
73+
simulation_app.close()

scripts/rsl_rl/cli_args.py renamed to src/isaac_so_arm101/scripts/rsl_rl/cli_args.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
# Copyright (c) 2024-2025, Muammer Bay (LycheeAI), Louis Le Lay
2-
# All rights reserved.
3-
#
4-
# SPDX-License-Identifier: BSD-3-Clause
5-
#
6-
# Copyright (c) 2022-2025, The Isaac Lab Project Developers.
1+
# Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
72
# All rights reserved.
83
#
94
# SPDX-License-Identifier: BSD-3-Clause
@@ -93,4 +88,4 @@ def update_rsl_rl_cfg(agent_cfg: RslRlBaseRunnerCfg, args_cli: argparse.Namespac
9388
agent_cfg.wandb_project = args_cli.log_project_name
9489
agent_cfg.neptune_project = args_cli.log_project_name
9590

96-
return agent_cfg
91+
return agent_cfg

scripts/rsl_rl/play.py renamed to src/isaac_so_arm101/scripts/rsl_rl/play.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
# Copyright (c) 2024-2025, Muammer Bay (LycheeAI), Louis Le Lay
2-
# All rights reserved.
3-
#
4-
# SPDX-License-Identifier: BSD-3-Clause
5-
#
6-
# Copyright (c) 2022-2025, The Isaac Lab Project Developers.
1+
# Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
72
# All rights reserved.
83
#
94
# SPDX-License-Identifier: BSD-3-Clause
@@ -18,7 +13,7 @@
1813
from isaaclab.app import AppLauncher
1914

2015
# local imports
21-
import cli_args # isort: skip
16+
import isaac_so_arm101.scripts.rsl_rl.cli_args as cli_args # isort: skip
2217

2318
# add argparse arguments
2419
parser = argparse.ArgumentParser(description="Train an RL agent with RSL-RL.")
@@ -58,13 +53,13 @@
5853

5954
"""Rest everything follows."""
6055

56+
import gymnasium as gym
6157
import os
6258
import time
63-
64-
import gymnasium as gym
65-
import isaaclab_tasks # noqa: F401
66-
import isaac_so_arm101.tasks # noqa: F401
6759
import torch
60+
61+
from rsl_rl.runners import DistillationRunner, OnPolicyRunner
62+
6863
from isaaclab.envs import (
6964
DirectMARLEnv,
7065
DirectMARLEnvCfg,
@@ -75,15 +70,15 @@
7570
from isaaclab.utils.assets import retrieve_file_path
7671
from isaaclab.utils.dict import print_dict
7772
from isaaclab.utils.pretrained_checkpoint import get_published_pretrained_checkpoint
78-
from isaaclab_rl.rsl_rl import (
79-
RslRlBaseRunnerCfg,
80-
RslRlVecEnvWrapper,
81-
export_policy_as_jit,
82-
export_policy_as_onnx,
83-
)
73+
74+
from isaaclab_rl.rsl_rl import RslRlBaseRunnerCfg, RslRlVecEnvWrapper, export_policy_as_jit, export_policy_as_onnx
75+
76+
import isaaclab_tasks # noqa: F401
77+
import isaac_so_arm101.tasks # noqa: F401
8478
from isaaclab_tasks.utils import get_checkpoint_path
8579
from isaaclab_tasks.utils.hydra import hydra_task_config
86-
from rsl_rl.runners import DistillationRunner, OnPolicyRunner
80+
81+
# PLACEHOLDER: Extension template (do not remove this comment)
8782

8883

8984
@hydra_task_config(args_cli.task, args_cli.agent)
@@ -118,6 +113,9 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
118113

119114
log_dir = os.path.dirname(resume_path)
120115

116+
# set the log directory for the environment (works for all environment types)
117+
env_cfg.log_dir = log_dir
118+
121119
# create isaac environment
122120
env = gym.make(args_cli.task, cfg=env_cfg, render_mode="rgb_array" if args_cli.video else None)
123121

@@ -208,4 +206,4 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
208206
# run the main function
209207
main()
210208
# close sim app
211-
simulation_app.close()
209+
simulation_app.close()

0 commit comments

Comments
 (0)