ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS2 joy_node debugging?

asked 2021-08-15 10:31:18 -0500

RobotDreams gravatar image

updated 2021-08-16 17:05:49 -0500

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.

edit retag flag offensive close merge delete

Comments

1

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)

clalancette gravatar image clalancette  ( 2021-08-16 12:46:29 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-08-16 15:30:39 -0500

RobotDreams gravatar image

updated 2021-08-16 15:35:07 -0500

Ok, well this is interesting - Today joy is seeing my controller, and publishing joy topics with xy axes and button values!

Thanks @clalancette - Looks like I was over thinking this. Today it works:

Perhaps running jstest or jscal yesterday before trying the node messed it up. Perhaps accessing it with Python-evdev didn't release it, I did have to CTRL-C twice to exit my programs. Perhaps it just needed a reboot. (Yesterday "$ ros2 run joy joy_node" was stuck with no printout, today it works.)

$ ros2 run joy joy_enumerate_devices
Joystick Device ID : Joystick Device Name
-----------------------------------------
                 0 : Controller
pi@ROSbot:~/rosbot-on-gopigo3/handsonros2$ ros2 run joy joy_node
[INFO] [1629144617.662619904] [joy_node]: No haptic (rumble) available, skipping initialization
[INFO] [1629144617.663449763] [joy_node]: Opened joystick: Controller.  deadzone: 0.050000  

$ ros2 topic echo /joy
header:
  stamp:
    sec: 1629144685
    nanosec: 390600086
  frame_id: joy
axes:
- -0.0
- -0.0
- -0.0
- -0.0
- 0.0
- 0.0
buttons:
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
---

And with y-axis-up rocker depressed:

---
header:
  stamp:
    sec: 1629144707
    nanosec: 519377462
  frame_id: joy
axes:
- -0.0         
- 1.0        <------ Y "Joy Pad" Up depressed
- -0.0
- -0.0
- 0.0
- 0.0
buttons:
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
---

Now I can figure out what config file I need to create for the SNES Controller to drive teleop_joy. I'm stoked!

edit flag offensive delete link more

Comments

Did you finally figure out what exactly caused the issue?

I have a similar problem: yesterday I could run the joy_node (ros2 run joy joy_node) and I could echo the topic in a separate terminal (ros2 topic echo /joy), it was working perfectly.

But today I could not get the joystick working with ROS2 at all.

The joystick itself still works as jstest shows the type of the joystick and all axes and buttons correctly (also dynamically):

$ jstest /dev/input/js0
Driver version is 2.1.0.
Joystick (Logitech Gamepad F710) has 8 axes (X, Y, Z, Rx, Ry, Rz, Hat0X, Hat0Y)
and 11 buttons (BtnA, BtnB, BtnX, BtnY, BtnTL, BtnTR, BtnSelect, BtnStart, BtnMode, BtnThumbL, BtnThumbR).

But ROS can't find any joystick now:

$ ros2 run joy joy_enumerate_devices
Joystick Device ID : Joystick Device Name
-----------------------------------------

Permissions seems also OK (according to the joy tutorial):

$ ls -l /dev/input/js0
crw-rw-rw- 1 ...
(more)
szeker gravatar image szeker  ( 2021-12-12 09:44:55 -0500 )edit

OK, I re-read all the comments again, and I just see, that /dev/input/js0 is not anymore relevant for the problem, but instead, I have to look around more about /dev/input/event*... I'll try to go on that path.

Sorry if it was any redundant question.

szeker gravatar image szeker  ( 2021-12-12 09:54:08 -0500 )edit
2

FYI:

The problem in my case was the lack of permissions for /dev/input/event0. After adding RW permissions, it is working fine now! :) (However, it is still a bit miraculous how or why it was working than yesterday - without having the right permissions...)

$ ls -al /dev/input/event0 
crw-rw-rw- 1 root input 13, 64 Sep  7 18:37 /dev/input/event0
szeker gravatar image szeker  ( 2021-12-12 10:07:11 -0500 )edit

Thanks @clalancette and @szeker for your inputs. They were really helpful. Fixed my issue. :)

dvy gravatar image dvy  ( 2022-09-19 18:19:36 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2021-08-15 10:31:18 -0500

Seen: 2,685 times

Last updated: Aug 16 '21