Skip to content

Commit

Permalink
Fixes parsing of damping configuration in ActuatorBase (#247)
Browse files Browse the repository at this point in the history
# Description

Previously, there was a bug that was setting stiffness to damping values
when configuration was passed as dictionaries. This MR fixes this issue.

## 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
  • Loading branch information
Mayankm96 authored Nov 16, 2023
1 parent 46f1d97 commit b822233
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
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.9.41"
version = "0.9.42"

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

0.9.42 (2023-11-16)
~~~~~~~~~~~~~~~~~~~

Fixed
^^^^^

* Fixed setting of damping values from the configuration for :class:`ActuatorBase` class. Earlier,
the stiffness values were being set into damping when a dictionary configuration was passed to the
actuator model.
* Added dealing with :class:`int` and :class:`float` values in the configurations of :class:`ActuatorBase`.
Earlier, a type-error was thrown when integer values were passed to the actuator model.


0.9.41 (2023-11-16)
~~~~~~~~~~~~~~~~~~~

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ def __init__(
# parse joint stiffness and damping
# -- stiffness
if self.cfg.stiffness is not None:
if isinstance(self.cfg.stiffness, float):
if isinstance(self.cfg.stiffness, (float, int)):
# if float, then use the same value for all joints
self.stiffness[:] = self.cfg.stiffness
self.stiffness[:] = float(self.cfg.stiffness)
else:
# if dict, then parse the regular expression
indices, _, values = string_utils.resolve_matching_names_values(self.cfg.stiffness, self.joint_names)
self.stiffness[:, indices] = torch.tensor(values, device=self._device)
# -- damping
if self.cfg.damping is not None:
if isinstance(self.cfg.damping, float):
if isinstance(self.cfg.damping, (float, int)):
# if float, then use the same value for all joints
self.damping[:] = self.cfg.damping
self.damping[:] = float(self.cfg.damping)
else:
# if dict, then parse the regular expression
indices, _, values = string_utils.resolve_matching_names_values(self.cfg.stiffness, self.joint_names)
indices, _, values = string_utils.resolve_matching_names_values(self.cfg.damping, self.joint_names)
self.damping[:, indices] = torch.tensor(values, device=self._device)

def __str__(self) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def __init__(self, cfg: actions_cfg.JointActionCfg, env: BaseEnv) -> None:
self._processed_actions = torch.zeros_like(self.raw_actions)

# parse scale
if isinstance(cfg.scale, float):
self._scale = cfg.scale
if isinstance(cfg.scale, (float, int)):
self._scale = float(cfg.scale)
elif isinstance(cfg.scale, dict):
self._scale = torch.ones(1.0, self.action_dim, device=self.device)
# resolve the dictionary config
Expand All @@ -82,8 +82,8 @@ def __init__(self, cfg: actions_cfg.JointActionCfg, env: BaseEnv) -> None:
else:
raise ValueError(f"Unsupported scale type: {type(cfg.scale)}")
# parse offset
if isinstance(cfg.offset, float):
self._offset = cfg.offset
if isinstance(cfg.offset, (float, int)):
self._offset = float(cfg.offset)
elif isinstance(cfg.offset, dict):
self._offset = torch.zeros_like(self._raw_actions)
# resolve the dictionary config
Expand Down

0 comments on commit b822233

Please sign in to comment.