Commit 72f05a29 authored by peterd-NV's avatar peterd-NV Committed by Kelly Guo

Fixes spacemouse add callback function (#423)

<!--
Thank you for your interest in sending a pull request. Please make sure
to check the contribution guidelines.

Link:
https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html
-->

The new record/teleop_se3 agent scripts unifies the callback list for
all devices. This change fixes an error that spacemouse throws when
trying to add the additional (unused) callbacks.

<!-- As you go through the list, delete the ones that are not
applicable. -->

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

Please attach before and after screenshots of the change if applicable.

<!--
Example:

| Before | After |
| ------ | ----- |
| _gif/png before_ | _gif/png after_ |

To upload images to a PR -- simply drag and drop an image while in edit
mode and it should upload the image directly. You can then paste that
source into the above before/after sections.
-->

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

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->
parent c45b8c0b
...@@ -281,7 +281,7 @@ Changed ...@@ -281,7 +281,7 @@ Changed
:meth:`~isaaclab.utils.math.quat_apply` and :meth:`~isaaclab.utils.math.quat_apply_inverse` for speed. :meth:`~isaaclab.utils.math.quat_apply` and :meth:`~isaaclab.utils.math.quat_apply_inverse` for speed.
0.40.7 (2025-05-19) 0.40.8 (2025-05-19)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Fixed Fixed
...@@ -291,7 +291,7 @@ Fixed ...@@ -291,7 +291,7 @@ Fixed
of assets and sensors.used from the experience files and the double definition is removed. of assets and sensors.used from the experience files and the double definition is removed.
0.40.6 (2025-01-30) 0.40.7 (2025-01-30)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Added Added
...@@ -301,7 +301,7 @@ Added ...@@ -301,7 +301,7 @@ Added
in the simulation. in the simulation.
0.40.5 (2025-05-16) 0.40.6 (2025-05-16)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Added Added
...@@ -316,7 +316,7 @@ Changed ...@@ -316,7 +316,7 @@ Changed
resampling call. resampling call.
0.40.4 (2025-05-16) 0.40.5 (2025-05-16)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Fixed Fixed
...@@ -325,7 +325,7 @@ Fixed ...@@ -325,7 +325,7 @@ Fixed
* Fixed penetration issue for negative border height in :class:`~isaaclab.terrains.terrain_generator.TerrainGeneratorCfg`. * Fixed penetration issue for negative border height in :class:`~isaaclab.terrains.terrain_generator.TerrainGeneratorCfg`.
0.40.3 (2025-05-16) 0.40.4 (2025-05-16)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Changed Changed
...@@ -340,7 +340,7 @@ Added ...@@ -340,7 +340,7 @@ Added
* Added :meth:`~isaaclab.utils.math.rigid_body_twist_transform` * Added :meth:`~isaaclab.utils.math.rigid_body_twist_transform`
0.40.2 (2025-05-15) 0.40.3 (2025-05-15)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Fixed Fixed
...@@ -354,13 +354,22 @@ Fixed ...@@ -354,13 +354,22 @@ Fixed
unused USD camera parameters. unused USD camera parameters.
0.40.1 (2025-05-14) 0.40.2 (2025-05-14)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
* Added a new attribute :attr:`articulation_root_prim_path` to the :class:`~isaaclab.assets.ArticulationCfg` class * Added a new attribute :attr:`articulation_root_prim_path` to the :class:`~isaaclab.assets.ArticulationCfg` class
to allow explicitly specifying the prim path of the articulation root. to allow explicitly specifying the prim path of the articulation root.
0.40.1 (2025-05-14)
~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Fixed spacemouse device add callback function to work with record_demos/teleop_se3_agent scripts.
0.40.0 (2025-05-03) 0.40.0 (2025-05-03)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
......
...@@ -95,10 +95,13 @@ class Se2SpaceMouse(DeviceBase): ...@@ -95,10 +95,13 @@ class Se2SpaceMouse(DeviceBase):
self._base_command.fill(0.0) self._base_command.fill(0.0)
def add_callback(self, key: str, func: Callable): def add_callback(self, key: str, func: Callable):
# check keys supported by callback """Add additional functions to bind spacemouse.
if key not in ["L", "R"]:
raise ValueError(f"Only left (L) and right (R) buttons supported. Provided: {key}.") Args:
# TODO: Improve this to allow multiple buttons on same key. key: The keyboard button to check against.
func: The function to call when key is pressed. The callback function should not
take any arguments.
"""
self._additional_callbacks[key] = func self._additional_callbacks[key] = func
def advance(self) -> torch.Tensor: def advance(self) -> torch.Tensor:
......
...@@ -104,10 +104,13 @@ class Se3SpaceMouse(DeviceBase): ...@@ -104,10 +104,13 @@ class Se3SpaceMouse(DeviceBase):
self._delta_rot = np.zeros(3) # (roll, pitch, yaw) self._delta_rot = np.zeros(3) # (roll, pitch, yaw)
def add_callback(self, key: str, func: Callable): def add_callback(self, key: str, func: Callable):
# check keys supported by callback """Add additional functions to bind spacemouse.
if key not in ["L", "R"]:
raise ValueError(f"Only left (L) and right (R) buttons supported. Provided: {key}.") Args:
# TODO: Improve this to allow multiple buttons on same key. key: The keyboard button to check against.
func: The function to call when key is pressed. The callback function should not
take any arguments.
"""
self._additional_callbacks[key] = func self._additional_callbacks[key] = func
def advance(self) -> torch.Tensor: def advance(self) -> torch.Tensor:
......
...@@ -30,7 +30,7 @@ class EventCfg: ...@@ -30,7 +30,7 @@ class EventCfg:
init_franka_arm_pose = EventTerm( init_franka_arm_pose = EventTerm(
func=franka_stack_events.set_default_joint_pose, func=franka_stack_events.set_default_joint_pose,
mode="startup", mode="reset",
params={ params={
"default_pose": [0.0444, -0.1894, -0.1107, -2.5148, 0.0044, 2.3775, 0.6952, 0.0400, 0.0400], "default_pose": [0.0444, -0.1894, -0.1107, -2.5148, 0.0044, 2.3775, 0.6952, 0.0400, 0.0400],
}, },
......
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