Show EOL distros:
Package Summary
ROS driver for the DualShock 4 controller
- Maintainer status: maintained
- Maintainer: Naoki Mizuno <naoki.mizuno.256 AT gmail DOT com>
- Author: Naoki Mizuno
- License: MIT
- Source: git https://github.com/naoki-mizuno/ds4_driver.git (branch: master)
Package Summary
ROS driver for the DualShock 4 controller
- Maintainer status: maintained
- Maintainer: Naoki Mizuno <naoki.mizuno.256 AT gmail DOT com>
- Author: Naoki Mizuno
- License: MIT
- Source: git https://github.com/naoki-mizuno/ds4_driver.git (branch: master)
Contents
Overview
This package provides a driver for the DualShock 4 (PS4) Bluetooth controller. Some of the features of this package are:
- Access to information such as IMU, battery, and touchpad
- Access to feedback such as rumble, LED color, and LED flashing
- Connection via Bluetooth for wireless control
Installation and Usage
Pair and connect to your DualShock 4 by long-pressing the PS button and Share button for up to 10 seconds until the LED starts flashing. Use your system's Bluetooth settings to connect to the device.
This driver depends on ds4drv. Some features of this driver depend on pull requests have not yet been merged upstream. Until they are merged, use the fork (devel branch).
$ git clone https://github.com/naoki-mizuno/ds4drv --branch devel $ cd ds4drv $ python2 setup.py install --prefix ~/.local $ sudo cp udev/50-ds4drv.rules /etc/udev/rules.d/ $ sudo udevadm control --reload-rules $ sudo udevadm trigger $ cd ~/catkin_ws/src $ git clone https://github.com/naoki-mizuno/ds4_driver.git
Compile and source this package just like any other ROS package. To run,
$ roslaunch ds4_driver ds4_driver.launch # Or $ rosrun ds4_driver ds4_driver_node.py
Disable touchpad input device
Note: You can skip this section if you use the forked version of ds4drv (i.e. naoki-mizuno/ds4drv) because the following line is included in the udev rules by default.
By default the touchpad of the DualShock 4 is recognized as an input device. Because of this, the mouse moves to the location on screen that corresponds to the location touched, making it very hard to track the mouse cursor (and worse, it automatically clicks at that location). If you want to prevent the touchpad from being recognized as an input device, add the following to the udev rules and run the udevadm commands (you will still be able to use the touchpad from this driver):
SUBSYSTEM=="input", ATTRS{name}=="*Wireless Controller Touchpad", RUN+="/bin/rm %E{DEVNAME}", ENV{ID_INPUT_JOYSTICK}=""
Demonstration
Get a glimpse of some of the features of ds4_driver including touchpad, rumble, and LED control:
$ roslaunch ds4_driver demo.launch
Moving the left/right stick controls the rumble. Sliding left and right on the touchpad while pressing circle, triangle, cross buttons controls the brightness of the red, green, blue LED, respectively (you can tell from the color of the button). Pressing the PS button triggers the flashing of the LED.
Nodes
ds4_driver_node.py
Driver for DualShock 4, which publishes the device's status and applies feedback to the device.Subscribed Topics
set_feedback (ds4_driver/Feedback)- Feedback for the device such as LED color, LED flashing, and rumble.
When using ROS standard messages.
Topics subscribed to only when ~use_standard_msgs is true- Feedback for the device (only LED color and rumble).
Published Topics
status (ds4_driver/Status)- Publishes the current state of the device.
When using ROS standard messages.
Topics published only when ~use_standard_msgs is true- Battery information such as percentage left.
- Joypad data.
- IMU data, where X points to the right, Y points up, and Z points towards the person holding the device.
Parameters
~device_addr (string)- Hardware address of the device to be connected to. If unspecified, the first device found will be used.
- Backend to be used to connect to the device via Bluetooth. bluetooth is only for legacy support and should not be used unless necessary. Refer to the docs of ds4drv for details.
- If true, uses ROS standard messages such as sensor_msgs/Joy.
- Amount by which the joystick has to move before it is considered to be off-center.
- Frame ID to be used for the messages.
- Frame ID to be used for the IMU messages.
ds4_twist_node.py
Subscribes to the device status messages and converts them to velocity commands.Subscribed Topics
status (ds4_driver/Status)- Joypad state published from the driver.
Published Topics
cmd_vel (geometry_msgs/Twist)- Velocity commands. Type is geometry_msgs/TwistStamped if ~stamped parameter is true.
Parameters
~stamped (bool, default: false)- Whether to publish geometry_msgs/Twist or geometry_msgs/TwistStamped for the output velocity command. For robots such as TurtleBot, Husky, and PR2, /cmd_vel is not stamped (i.e. geometry_msgs/Twist is used) but stamped velocity commands may be required for some applications.
- What buttons and axes to use for the value of each velocity vector. Expressions can be used to combine values of multiple keys (see config/twist_6dof.yaml for examples).
- Scaling factor for each velocity vector.