Skip to content

[ROS] Sony PlayStation 4 DualShock®4 node joy_msg to twist_msg

License

Notifications You must be signed in to change notification settings

BastianSolutionsRandD/ps4-ros

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ps4_ros

Sony PlayStation 4 DualShock®4 node joy_msg to twist_msg.

This uses ds4drv --hidraw which allows connecting to an already paired remote, thus removing the need to sync every time.

Installation

1. Clone this repo

git clone https://github.com/BastianSolutionsRandD/ps4-ros.git
catkin build
sws

2. Install ds4dr:

sudo pip install ds4drv

3. Install joy http://wiki.ros.org/joy

sudo apt install ros-$ROS_DISTRO-joy

4. Edit the WORKSPACE variable in ps4-ros/scripts/set_udev_rules.sh to provide the name of the workspace containing ps4-ros.

# Default is 'catkin_ws. Replace with the name of your workspace
WORKSPACE='catkin_ws'

5. Run set_udev_rules.sh , which copies ps4-ros/udev/50-ds4drv.rules to /etc/udev/rules.d/ giving R/W permissions to ds4drv for all users.

roscd ps4-ros/scripts
chmod +x set_udev_rules.sh
sudo ./set_udev_rules.sh

6. Pair PS4 controller over Bluetooth

roslaunch

roslaunch ps4_ros ps4.launch

One by one

  1. ds4drv --hidraw if it is not running already.
  2. rosparam set joy_node/dev "/dev/input/jsX"
  3. rosrun joy joy_node
  4. rosrun ps4_ros ps4_ros

You can adjust the scaling parameters inside the launch file or via rosparam while running. The default scaling is 1.0

<!-- In Launch File -->
<param name="scale_angular" value="1.0"/>
<param name="scale_linear" value="1.0"/>
# While node is running
rosparam set /ps4/scale_linear 1.0
rosparam set /ps4/scale_angular 1.0

Troubleshooting

  • If nothing is being published to /cmd_vel check the js* port of the controller using ls /dev/input/ | grep js, and try changing to another js* in the launch file.

  • Display raw ds4drv data

sudo jstest /dev/input/jsX

About

[ROS] Sony PlayStation 4 DualShock®4 node joy_msg to twist_msg

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 82.5%
  • CMake 11.3%
  • Shell 6.2%