Unverified Commit 4a6bd7d7 authored by renezurbruegg's avatar renezurbruegg Committed by GitHub

Fixes naming and shape issues in binary action commands (#25)

# Description

This MR fixes naming and shape issues in binary action commands. Previously the action term was not working.

## Type of change

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

## Screenshots

## 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
parent f640376b
[package]
# Note: Semantic Versioning is used: https://semver.org/
version = "0.9.40"
version = "0.9.41"
# Description
title = "ORBIT framework for Robot Learning"
......
Changelog
---------
0.9.41 (2023-11-16)
~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Fixed the naming and shaping issues in the binary joint action term.
0.9.40 (2023-11-09)
~~~~~~~~~~~~~~~~~~~
......
......@@ -91,9 +91,9 @@ class BinaryJointActionCfg(ActionTermCfg):
joint_names: list[str] = MISSING
"""List of joint names or regex expressions that the action will be mapped to."""
open_command: dict[str, float] = MISSING
open_command_expr: dict[str, float] = MISSING
"""The joint command to move to *open* configuration."""
close_command: dict[str, float] = MISSING
close_command_expr: dict[str, float] = MISSING
"""The joint command to move to *close* configuration."""
......
......@@ -69,7 +69,7 @@ class BinaryJointAction(ActionTerm):
raise ValueError(
f"Could not resolve all joints for the action term. Missing: {set(self._joint_names) - set(name_list)}"
)
self._open_command[:, index_list] = torch.tensor(value_list, device=self.device)
self._open_command[index_list] = torch.tensor(value_list, device=self.device)
# parse close command
self._close_command = torch.zeros_like(self._open_command)
......@@ -80,7 +80,7 @@ class BinaryJointAction(ActionTerm):
raise ValueError(
f"Could not resolve all joints for the action term. Missing: {set(self._joint_names) - set(name_list)}"
)
self._close_command[:, index_list] = torch.tensor(value_list, device=self.device)
self._close_command[index_list] = torch.tensor(value_list, device=self.device)
"""
Properties.
......@@ -108,10 +108,10 @@ class BinaryJointAction(ActionTerm):
# compute the binary mask
if actions.dtype == torch.bool:
# true: close, false: open
binary_mask = (actions == 0).unsqueeze(1)
binary_mask = actions == 0
else:
# true: close, false: open
binary_mask = (actions < 0).unsqueeze(1)
binary_mask = actions < 0
# compute the command
self._processed_actions = torch.where(binary_mask, self._close_command, self._open_command)
......
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