forked from isaac-sim/IsaacLab
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Manager Based Cartpole Vision Example Environments (isaac-sim#995
) # Description Adds manager based cartpole vision example environments. Also uses the`convert_perspective_depth_to_orthogonal_depth ` functionality introduced in isaac-sim#976 , contains a duplicate copy of the method and test for completeness of the PR. Will be synced with main to remove this duplicate copy once isaac-sim#976 is merged into main, or isaac-sim#976 will be synced with main if this PR is merged first ## Type of change - New feature (non-breaking change which adds functionality) - This change requires a documentation update ## Screenshots ![image](https://github.com/user-attachments/assets/4cce3923-b199-4469-b8d0-9d8d8abb3456) ## Checklist - [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 - [x] 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 ## Testing Training converged in both RGB and Depth at similar rates to the direct environments --------- Signed-off-by: garylvov <[email protected]> Signed-off-by: glvov-bdai <[email protected]> Co-authored-by: garylvov <[email protected]> Co-authored-by: garylvov <[email protected]> Co-authored-by: James Smith <[email protected]>
- Loading branch information
1 parent
f8d80cb
commit 2804ff3
Showing
7 changed files
with
267 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...s/omni/isaac/lab_tasks/manager_based/classic/cartpole/agents/rl_games_camera_ppo_cfg.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
params: | ||
seed: 42 | ||
|
||
# environment wrapper clipping | ||
env: | ||
# added to the wrapper | ||
clip_observations: 5.0 | ||
# can make custom wrapper? | ||
clip_actions: 1.0 | ||
|
||
algo: | ||
name: a2c_continuous | ||
|
||
model: | ||
name: continuous_a2c_logstd | ||
|
||
# doesn't have this fine grained control but made it close | ||
network: | ||
name: actor_critic | ||
separate: False | ||
space: | ||
continuous: | ||
mu_activation: None | ||
sigma_activation: None | ||
|
||
mu_init: | ||
name: default | ||
sigma_init: | ||
name: const_initializer | ||
val: 0 | ||
fixed_sigma: True | ||
cnn: | ||
type: conv2d | ||
activation: relu | ||
initializer: | ||
name: default | ||
regularizer: | ||
name: None | ||
convs: | ||
- filters: 32 | ||
kernel_size: 8 | ||
strides: 4 | ||
padding: 0 | ||
- filters: 64 | ||
kernel_size: 4 | ||
strides: 2 | ||
padding: 0 | ||
- filters: 64 | ||
kernel_size: 3 | ||
strides: 1 | ||
padding: 0 | ||
|
||
mlp: | ||
units: [512] | ||
activation: elu | ||
initializer: | ||
name: default | ||
|
||
load_checkpoint: False # flag which sets whether to load the checkpoint | ||
load_path: '' # path to the checkpoint to load | ||
|
||
config: | ||
name: cartpole_camera | ||
env_name: rlgpu | ||
device: 'cuda:0' | ||
device_name: 'cuda:0' | ||
multi_gpu: False | ||
ppo: True | ||
mixed_precision: False | ||
normalize_input: False | ||
normalize_value: True | ||
num_actors: -1 # configured from the script (based on num_envs) | ||
reward_shaper: | ||
scale_value: 1.0 | ||
normalize_advantage: True | ||
gamma: 0.99 | ||
tau : 0.95 | ||
learning_rate: 1e-4 | ||
lr_schedule: adaptive | ||
kl_threshold: 0.008 | ||
score_to_win: 20000 | ||
max_epochs: 500 | ||
save_best_after: 50 | ||
save_frequency: 25 | ||
grad_norm: 1.0 | ||
entropy_coef: 0.0 | ||
truncate_grads: True | ||
e_clip: 0.2 | ||
horizon_length: 64 | ||
minibatch_size: 2048 | ||
mini_epochs: 4 | ||
critic_coef: 2 | ||
clip_value: True | ||
seq_length: 4 | ||
bounds_loss_coef: 0.0001 |
86 changes: 86 additions & 0 deletions
86
....lab_tasks/omni/isaac/lab_tasks/manager_based/classic/cartpole/cartpole_camera_env_cfg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Copyright (c) 2022-2024, The Isaac Lab Project Developers. | ||
# All rights reserved. | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
import omni.isaac.lab.sim as sim_utils | ||
from omni.isaac.lab.envs.mdp.observations import grab_images | ||
from omni.isaac.lab.managers import ObservationGroupCfg as ObsGroup | ||
from omni.isaac.lab.managers import ObservationTermCfg as ObsTerm | ||
from omni.isaac.lab.managers import SceneEntityCfg | ||
from omni.isaac.lab.sensors import TiledCameraCfg | ||
from omni.isaac.lab.utils import configclass | ||
|
||
from omni.isaac.lab_tasks.manager_based.classic.cartpole.cartpole_env_cfg import CartpoleEnvCfg, CartpoleSceneCfg | ||
|
||
## | ||
# Scene definition | ||
## | ||
|
||
|
||
@configclass | ||
class CartpoleRGBCameraSceneCfg(CartpoleSceneCfg): | ||
tiled_camera: TiledCameraCfg = TiledCameraCfg( | ||
prim_path="{ENV_REGEX_NS}/Camera", | ||
offset=TiledCameraCfg.OffsetCfg(pos=(-7.0, 0.0, 3.0), rot=(0.9945, 0.0, 0.1045, 0.0), convention="world"), | ||
data_types=["rgb"], | ||
spawn=sim_utils.PinholeCameraCfg( | ||
focal_length=24.0, focus_distance=400.0, horizontal_aperture=20.955, clipping_range=(0.1, 20.0) | ||
), | ||
width=80, | ||
height=80, | ||
) | ||
|
||
|
||
@configclass | ||
class CartpoleDepthCameraSceneCfg(CartpoleSceneCfg): | ||
tiled_camera: TiledCameraCfg = TiledCameraCfg( | ||
prim_path="{ENV_REGEX_NS}/Camera", | ||
offset=TiledCameraCfg.OffsetCfg(pos=(-7.0, 0.0, 3.0), rot=(0.9945, 0.0, 0.1045, 0.0), convention="world"), | ||
data_types=["distance_to_camera"], | ||
spawn=sim_utils.PinholeCameraCfg( | ||
focal_length=24.0, focus_distance=400.0, horizontal_aperture=20.955, clipping_range=(0.1, 20.0) | ||
), | ||
width=80, | ||
height=80, | ||
) | ||
|
||
|
||
@configclass | ||
class RGBObservationsCfg: | ||
"""Observation specifications for the MDP.""" | ||
|
||
@configclass | ||
class RGBCameraPolicyCfg(ObsGroup): | ||
"""Observations for policy group.""" | ||
|
||
image = ObsTerm(func=grab_images, params={"sensor_cfg": SceneEntityCfg("tiled_camera"), "data_type": "rgb"}) | ||
|
||
def __post_init__(self) -> None: | ||
self.enable_corruption = False | ||
self.concatenate_terms = True | ||
|
||
policy: ObsGroup = RGBCameraPolicyCfg() | ||
|
||
|
||
@configclass | ||
class DepthObservationsCfg: | ||
@configclass | ||
class DepthCameraPolicyCfg(RGBObservationsCfg.RGBCameraPolicyCfg): | ||
image = ObsTerm( | ||
func=grab_images, params={"sensor_cfg": SceneEntityCfg("tiled_camera"), "data_type": "distance_to_camera"} | ||
) | ||
|
||
policy: ObsGroup = DepthCameraPolicyCfg() | ||
|
||
|
||
@configclass | ||
class CartpoleRGBCameraEnvCfg(CartpoleEnvCfg): | ||
scene: CartpoleSceneCfg = CartpoleRGBCameraSceneCfg(num_envs=1024, env_spacing=20) | ||
observations = RGBObservationsCfg() | ||
|
||
|
||
@configclass | ||
class CartpoleDepthCameraEnvCfg(CartpoleEnvCfg): | ||
scene: CartpoleSceneCfg = CartpoleDepthCameraSceneCfg(num_envs=1024, env_spacing=20) | ||
observations = DepthObservationsCfg() |