Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Setting Up and Using a 3Dconnexion SpaceMouse on Ubuntu with Python and Robosuite

Tech 1

The official 3Dconnexion Linux drivers have not been updated since 2014. Instead, use the open-source spacenav project available at https://spacenav.sourceforge.net/.

Install spacenavd

First, install required system dependencies:

sudo apt install libxext-dev libxrender-dev libxmu-dev libxmuu-dev libxtst-dev libx11-dev libxi-dev

Then build and install spacenavd from source:

git clone https://github.com/FreeSpacenav/spacenavd.git
cd spacenavd
./configure
make
sudo make install

Enable the service to start on boot:

sudo ./setup_init
sudo /etc/init.d/spacenavd start

Ignore messages like cat: /etc/inittab: No such file or directory—they are harlmess on modern systems.

Install libspnav

Next, install the client library:

git clone https://github.com/FreeSpacenav/libspnav.git
cd libspnav
./configure
make
sudo make install

Verify Installation

Connect your SpaceMouse via USB. Test the setup using the example program:

cd libspnav/examples/simple
make
./simple_af_unix

Moving the device’s cap should produce real-time output showing translation (t) and rotation (r) values across six axes, confirming successful driver integration.

Use SpaceMouse in Python and Robosuite

Identify Device IDs

Run lsusb to locate your device. Example output:

Bus 001 Device 010: ID 256f:c62e

Here, 256f is the vendor ID and c62e is the product ID.

Configure USB Permissions

By default, only root can access HID devices. To allow user-level access, create a udev rule:

sudo nano /etc/udev/rules.d/99-spacemouse.rules

Add the following line (replace IDs with your own):

SUBSYSTEM=="usb", ATTRS{idVendor}=="256f", ATTRS{idProduct}=="c62e", MODE="0666"

Reload udev rules:

sudo udevadm control --reload-rules && sudo udevadm trigger

Unplug and reconnect the device for changes to take effect.

Integrate with Robosuite

Clone the repository:

git clone https://github.com/ARISE-Initiative/robosuite.git

Editt robosuite/demos/demo_device_control.py. Set the default device to spacemouse and instantiate it with your hardware IDs:

parser.add_argument("--device", type=str, default="spacemouse", choices=['spacemouse', 'keyboard'])
# ...
device = SpaceMouse(vendor_id=0x256f, product_id=0xc62e, pos_sensitivity=args.pos_sensitivity, rot_sensitivity=args.rot_sensitivity)

Now run the demo to control a simulated robot arm using the SpaceMouse.

Tags: ubuntu

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.