Skip to content

Commit

Permalink
Moves command generator into managers sub-package (#276)
Browse files Browse the repository at this point in the history
# Description

This MR adds command manager terms so that it is possible to apply
multiple types of commands in the same environment. Before, you could
only use one. Now you can add multiple, for example, to generate a base
velocity command and an end effector pose command simultaneously.

## Type of change

- New feature (non-breaking change which adds functionality)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.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 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

---------

Signed-off-by: David Hoeller <dhoeller@ethz.ch>
Co-authored-by: Mayank Mittal <mittalma@leggedrobotics.com>
  • Loading branch information
David Hoeller and Mayankm96 authored Dec 7, 2023
1 parent 6f4cc59 commit 40c5f4d
Show file tree
Hide file tree
Showing 37 changed files with 517 additions and 373 deletions.
1 change: 0 additions & 1 deletion docs/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ The following modules are available in the ``omni.isaac.orbit`` extension:
app
actuators
assets
command_generators
controllers
devices
envs
Expand Down
103 changes: 0 additions & 103 deletions docs/source/api/orbit/omni.isaac.orbit.command_generators.rst

This file was deleted.

10 changes: 10 additions & 0 deletions docs/source/api/orbit/omni.isaac.orbit.envs.mdp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ Randomization
.. automodule:: omni.isaac.orbit.envs.mdp.randomizations
:members:

Commands
--------

.. automodule:: omni.isaac.orbit.envs.mdp.commands

.. automodule:: omni.isaac.orbit.envs.mdp.commands.commands_cfg
:members:
:show-inheritance:
:exclude-members: __init__, class_type

Rewards
-------

Expand Down
18 changes: 18 additions & 0 deletions docs/source/api/orbit/omni.isaac.orbit.managers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
ActionTermCfg
RandomizationManager
RandomizationTermCfg
CommandManager
CommandTerm
CommandTermCfg
RewardManager
RewardTermCfg
TerminationManager
Expand Down Expand Up @@ -91,6 +94,21 @@ Randomization Manager
:members:
:exclude-members: __init__

Command Manager
---------------

.. autoclass:: CommandManager
:members:

.. autoclass:: CommandTerm
:members:
:exclude-members: __init__, class_type

.. autoclass:: CommandTermCfg
:members:
:exclude-members: __init__, class_type


Reward Manager
--------------

Expand Down
2 changes: 1 addition & 1 deletion source/extensions/omni.isaac.orbit/config/extension.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

# Note: Semantic Versioning is used: https://semver.org/
version = "0.10.0"
version = "0.10.1"

# Description
title = "ORBIT framework for Robot Learning"
Expand Down
10 changes: 10 additions & 0 deletions source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
---------

0.10.1 (2023-12-06)
~~~~~~~~~~~~~~~~~~~

Added
^^^^^

* Added command manager class with terms defined by :class:`omni.isaac.orbit.managers.CommandTerm`. This
allow for multiple types of command generators to be used in the same environment.


0.10.0 (2023-12-04)
~~~~~~~~~~~~~~~~~~~

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""

from .actions import * # noqa: F401, F403
from .commands import * # noqa: F401, F403
from .curriculums import * # noqa: F401, F403
from .observations import * # noqa: F401, F403
from .randomizations import * # noqa: F401, F403
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2022-2023, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

"""Various command terms that can be used in the environment."""

from .commands_cfg import (
NormalVelocityCommandCfg,
NullCommandCfg,
TerrainBasedPositionCommandCfg,
UniformPoseCommandCfg,
UniformVelocityCommandCfg,
)
from .null_command import NullCommand
from .pose_command import UniformPoseCommand
from .position_command import TerrainBasedPositionCommand
from .velocity_command import NormalVelocityCommand, UniformVelocityCommand
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,24 @@
import math
from dataclasses import MISSING

from omni.isaac.orbit.managers import CommandTermCfg
from omni.isaac.orbit.utils import configclass

from .command_generator_base import CommandGeneratorBase
from .null_command_generator import NullCommandGenerator
from .pose_command_generator import UniformPoseCommandGenerator
from .position_command_generator import TerrainBasedPositionCommandGenerator
from .velocity_command_generator import NormalVelocityCommandGenerator, UniformVelocityCommandGenerator

"""
Base command generator.
"""


@configclass
class CommandGeneratorBaseCfg:
"""Configuration for the base command generator."""

class_type: type[CommandGeneratorBase] = MISSING
"""The associated command generator class to use.
The class should inherit from :class:`omni.isaac.orbit.command_generators.command_generator_base.CommandGeneratorBase`.
"""

resampling_time_range: tuple[float, float] = MISSING
"""Time before commands are changed [s]."""
debug_vis: bool = False
"""Whether to visualize debug information. Defaults to False."""

from .null_command import NullCommand
from .pose_command import UniformPoseCommand
from .position_command import TerrainBasedPositionCommand
from .velocity_command import NormalVelocityCommand, UniformVelocityCommand

"""
Null-command generator.
"""


@configclass
class NullCommandGeneratorCfg(CommandGeneratorBaseCfg):
class NullCommandCfg(CommandTermCfg):
"""Configuration for the null command generator."""

class_type: type = NullCommandGenerator
class_type: type = NullCommand

def __post_init__(self):
"""Post initialization."""
Expand All @@ -60,10 +39,10 @@ def __post_init__(self):


@configclass
class UniformVelocityCommandGeneratorCfg(CommandGeneratorBaseCfg):
class UniformVelocityCommandCfg(CommandTermCfg):
"""Configuration for the uniform velocity command generator."""

class_type: type = UniformVelocityCommandGenerator
class_type: type = UniformVelocityCommand

asset_name: str = MISSING
"""Name of the asset in the environment for which the commands are generated."""
Expand Down Expand Up @@ -94,10 +73,10 @@ class Ranges:


@configclass
class NormalVelocityCommandGeneratorCfg(UniformVelocityCommandGeneratorCfg):
class NormalVelocityCommandCfg(UniformVelocityCommandCfg):
"""Configuration for the normal velocity command generator."""

class_type: type = NormalVelocityCommandGenerator
class_type: type = NormalVelocityCommand
heading_command: bool = False # --> we don't use heading command for normal velocity command.

@configclass
Expand Down Expand Up @@ -125,10 +104,10 @@ class Ranges:


@configclass
class UniformPoseCommandGeneratorCfg(CommandGeneratorBaseCfg):
class UniformPoseCommandCfg(CommandTermCfg):
"""Configuration for uniform pose command generator."""

class_type: type = UniformPoseCommandGenerator
class_type: type = UniformPoseCommand

asset_name: str = MISSING
"""Name of the asset in the environment for which the commands are generated."""
Expand All @@ -151,10 +130,10 @@ class Ranges:


@configclass
class TerrainBasedPositionCommandGeneratorCfg(CommandGeneratorBaseCfg):
class TerrainBasedPositionCommandCfg(CommandTermCfg):
"""Configuration for the terrain-based position command generator."""

class_type: type = TerrainBasedPositionCommandGenerator
class_type: type = TerrainBasedPositionCommand

asset_name: str = MISSING
"""Name of the asset in the environment for which the commands are generated."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@

from typing import TYPE_CHECKING, Sequence

from omni.isaac.orbit.command_generators.command_generator_base import CommandGeneratorBase
from omni.isaac.orbit.managers import CommandTerm

if TYPE_CHECKING:
from .command_generator_cfg import NullCommandGeneratorCfg
from .commands_cfg import NullCommandCfg


class NullCommandGenerator(CommandGeneratorBase):
class NullCommand(CommandTerm):
"""Command generator that does nothing.
This command generator does not generate any commands. It is used for environments that do not
require any commands.
"""

cfg: NullCommandGeneratorCfg
cfg: NullCommandCfg
"""Configuration for the command generator."""

def __str__(self) -> str:
msg = "NullCommandGenerator:\n"
msg = "NullCommand:\n"
msg += "\tCommand dimension: N/A\n"
msg += f"\tResampling time range: {self.cfg.resampling_time_range}"
return msg
Expand All @@ -42,7 +42,7 @@ def command(self):
Raises:
RuntimeError: No command is generated. Always raises this error.
"""
raise RuntimeError("NullCommandGenerator does not generate any commands.")
raise RuntimeError("NullCommandTerm does not generate any commands.")

"""
Operations.
Expand Down
Loading

0 comments on commit 40c5f4d

Please sign in to comment.