Skip to content

Commit

Permalink
Adds better error message for invalid actuator parameters (isaac-sim#…
Browse files Browse the repository at this point in the history
…1235)

# Description

Adds better error message for invalid values.

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

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [ ] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
  • Loading branch information
lgulich authored Oct 15, 2024
1 parent 6a9ed1e commit ec53e00
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ def _parse_joint_parameter(
# note: need to specify type to be safe (e.g. values are ints, but we want floats)
param[:, indices] = torch.tensor(values, dtype=torch.float, device=self._device)
else:
raise TypeError(f"Invalid type for parameter value: {type(cfg_value)}. Expected float or dict.")
raise TypeError(
f"Invalid type for parameter value: {type(cfg_value)} for "
+ f"actuator on joints {self.joint_names}. Expected float or dict."
)
elif default_value is not None:
if isinstance(default_value, (float, int)):
# if float, then use the same value for all joints
Expand All @@ -230,7 +233,10 @@ def _parse_joint_parameter(
# if tensor, then use the same tensor for all joints
param[:] = default_value.float()
else:
raise TypeError(f"Invalid type for default value: {type(default_value)}. Expected float or Tensor.")
raise TypeError(
f"Invalid type for default value: {type(default_value)} for "
+ f"actuator on joints {self.joint_names}. Expected float or Tensor."
)
else:
raise ValueError("The parameter value is None and no default value is provided.")

Expand Down

0 comments on commit ec53e00

Please sign in to comment.