PS4 Controller and ROS
05 Apr 2020ros
national-robotics-week
maxwell
robots
It's National Robotics Week! But you should definitely #StayAtHome, so there are
no in-person events this week. I already had this (and several other posts) nearly
done, so I'm aiming to post something every day this week.Recently I updated Maxwell to use the PS4 controller. It is not the easiest thing to setup, and I found lots of misinformation out there that either never worked, or no longer works. So here is how I now setup PS4 controllers on Ubuntu Bionic (18.04).
These instructions require no special packages to be installed, we're using the default bluetooth built into the Linux kernel, which should also mean that other bluetooth stuff continues to work (unlike the older ps3_joy ROS package).
To pair the PS4 controller with the robot computer we need to start the controller in "pairing mode". Hold down the SHARE button while pushing the POWER button. Continue to hold both buttons until the LED starts flashing very quickly.
On the computer we will use bluetoothctl to do three things:
- Turn on the scan - so we can find new devices. This is how we find the MAC address of the wireless controller.
- Tell the bluetooth controller to trust the wireless controller
- Tell the bluetooth controller to pair with the wireless controller
Once you've got the PS4 controller paired, you'll find out the button mapping is just a little different form the PS3:
- The common "deadman" button on the upper corner of the joystick (labeled "L1") is index 4 instead of 10.
- The joystick axis have changed a bit, I had to change axis_linear from 4 to 3.
- It is probably a good idea to set the autorepeat_rate on the joy node. This prevents stuttering publishing (and movement).