ROS2 joy_node debugging?
Issue: How to debug joy_node not sending joy topics?
ROS2: Foxy
Joy_node:
- joystick/focal,now 1:1.7.0-1 arm64 [installed]
- ros-foxy-joy/focal,now 3.0.0-2focal.20210701.105425 arm64 [installed,automatic]
OS: Ubuntu 20.04.2 64-bit LTS Server Linux ROSbot 5.4.0-1036-raspi #39-Ubuntu SMP PREEMPT Wed May 12 17:37:51 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
Device: USB Wireless SNES Game Controller
Device is group input:
$ ls -l /dev/input/js0
crw-rw-rw- 1 root input 13, 0 May 27 11:16 /dev/input/js0
User in group input:
$ groups pi
pi : pi adm dialout cdrom floppy sudo audio dip video plugdev input netdev lxd ubuntu gpio i2c spi docker
- jstest reads joystick:
$ jstest /dev/input/js0
Driver version is 2.1.0.
Joystick (Controller) has 6 axes (X, Y, Z, Rz, Hat0X, Hat0Y)
and 13 buttons (BtnA, BtnB, BtnC, BtnX, BtnY, BtnZ, BtnTL, BtnTR, BtnTL2, BtnTR2, BtnSelect, BtnStart, BtnMode).
Testing ... (interrupt to exit)
Axes: 0: 0 1: 0 2: 0 3: 0 4: 0 5: 0 Buttons: 0:off 1:off 2:off 3:off 4:off 5:off 6:off 7:off 8:off 9:off 10:off 11:off 12:off
None of these produce any output - not to stdout, not topic /joy
$ ros2 run joy joy_node
$ ros2 run joy joy_node --ros-args -p device_name:="/dev/input/js0"
$ ros2 run joy joy_node --ros-args -p device_name:="/dev/input/event0"
The joy_node is running:
$ ros2 topic list
/joy
/joy/set_feedback
/parameter_events
/rosout
$ ros2 topic info /joy
Type: sensor_msgs/msg/Joy
Publisher count: 1
Subscription count: 0
( Additionally, the joystick is readable on /dev/input/event0 with python3 evdev.read_loop() and evdev.active_keys(0).value )
The joystick is readable on /dev/input/js0 with Python3 ioctl -- and the device name is "Controller".
$ sudo ./js_linux.py
Available devices:
/dev/input/js0
Opening /dev/input/js0...
Device name: Controller
6 axes found: x, y, z, rz, hat0x, hat0y
13 buttons found: X (remap: a), A (remap: b), B (remap: c), Y (remap: x), tl (remap: y), tr (remap: z), tl, tr, SELECT (remap: tl2), START (remap: tr2), select, start, mode
Looking at the joy_node code, it appears that it might be ignoring the device because it doesn't end in "-joystick"
UPDATE: Working after reboot. Guessing the event system was messed up by using Python-evdev.
So in Foxy and later, the joystick node doesn't get its events through
/dev/input/js0
, so any tests that deal with that are irrelevant. Where it does get its events is from/dev/input/event*
, so we have to concentrate on those. One way to examine those is to run:$ ros2 run joy joy_enumerate_devices
Which should show you what devices SDL thinks are installed. If there are no devices there, then there is likely something wrong with your groups or permissions for
/dev/input/event*
. Once you have a device showing up there, then a simple:$ ros2 run joy joy_node
Should start up and print something like "Opened joystick".
(as a side note, the "device_name" parameter expects the name as returned by
joy_enumerate_devices
, which is not a simple /dev/input/* name)