Skip to content

PlayStation DualShock4

趙 漠居(Zhao, Moju) edited this page Jun 14, 2022 · 8 revisions

PlayStation DualShock4

PS4joy

Install ds4drv

Please refer to https://github.com/chrippa/ds4drv

sudo pip install ds4drv

Bluetooth Pairing

Mode1: Raw bluetooth mode (recommended)

holding Share + the PS button until the LED starts blinking rapidly

Mode2: Hidraw mode

instruction
  1. Please check the Bluetooth is ON in host PC: bluetooth
  2. Click + button: bluetooth
  3. Hold Share + PS button until the LED starts blinking rapidly, then a new device Wireless Controller will appear. Select this new device and click "Next". Finally, this device will be paired successfully in Ubuntu: bluetooth the controller's LED will turn in blue and you can also find /dev/input/js0 which is created by Bluetooth driver (not from ds4drv).
  4. Disconnect this device by holding only PS button until the LED turns off (more than 10 seconds).
  5. run following command:
chou@chou-ThinkPad-T450:~$ sudo ds4drv --hidraw 
[info][controller 1] Created devices /dev/input/js0 (joystick) /dev/input/event1 (evdev) 
[info][hidraw] Scanning for devices
m[info][controller 1] Connected to Bluetooth Controller (1C:66:6D:7B:C6:0A hidraw0)
[info][hidraw] Scanning for devices
[info][controller 1] Battery: Fully charged
[warning][controller 1] Signal strength is low (18 reports/s)

Note: important point is that the bluetooth devices should be linked to /dev/input/js0 by the above command. If not, please do step 4 again.

  1. hold only PS button for a while, then the LED will turn back to blue again, meaning successful connection. The Bluetooth icon will have the padlock emblem.

  2. disable touchpad input device by creating /etc/udev/rules.d/50-ps4joy.rules which contains following content:

SUBSYSTEM=="input", ATTRS{name}=="*Wireless Controller Touchpad", RUN+="/bin/rm %E{DEVNAME}", ENV{ID_INPUT_JOYSTICK}=""

Note: please refer to 2.1 disable touchpad input device in http://wiki.ros.org/ds4_driver for more details.

  1. restart udev rule by following commands:
$ sudo udevadm control --reload-rules
$ sudo udevadm trigger
  1. start sixad on boots (not recommend): Please check the instruction of "PS4JOYドライバの自動起動設定" in this blog

How to use in ROS

roslaunch aerial_robot_base joy_stick.launch robot_name:=$ROBOT_NAME

$ROBOT_NAME is the name of your robot (e.g., hydrus, dragon, hydrus_xi)

Common commands:

command action
options motor arming (please do this before takeoff)
share (short push) force landing (without xy position control, robot will descend slowly)
share (long push, > 2.0s) halt (i.e. stop motor immediately )
cross-left + circle takeoff (this can be received by robot only after motor arming)
cross-right + square landing
select (short push) force landing (without xy position control, robot will descend slowly)
select (long push, > 2.0s) halt (i.e. stop motor immediately )
triangle xy(horizontal) velocity control mode
cross(X) xy(horizontal) position control mode
cross-down xy(horizontal) attitude control mode
left stick vertical movement in world x axis (only available in velocity/attitude control mode)
left stick horizontal movement in world y axis (only available in velocity/attitude control mode)
left stick vertical + L2 movement in baselink (local) x axis (only available in velocity/attitude control mode)
left stick horizontal + L2 movement in baselink (local) y axis (only available in velocity/attitude control mode)
right stick vertical movement in z axis
right stick horizontal + push right stick movement in yaw axis

For more information about ps4joy in ros, please check here

euroc

Clone this wiki locally