Unverified Commit f93c8248 authored by Kelly Guo's avatar Kelly Guo Committed by GitHub

Updates Cartpole Camera environment (#512)

- Fix CartpoleDepthCameraEnvCfg
- Add option to save images to file

## Type of change

- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)

## 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
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] I have run all the tests with `./isaaclab.sh --test` and they pass
- [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
parent 478e914f
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.7.5" version = "0.7.6"
# Description # Description
title = "Isaac Lab Environments" title = "Isaac Lab Environments"
......
Changelog Changelog
--------- ---------
0.7.6 (2024-06-13)
~~~~~~~~~~~~~~~~~~
Added
^^^^^
* Added option to save images for Cartpole Camera environment.
0.7.5 (2024-05-31) 0.7.5 (2024-05-31)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
......
...@@ -17,7 +17,7 @@ import omni.isaac.lab.sim as sim_utils ...@@ -17,7 +17,7 @@ import omni.isaac.lab.sim as sim_utils
from omni.isaac.lab.assets import Articulation, ArticulationCfg from omni.isaac.lab.assets import Articulation, ArticulationCfg
from omni.isaac.lab.envs import DirectRLEnv, DirectRLEnvCfg, ViewerCfg from omni.isaac.lab.envs import DirectRLEnv, DirectRLEnvCfg, ViewerCfg
from omni.isaac.lab.scene import InteractiveSceneCfg from omni.isaac.lab.scene import InteractiveSceneCfg
from omni.isaac.lab.sensors import TiledCamera, TiledCameraCfg from omni.isaac.lab.sensors import TiledCamera, TiledCameraCfg, save_images_to_file
from omni.isaac.lab.sim import SimulationCfg from omni.isaac.lab.sim import SimulationCfg
from omni.isaac.lab.sim.spawners.from_files import GroundPlaneCfg, spawn_ground_plane from omni.isaac.lab.sim.spawners.from_files import GroundPlaneCfg, spawn_ground_plane
from omni.isaac.lab.utils import configclass from omni.isaac.lab.utils import configclass
...@@ -45,6 +45,7 @@ class CartpoleRGBCameraEnvCfg(DirectRLEnvCfg): ...@@ -45,6 +45,7 @@ class CartpoleRGBCameraEnvCfg(DirectRLEnvCfg):
width=80, width=80,
height=80, height=80,
) )
write_image_to_file = False
# change viewer settings # change viewer settings
viewer = ViewerCfg(eye=(20.0, 20.0, 20.0)) viewer = ViewerCfg(eye=(20.0, 20.0, 20.0))
...@@ -73,6 +74,7 @@ class CartpoleRGBCameraEnvCfg(DirectRLEnvCfg): ...@@ -73,6 +74,7 @@ class CartpoleRGBCameraEnvCfg(DirectRLEnvCfg):
rew_scale_pole_vel = -0.005 rew_scale_pole_vel = -0.005
@configclass
class CartpoleDepthCameraEnvCfg(CartpoleRGBCameraEnvCfg): class CartpoleDepthCameraEnvCfg(CartpoleRGBCameraEnvCfg):
# camera # camera
tiled_camera: TiledCameraCfg = TiledCameraCfg( tiled_camera: TiledCameraCfg = TiledCameraCfg(
...@@ -172,6 +174,10 @@ class CartpoleCameraEnv(DirectRLEnv): ...@@ -172,6 +174,10 @@ class CartpoleCameraEnv(DirectRLEnv):
def _get_observations(self) -> dict: def _get_observations(self) -> dict:
data_type = "rgb" if "rgb" in self.cfg.tiled_camera.data_types else "depth" data_type = "rgb" if "rgb" in self.cfg.tiled_camera.data_types else "depth"
observations = {"policy": self._tiled_camera.data.output[data_type].clone()} observations = {"policy": self._tiled_camera.data.output[data_type].clone()}
if self.cfg.write_image_to_file:
save_images_to_file(observations["policy"], f"cartpole_{data_type}.png")
return observations return observations
def _get_rewards(self) -> torch.Tensor: def _get_rewards(self) -> torch.Tensor:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment