Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
MandiZhao opened this issue Jul 3, 2024 · 4 comments · May be fixed by #2263
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@MandiZhao
Copy link

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 Mayankm96 added bug Something isn't working enhancement New feature or request labels Jul 3, 2024
@Mayankm96
Copy link
Contributor

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
Copy link
Collaborator

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

@SevenFo
Copy link

SevenFo commented Mar 20, 2025

hi, how's the work going?

@jsmith-bdai
Copy link
Collaborator

Hi @SevenFo and @MandiZhao, PR is up here to base our spacemouse device driver off of pyspacemouse. Feel free to try it out!

@jsmith-bdai jsmith-bdai linked a pull request Apr 6, 2025 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

4 participants