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
When complete, the PS4 LED should go solid and turn a deeper blue color. You should only have to do this once, and the controller will remain paired until you pair it with another computer.
Once you've got the PS4 controller paired, you'll find out the button mapping is just a little different form the PS3:
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).
Here's the changes I made to Maxwell to update from the PS3 to the PS4 controller. I use a custom node for converting Joy messages into Twist messages. If you're using the popular teleop_twist_joy package, you'll be using enable_button parameter instead of axis_deadman.
No comments:
Post a Comment