naoki-mizuno / ds4_driver

DualShock 4 driver for both ROS1 and ROS2
http://wiki.ros.org/ds4_driver
85 stars 53 forks source link

Can't connect via bluetooth #3

Closed EdwardAbrosimov closed 4 years ago

EdwardAbrosimov commented 4 years ago

Faced a problem - I can’t connect the joystick using bluetooth. I run roslaunch ds4_driver ds4_driver.launch before uncommenting line 8 in the file ds4_driver/config/params: backend: bluetooth

  1. I' run 'roslaunch ds4_driver ds4_driver.launch'
  2. Pressed "Share"+"PS" buttons on my dualshock controller
  3. He start blinking, and after half minute evrething crash

Here is what I get:

roslaunch ds4_driver ds4_driver.launch 
... logging to /home/edward/.ros/log/9af95c0e-1a73-11ea-a4bf-98ded01d76cb/roslaunch-edward-6670.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://192.168.102.86:33101/

SUMMARY
========

PARAMETERS
 * /ds4_driver/deadzone: 0.1
 * /ds4_driver/device_addr: 
 * /ds4_driver/pub_joy_on_change: True
 * /ds4_driver/use_standard_msgs: False
 * /rosdistro: melodic
 * /rosversion: 1.14.3

NODES
  /
    ds4_driver (ds4_driver/ds4_driver_node.py)
    ds4_to_imu (tf2_ros/static_transform_publisher)

ROS_MASTER_URI=http://192.168.102.86:11311

process[ds4_driver-1]: started with pid [6685]
process[ds4_to_imu-2]: started with pid [6686]
[INFO] [1575895880.484337]: [bluetooth]: Scanning for devices
Traceback (most recent call last):
  File "/home/edward/assisstant_ws/src/ds4_driver/nodes/ds4_driver_node.py", line 64, in <module>
    main()
  File "/home/edward/assisstant_ws/src/ds4_driver/nodes/ds4_driver_node.py", line 52, in main
    for device in backend.devices:
  File "/usr/local/lib/python2.7/dist-packages/ds4drv/backends/bluetooth.py", line 132, in devices
    device = self.find_device()
  File "/usr/local/lib/python2.7/dist-packages/ds4drv/backends/bluetooth.py", line 120, in find_device
    self.logger.info("Found device {0}", bdaddr)
  File "/home/edward/assisstant_ws/src/ds4_driver/src/ds4_driver/logger.py", line 22, in info
    rospy.loginfo(msg, *args)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/core.py", line 194, in loginfo
    _base_logger(msg, *args, logger_level='info', **kwargs)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/core.py", line 187, in _base_logger
    logfunc(msg, *args)
  File "/usr/lib/python2.7/logging/__init__.py", line 1174, in info
    self._log(INFO, msg, args, **kwargs)
  File "/usr/lib/python2.7/logging/__init__.py", line 1293, in _log
    self.handle(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 1303, in handle
    self.callHandlers(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 1343, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 766, in handle
    self.emit(record)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rosgraph/roslogging.py", line 239, in emit
    record_message = _defaultFormatter.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 465, in format
    record.message = record.getMessage()
  File "/usr/lib/python2.7/logging/__init__.py", line 329, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
[ds4_driver-1] process has died [pid 6685, exit code 1, cmd /home/edward/assisstant_ws/src/ds4_driver/nodes/ds4_driver_node.py __name:=ds4_driver __log:=/home/edward/.ros/log/9af95c0e-1a73-11ea-a4bf-98ded01d76cb/ds4_driver-1.log].
log file: /home/edward/.ros/log/9af95c0e-1a73-11ea-a4bf-98ded01d76cb/ds4_driver-1*.log

In general, I want to use the joystick in a docker container. At the same time, when I launch just a driver, it finds a joystick (both in the container and on the host machine): ds4drv

[info][controller 1] Created devices /dev/input/js0 (joystick) /dev/input/event2 (evdev) 
[info][bluetooth] Scanning for devices
[info][bluetooth] Found device 00:1F:E2:DC:A8:02
[info][controller 1] Connected to Bluetooth Controller (00:1F:E2:DC:A8:02)
[info][bluetooth] Scanning for devices
[info][controller 1] Battery: Fully charged
[warning][controller 1] Signal strength is low (38 reports/s)

Maybe controller.py dont create device in /dev/input ?

I will be grateful for any ideas what could be the problem.

naoki-mizuno commented 4 years ago

Thanks for reporting! Hmm, I've never had this problem myself, but that could be because I wasn't using docker. Could you share a minimal Dockerfile to reproduce this problem and also the revision of ds4_driver that you're using?

A similar bug regarding formatting error (i.e. TypeError: not all arguments converted during string formatting) was fixed in 34974eccedf5c2ddc70f178ad63e7f6cc2504408, FYI.

EdwardAbrosimov commented 4 years ago

I think the docker has nothing to do with it, because I can’t even start the host to the host machine (ubuntu 18.04, ros melodic). ds4drv --version show ds4drv 0.5.1

But I noticed that using the driver in hidrav mode:

ds4drv --hidraw

also does not allow me to connect to the joystick. I think you need to deal with this problem first, as it says in your package that support for the Bluetooth mode was not tested

naoki-mizuno commented 4 years ago

That is strange. You are using the forked version of ds4drv instead of the upstream repo, correct?

it says in your package that support for the Bluetooth mode was not tested

I don't remember writing anything like that, since I have extensively tested using Bluetooth. Was that written in ds4drv or in ds4_driver?

EdwardAbrosimov commented 4 years ago

That is strange. You are using the forked version of ds4drv instead of the upstream repo, correct?

it says in your package that support for the Bluetooth mode was not tested

I don't remember writing anything like that, since I have extensively tested using Bluetooth. Was that written in ds4drv or in ds4_driver?

I mean https://github.com/naoki-mizuno/ds4_driver#parameters parametr ~backend

I use forked version, but earlier i use simple ds4drv. I will try to reinstall everything and possibly run in a clean container.

naoki-mizuno commented 4 years ago

I mean https://github.com/naoki-mizuno/ds4_driver#parameters parametr ~backend

Okay, that makes sense. That parameter may be confusing, since you don't need to set backend to bluetooth to use Bluetooth connection. In general, you don't need to change the parameters to connect to your DualShock 4 (whether via USB or Bluetooth).

Since #4 seems to have fixed this problem, I'll close this issue :)

aalbaali commented 1 year ago

I have a very similar issue now but running on ROS Humble that's running on a Docker container. Specifically, I'm able to connect the ds4 by using the command ds4drv but not ds4drv --hidraw or ros2 launch ds4_driver ds4_driver.launch.xml (it just stays stale). Any idea on how to fix this?

Would it be possible to use ds4drv to connect to the bluetooth device, and then use some parameter in ros2 launch file?

Update: I forgot to mention that I tried it out on the Dockerfile from the repo and it still didn't work.