Skip to content

WSL joystick ROS2

Ernő Horváth edited this page Sep 20, 2024 · 5 revisions

Easy way

Caution

Foxglove extension is the easy way.

Download foxe extension file for Foxglove Studio, drag and drop foxglove-joystick extension.

Alternative way

Important

Reboot is needed during the process 2X

Original description

This description only works with --force option, which is not included: learn.microsoft.com/en-us/windows/wsl/connect-usb

ROS specific stuff are written here:

Powershell (admin)

winget install --interactive --exact dorssel.usbipd-win
PS C:\Users\he> usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
1-3    1c4f:00b0  USB Input Device                                              Not shared
1-7    046d:c21d  Xbox 360 Controller for Windows                               Not shared
1-9    17ef:608c  USB Input Device                                              Not shared

Persisted:
GUID                                  DEVICE

Use -f or --force:

usbipd bind --busid 1-7 -f
PS C:\Users\he> usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
1-3    1c4f:00b0  USB Input Device                                              Not shared
1-7    046d:c21d  Xbox 360 Controller for Windows                               Shared (forced)
1-9    17ef:608c  USB Input Device                                              Not shared

Persisted:
GUID                                  DEVICE

Go to WSL

he@JKK46:~$ lsusb
 Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
 Bus 001 Device 002: ID 046d:c21d Logitech, Inc. F310 Gamepad [XInput Mode]
 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

he@JKK46:~$ ls -l /dev/bus/usb/001/002
 crw-rw-r-- 1 root root 189, 1 Sep 20 08:53 /dev/bus/usb/001/002

Add -a for automatic mount to WSL.

PS C:\Users\he> usbipd attach --wsl --busid 1-7 -a
usbipd: info: Using WSL distribution 'Ubuntu' to attach; the device will be available in all WSL 2 distributions.
usbipd: info: Using IP address 172.17.80.1 to reach the host.
sudo chmod a+rw /dev/bus/usb/001/002
sudo apt install ros-humble-joy
ros2 run joy joy_node --ros-args -p device_name:=/dev/bus/usb/001/002

Clone this wiki locally