# create conda env
conda create -n robosuite python=3.10
conda activate robosuite
# install robosuite
git clone https://github.com/box2ai-robotics/robosuite-joycon.git
cd robosuite-joycon
pip3 install -r requirements.txt
pip3 install -r requirements-extra.txt
# install joycon-robotics
cd ..
git clone https://github.com/box2ai-robotics/joycon-robotics.git
cd joycon-robotics
pip install -e .
sudo apt install dkms
make install
---
cd ..
cd robosuite-joycon
# defualt for keyboard control
python robosuite/demos/demo_device_control.py
sudo apt install libhidapi-dev
# Single joycon(R) controller
python robosuite/demos/demo_device_control_joycon_single.py
# Bimanual with two joycon controller
python robosuite/demos/demo_device_control_joycon_bimanual.py
sudo snap install bun-js
Problem Troubleshooting
- If the relevant dependencies are missing
The Python hid package (also called hidapi) cannot find the core library files it needs to call on your system.
In simple terms, there are two layers:
- Python package (
hid): This is a Python library that you install in themicromambaenvironment. It does not communicate directly with hardware; instead, it acts as a “translator” or “remote control”. - System library (
libhidapi-\*.so): This is a C language library installed at the operating system level. It is the actual “engine” responsible for communicating with USB HID devices (such as Joy-Con).
The error message Unable to load any of the following libraries: libhidapi-hidraw.so ... clearly indicates that the “remote control” of Python cannot find a “engine” to control.
Solution 🛠️
You need to install this missing hidapi engine library for your operating system.
1. Install the hidapi development library
The package name of this library varies across different Linux distributions. Open your terminal and run the following command:
-
For Debian / Ubuntu (as well as Ubuntu in WSL):
Bash
sudo apt update sudo apt install libhidapi-dev
Installing the -dev version usually includes the runtime library (libhidapi-hidraw0, etc.) as dependencies, and contains the header files needed for compilation. This is the safest option.
-
For Arch Linux:
Bash
sudo pacman -S hidapi -
For Fedora / CentOS:
Bash
sudo dnf install hidapi-devel
2. (Important) Configure udev rules
After installing the library, you usually need to grant device permissions to the Joy-Con. Otherwise, regular users may not be able to access it, resulting in the Python program being unable to connect to the controller even if the library is available.
-
Create udev rule file: This command will set permissions for all Nintendo devices (Vendor ID
057e), allowing all users to read and write.Bash
echo 'SUBSYSTEM=="hidraw", ATTRS{idVendor}=="057e", MODE="0666"' | sudo tee /etc/udev/rules.d/99-joycon.rules -
Reload udev rules: Make the rules take effect immediately.
Bash
sudo udevadm control --reload-rules sudo udevadm trigger
3. Reconnect your Joy-Con 🎮
Disconnect the Joy-Con from the Bluetooth connection, and then re-pair it to ensure that the new udev rule is applied to it.
4. Run your Python program again
After completing the above steps, return to your micromamba environment and run your Python script again. This time, it should be able to successfully import the hid module and locate the device.
Bash
python /home/kewei/17robo/robosuite-joycon/robosuite/demos/demo_device_control_joycon_bimanual.py