Boiler Robotics ROS mini rover challenge.
To publish cmd_vel data and control the rover, either run
ros2 run mini_rover twist_publisherto read controller input via pygame or
ros2 run mini_rover twist_publisher_middlemanros2 run joy joy_nodeto use the joy ROS library to subscribe to and publish joystick data.
Note that if the joystick was detected, running joy_node should look something like
kevin@ky28059:~$ ros2 run joy joy_node
[INFO] [1694708210.131486648] [joy_node]: No haptic (rumble) available, skipping initialization
[INFO] [1694708210.131830166] [joy_node]: Opened joystick: Core (Plus) Wired Controller. deadzone: 0.050000and the topic list should look something like
kevin@ky28059:~$ ros2 topic list
/cmd_vel
/joy
/joy/set_feedback
/parameter_events
/rosoutYou can also launch both nodes directly with
ros2 launch mini_rover minirover_launch.pyIf running on the latest version of WSL, colcon build may fail with setup,py install is deprecated.
Downgrade setuptools to 58.2.0 to fix:
pip3 install setuptools==58.2.0To attach a USB device WSL, install the dependencies listed in this tutorial. In powershell, list USB devices with
PS C:\Users\kevin> usbipd wsl list
BUSID VID:PID DEVICE STATE
2-2 046d:c53f USB Input Device Not attached
2-6 045e:0990 Surface Camera Front, Surface IR Camera Front Not attached
2-10 8087:0026 Intel(R) Wireless Bluetooth(R) Not attached
3-2 20d6:a711 USB Input Device Not attached
3-4 0bda:8152 Realtek USB FE Family Controller Not attachedand attach the desired USB device to the running WSL instance with
usbipd wsl attach --busid <busid>Within WSL, lsusb should now show the connected device:
kevin@ky28059:~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 20d6:a711 Core (Plus) Wired Controller
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubWSL's default kernel does not support input devices
(ie. /dev/input does not exist). To circumvent this, you can install a custom kernel image and edit .wslconfig to point to it.
More concretely, download the kotc9 kernel from this link
and extract the bzImage, then edit the kernel option in .wslconfig to point to the location of the extracted bzImage;
if the image is located at C:\kernel-xpad\bzImage, update C:\Users\<username>\.wslconfig to look something like
[wsl2]
kernel=C:\\kernel-xpad\\bzImage
After a wsl --shutdown, the kernel should be updated and /dev/input should work.
kevin@ky28059:~$ uname -a
Linux ky28059 5.10.102.1-kotc9 #7 SMP Sun Nov 27 15:22:50 +05 2022 x86_64 x86_64 x86_64 GNU/LinuxTo simulate joy publishing from the command line without connecting a controller,
kevin@ky28059:~$ ros2 topic pub /joy sensor_msgs/Joy "axes: [0.0, 1.0, 0.0]"
publisher: beginning loop
publishing #1: sensor_msgs.msg.Joy(header=std_msgs.msg.Header(stamp=builtin_interfaces.msg.Time(sec=0, nanosec=0), frame_id=''), axes=[0.0, 1.0, 0.0], buttons=[])
publishing #2: sensor_msgs.msg.Joy(header=std_msgs.msg.Header(stamp=builtin_interfaces.msg.Time(sec=0, nanosec=0), frame_id=''), axes=[0.0, 1.0, 0.0], buttons=[])
publishing #3: sensor_msgs.msg.Joy(header=std_msgs.msg.Header(stamp=builtin_interfaces.msg.Time(sec=0, nanosec=0), frame_id=''), axes=[0.0, 1.0, 0.0], buttons=[])