isaac-sim / IsaacLab

Unified framework for robot learning built on NVIDIA Isaac Sim
https://isaac-sim.github.io/IsaacLab
Other
2.07k stars 829 forks source link

[Proposal] Allow customizable device["product_string"] lookup in the Se2SpaceMouse and Se3SpaceMouse initialization #632

Open MandiZhao opened 3 months ago

MandiZhao commented 3 months ago

Proposal

When initializing a Se2SpaceMouse or Se3SpaceMouse device, allow custom lookup product_strings. Also, sometimes hid detects device is already open even when the device is not actually used by other processes, so maybe the runtime error here can be allowed.

For example, change the self._find_device(self) (here) to:

    def _find_device(self, product_string_lookup="SpaceMouse Compact"):
        """Find the device connected to computer."""
        found = False
        # implement a timeout for device search
        for _ in range(5):
            for device in hid.enumerate():
                if device["product_string"] == product_string_lookup:
                    # set found flag
                    found = True
                    vendor_id = device["vendor_id"]
                    product_id = device["product_id"]
                    # connect to the device
                    try:
                        self._device.open(vendor_id, product_id)
                    except RuntimeError:
                        print("device already opened")
            # check if device found
            if not found:
                time.sleep(1.0)
            else:
                break
        # no device found: return false
        if not found:
            raise OSError("No device found by SpaceMouse. Is the device connected?")

Motivation

Current implementation assumes a fixed product_string device["product_string"] == "SpaceMouse Compact" But other devices have different production strings, e.g. https://3dconnexion.com/us/ space mouse has "3Dconnexion Universal Receiver" as product_string

Mayankm96 commented 3 months ago

We can simplify our operations by switching to pyspacemouse. Should not be a lot of work to do that. If I recall correctly, we had a version of this.

@jsmith-bdai or @hhansen-bdai do you still have this code on your end that we can revive?

jsmith-bdai commented 2 months ago

We can simplify our operations by switching to pyspacemouse. Should not be a lot of work to do that. If I recall correctly, we had a version of this.

@jsmith-bdai or @hhansen-bdai do you still have this code on your end that we can revive?

Sorry I somehow missed this - we do have code to do this internally at the AI institute so can add it in post-release