[Documentation] [TitleIndex] [WordIndex

Note: This tutorial assumes that you have completed the previous tutorials: ROS tutorials.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

How to Pair the PS3 Joystick with a Bluetooth Dongle

Description: This tutorial is an introduction to using the PS3 DualShock 3 Joystick connected via bluetooth to a desktop computer. After reading it, you should be able to bring up the ps3joy node and display the data coming from the joystick.

Keywords: PS3, joystick, driver

Tutorial Level: BEGINNER

Next Tutorial: Writing a teleop node


Start by installing the dependencies and compiling the driver:

$ rosdep install ps3joy
$ rosmake ps3joy


If this joystick has already been paired to this dongle you can skip this section and go directly to "Connecting to the Joystick Via Bluetooth". This will usually be the case when you are working on the PR2.

For Computers with More than One USB Port

Plug the USB bluetooth dongle into your computer. Then, plug the PS3 bluetooth joystick into the computer using a USB cable.

Load the bluetooth dongle's MAC address into the PS3 joystick using:

$ sudo bash
$ rosrun ps3joy sixpair

You will see something similar to:

Press Ctrl-D now so that you do not continue to run as root.

If you get something like the following:

Run the command:

$ hciconfig hci0 reset

and then retry:

$ rosrun ps3joy sixpair

For Computers with One USB Port

Plug the USB bluetooth dongle into the computer and read the MAC address from the dongle:

$ sudo hciconfig hci0 up
$ hciconfig

You will see something like this:

(In the above example, the MAC address is: 00:22:B0:D0:5A:09)

Now unplug the bluetooth dongle and plug the PS3 joystick into the computer using a USB cable. Replace the joystick's MAC address using the following command:

$ sudo bash
$ rosrun ps3joy sixpair [MAC address]

You will see something like this:

Press Ctrl-D now so that you do not continue to run as root.

Connecting to the Joystick Via Bluetooth

Unplug the joystick from the computer and make sure that the USB bluetooth dongle is plugged in. Now, start the program to create the connection between the bluetooth dongle and the joystick:

$ sudo bash
$ rosrun ps3joy ps3joy.py

You will see:

Press the PS button in the middle of the joystick and the connection will be activated.

You will see:

If you do not see the above message and you are running Karmic or Lucid versions of Ubuntu you may need to follow these instructions.

Confirming Joystick Input

In a new terminal, confirm that the joystick is sending data to your computer. You can test this with jstest:

$ sudo jstest /dev/input/js?

(if this does not work, try replacing ? with the number of your joystick --try tab completing, i.e. /dev/input/js0 )

You will see output that looks like this and changes as you press buttons and move the joysticks:

Unpairing the Joystick

If you ever need to unpair the joystick, you can simply press the pairing button for 10 seconds. The lights on the joystick should stop blinking.

2019-07-13 13:01