Unverified Commit 6ced8f93 authored by AutonomousHansen's avatar AutonomousHansen Committed by GitHub

Fixes reading of policy file from Nucleus in tutorial scripts (#308)

# Description

Adds read_file() step to scripts which check_file_path() but don't load
the file

Fixes #299 

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [ ] 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
parent fb781557
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.10.4" version = "0.10.5"
# Description # Description
title = "ORBIT framework for Robot Learning" title = "ORBIT framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.10.5 (2023-12-18)
~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Fixed test ``check_base_env_anymal_locomotion.py``, which
previously called :func:`torch.jit.load` with the path to a policy (which would work
for a local file), rather than calling
:func:`omni.isaac.orbit.utils.assets.read_file` on the path to get the file itself.
0.10.4 (2023-12-14) 0.10.4 (2023-12-14)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
......
...@@ -53,7 +53,7 @@ from omni.isaac.orbit.scene import InteractiveSceneCfg ...@@ -53,7 +53,7 @@ from omni.isaac.orbit.scene import InteractiveSceneCfg
from omni.isaac.orbit.sensors import RayCasterCfg, patterns from omni.isaac.orbit.sensors import RayCasterCfg, patterns
from omni.isaac.orbit.terrains import TerrainImporterCfg from omni.isaac.orbit.terrains import TerrainImporterCfg
from omni.isaac.orbit.utils import configclass from omni.isaac.orbit.utils import configclass
from omni.isaac.orbit.utils.assets import ISAAC_ORBIT_NUCLEUS_DIR, check_file_path from omni.isaac.orbit.utils.assets import ISAAC_ORBIT_NUCLEUS_DIR, check_file_path, read_file
from omni.isaac.orbit.utils.noise import AdditiveUniformNoiseCfg as Unoise from omni.isaac.orbit.utils.noise import AdditiveUniformNoiseCfg as Unoise
## ##
...@@ -215,11 +215,13 @@ def main(): ...@@ -215,11 +215,13 @@ def main():
# load level policy # load level policy
policy_path = os.path.join(ISAAC_ORBIT_NUCLEUS_DIR, "Policies", "ANYmal-C", "policy.pt") policy_path = os.path.join(ISAAC_ORBIT_NUCLEUS_DIR, "Policies", "ANYmal-C", "policy.pt")
# check if policy file exists # check if policy file exists
if not check_file_path(policy_path): if not check_file_path(policy_path):
raise FileNotFoundError(f"Policy file '{policy_path}' does not exist.") raise FileNotFoundError(f"Policy file '{policy_path}' does not exist.")
file_bytes = read_file(policy_path)
# jit load the policy # jit load the policy
locomotion_policy = torch.jit.load(policy_path) locomotion_policy = torch.jit.load(file_bytes)
locomotion_policy.to(env.device) locomotion_policy.to(env.device)
locomotion_policy.eval() locomotion_policy.eval()
......
...@@ -60,7 +60,7 @@ from omni.isaac.orbit.scene import InteractiveSceneCfg ...@@ -60,7 +60,7 @@ from omni.isaac.orbit.scene import InteractiveSceneCfg
from omni.isaac.orbit.sensors import RayCasterCfg, patterns from omni.isaac.orbit.sensors import RayCasterCfg, patterns
from omni.isaac.orbit.terrains import TerrainImporterCfg from omni.isaac.orbit.terrains import TerrainImporterCfg
from omni.isaac.orbit.utils import configclass from omni.isaac.orbit.utils import configclass
from omni.isaac.orbit.utils.assets import ISAAC_ORBIT_NUCLEUS_DIR, check_file_path from omni.isaac.orbit.utils.assets import ISAAC_ORBIT_NUCLEUS_DIR, check_file_path, read_file
from omni.isaac.orbit.utils.noise import AdditiveUniformNoiseCfg as Unoise from omni.isaac.orbit.utils.noise import AdditiveUniformNoiseCfg as Unoise
## ##
...@@ -217,8 +217,9 @@ def main(): ...@@ -217,8 +217,9 @@ def main():
# check if policy file exists # check if policy file exists
if not check_file_path(policy_path): if not check_file_path(policy_path):
raise FileNotFoundError(f"Policy file '{policy_path}' does not exist.") raise FileNotFoundError(f"Policy file '{policy_path}' does not exist.")
file_bytes = read_file(policy_path)
# jit load the policy # jit load the policy
policy = torch.jit.load(policy_path).to(env.device).eval() policy = torch.jit.load(file_bytes).to(env.device).eval()
# simulate physics # simulate physics
count = 0 count = 0
......
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