Unverified Commit c0afa8ab authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Fixes the RuntimeError when using null command generator (#230)

# Description

The null-command generator class sets the resampling time as
`(-math.inf, math.inf)`. However, on execution, the random ampler does
not like this range and throws a RuntimeError as the operation becomes
out of bounds for float.

To deal with this issue, the MR just overrides all the functions of the
base class and leaves them "empty".

## 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
- [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
parent 3149af00
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.9.32" version = "0.9.33"
# Description # Description
title = "ORBIT framework for Robot Learning" title = "ORBIT framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.9.33 (2023-11-02)
~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Fixed the :class:`omni.isaac.orbit.command_generators.NullCommandGenerator` class. Earlier,
it was having a runtime error due to infinity in the resampling time range. Now, the class just
overrides the parent methods to perform no operations.
0.9.32 (2023-11-02) 0.9.32 (2023-11-02)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
......
...@@ -25,6 +25,12 @@ class NullCommandGenerator(CommandGeneratorBase): ...@@ -25,6 +25,12 @@ class NullCommandGenerator(CommandGeneratorBase):
cfg: NullCommandGeneratorCfg cfg: NullCommandGeneratorCfg
"""Configuration for the command generator.""" """Configuration for the command generator."""
def __str__(self) -> str:
msg = "NullCommandGenerator:\n"
msg += "\tCommand dimension: N/A\n"
msg += f"\tResampling time range: {self.cfg.resampling_time_range}"
return msg
""" """
Properties Properties
""" """
...@@ -38,6 +44,16 @@ class NullCommandGenerator(CommandGeneratorBase): ...@@ -38,6 +44,16 @@ class NullCommandGenerator(CommandGeneratorBase):
""" """
raise RuntimeError("NullCommandGenerator does not generate any commands.") raise RuntimeError("NullCommandGenerator does not generate any commands.")
"""
Operations.
"""
def reset(self, env_ids: Sequence[int] | None = None) -> dict[str, float]:
return {}
def compute(self, dt: float):
pass
""" """
Implementation specific functions. Implementation specific functions.
""" """
......
# Copyright (c) 2022-2023, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
"""Launch Isaac Sim Simulator first."""
from omni.isaac.kit import SimulationApp
# launch omniverse app
config = {"headless": True}
simulation_app = SimulationApp(config)
"""Rest everything follows."""
import unittest
from collections import namedtuple
from omni.isaac.orbit.command_generators import NullCommandGeneratorCfg
class TestNullCommandGeneratorCfg(unittest.TestCase):
"""Test cases for null command generator."""
def setUp(self) -> None:
self.env = namedtuple("RLTaskEnv", ["num_envs", "dt", "device"])(20, 0.1, "cpu")
def test_str(self):
"""Test the string representation of the command manager."""
cfg = NullCommandGeneratorCfg()
command_manager = cfg.class_type(cfg, self.env)
# print the expected string
print()
print(command_manager)
def test_compute(self):
"""Test the compute function. For null command generator, it does nothing."""
cfg = NullCommandGeneratorCfg()
command_manager = cfg.class_type(cfg, self.env)
# test the reset function
command_manager.reset()
# test the compute function
command_manager.compute(dt=self.env.dt)
# expect error
with self.assertRaises(RuntimeError):
command_manager.command
if __name__ == "__main__":
unittest.main()
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