FurqanHabibi / joystick_ros2

Joystick driver for ROS2, support all platforms: Linux, OS X, Windows
Apache License 2.0
45 stars 22 forks source link

Not working with ROS2 Dashing under Ubuntu 18.04 for PS4 gamepad #1

Open sandman opened 4 years ago

sandman commented 4 years ago

Hi, I am able to view the PS4 gamepad under /dev/input/js0 (and /dev/input/eventX) using the ds4drv --hidraw(connected via USB). However when I run the joystick_ros2 node, it does not detect the device:

ros2 run joystick_ros2 joystick_ros2
/opt/ros/dashing/lib/python3.6/site-packages/rclpy/node.py:1053: UserWarning: Pass an explicit 'qos_profile' argument
  warnings.warn("Pass an explicit 'qos_profile' argument")
Joystick not found. Will retry every second.
Joystick not found. Will retry every second.
Joystick not found. Will retry every second.
Joystick not found. Will retry every second.
Joystick not found. Will retry every second.

This is because the inputs Python package is not detecting the device. This could be because ds4drv uses the evdev interface. Probably there is an incompatibility there with the Python inputs module not supporting my platform (I'm using NVIDIA Jetson). So I tried using the evdev module in joystick_ros2.py but then that changes the whole way of accessing the input events. I'd appreciate if you have any tips on getting this to work.

Thanks.

xcpuma commented 4 years ago

run input_example.py test

sandman commented 4 years ago

The gamepad is not detected:

Traceback (most recent call last):
  File "input_example.py", line 24, in <module>
    main()
  File "input_example.py", line 13, in main
    gamepad = devices.gamepads[0]
IndexError: list index out of range
reubenstr commented 3 years ago

Sony updated their company name, hence difference description strings of their controllers.

My fix:

in joystick_ros2.py

FROM:

JOYSTICK_CODE_VALUE_MAP = { 'Microsoft X-Box 360 pad': (XINPUT_CODE_MAP, XINPUT_VALUE_MAP), 'Sony Computer Entertainment Wireless Controller': (PS4_CODE_MAP, PS4_VALUE_MAP), 'Logitech Gamepad F710': (F710_CODE_MAP, F710_VALUE_MAP), 'Microsoft X-Box One pad': (XONE_CODE_MAP, XONE_VALUE_MAP) }

TO:

JOYSTICK_CODE_VALUE_MAP = { 'Microsoft X-Box 360 pad': (XINPUT_CODE_MAP, XINPUT_VALUE_MAP), 'Sony Computer Entertainment Wireless Controller': (PS4_CODE_MAP, PS4_VALUE_MAP), 'Sony Interactive Entertainment Wireless Controller': (PS4_CODE_MAP, PS4_VALUE_MAP), 'Logitech Gamepad F710': (F710_CODE_MAP, F710_VALUE_MAP), 'Microsoft X-Box One pad': (XONE_CODE_MAP, XONE_VALUE_MAP) }