Using a PlayStation DS4 with ROS Kinetic on Ubuntu 16.04

For certain tasks, driving a mobile robot with a joystick is easier than using keyboard controls. I realized this while creating maps of simulated environments for my autonomous navigation experiments. The joystick I used is a PlayStation DualShock 4 (DS4) controller.

It took me a few tries to get a working setup even after following these tutorials: 1, 2. This was partly because the first was written for an older version of ROS, and none discussed the nuances between connecting the DS4 in wired vs. wireless mode. This tutorial addresses the issues just described. It was written the following computer setup:

  • Ubuntu 16.04
  • Ros Kinetic

The Basics

  1. You can connect the DS4 to your computer in either wired mode (via a USB cable) or in wireless mode (via Bluetooth, if your computer has it).
  2. The ROS joystick_drivers metapackage contains the node and driver necessary to use the DS4, but only when you connect it via USB.
  3. If you want to connect the DS4 via Bluetooth, you’ll need to install an additional tool called ‘ds4drv’.


1. Open a terminal console. Install the required libraries.

 $ sudo apt-get install libusb-dev libbluetooth-dev
 $ sudo apt-get install libcwiid1 libcwiid-dev libspnav-dev  # for cwiid.h and spnav.h

2. Download and build the ROS joystick_drivers metapackage.

 $ cd ~/catkin_ws/src
 $ git clone
 $ cd ..
 $ catkin_make  

3. If you want to use Bluetooth, install the DS4 driver.

$ sudo pip install ds4drv 

4. Install the jstest tool. We will use it to test the DS4 connection.

 $ sudo apt-get install jstest-gtk

Connecting and using the DS4

$ rosrun joy joy_nodeYou can connect the PS4 controller to your computer in one of two ways:

Method 1. USB connection. This is the simpler way.

  • Connect the DS4 to your computer with a USB cable. You should see the blue light on the DS4 turn on immediately.
  • Run jstest to verify that the controller was recognized.
 $ jstest-gtk

A window should appear showing your device connection.

Click the ‘Properties’ button. Play around with the DS4 controls and watch the values change on the Properties window. Close the program when you are done.

  • Start the ROS joystick node. (This node publishes the controller’s data to the /joy topic.)
$ rosrun joy joy_node

[ERROR] [1576996919.982650391]: Couldn’t open joystick force feedback!

[ INFO] [1576996919.982814294]: Opened joystick: /dev/input/js0. deadzone_: 0.050000.

TIP: If the controller show up with a different device name (eg, /dev/input/js1 instead of the default /dev/input/js0), you must set ROS parameter before starting the node:

$ rosparam set joy_node/dev "/dev/input/js1"
$ rosrun joy joy_node

Method 2. Bluetooth wireless connection.

  • Turn on Bluetooth on your computer.
  • Press the PS button on the DS4 to power it on.
  • Open a terminal console. Run the DS4 driver software.
$ sudo ds4drv

NOTE: If you are wirelessly connecting the DS4 via Bluetooth for the first time, you will be prompted to pair the device. To pair, hold the SHARE and PS button untill joystick indicator flashes. (See Step 2 of this cool tutorial for details.)

You should see an output like below:

  • Open another terminal. Run jstest to verify that the controller was recognized. (see Method 1 above for how to use.)
$ jstest-gtk
  • Start the ROS joystick node. (This node publishes the controller’s data to the /joy topic.)
$ rosrun joy joy_node

3 thoughts on “Using a PlayStation DS4 with ROS Kinetic on Ubuntu 16.04

  1. Hello,

    first of all: great work!
    But is it possible, that some axes are not publishing anymore? The amount of data that is sent in each message is massive. I Only use Axes 1-4 and btns 1-8. The coalesce_intervall is already the minimum.

  2. Thanks Simon for the compliment. It’s been a while since I used the controller, but I recall you can change the button/joystick mappings by hitting the Mapping button. I didn’t reconfigure it because the axes info I needed were already being published.

  3. That’s just a temporary solution… actually it’s resetting the mapping everytime i connect the controller… i also increased the deadzone of the gyroscope axes, so no new value is published by the joy_node.
    I recognized┬┤, that i can connect the ds4 without using the command ‘sudo ds4drv’, so it’s detected as a ps3 controller and the joy_node isn’t publishing the data of the gyroscope . that is built in the ds4. This caused the lags. But thank you very much!

Leave a Reply

Your email address will not be published.