Coder Social home page Coder Social logo

autonohm / ds5_ros Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 1.3 MB

A ROS1 Node to integrate the DualSense 5 (PS5) Controller into the ROS ecosystem, including feedback messages to set leds, adaptive triggers etc.

License: MIT License

CMake 50.89% Python 47.98% C 1.13%
ros ds5 dualsense5 dualsense-controller adaptive-triggers ps5-controller

ds5_ros's Introduction

ds5_ros

A ROS1 Node to integrate the DualSense 5 (PS5) Controller into the ROS ecosystem, including feedback messages to set leds, adaptive triggers etc.

Installing

Install the hidapi.

sudo apt install libhidapi-dev

Install the package from pypi.

pip install pydualsense

Device Access

To allow linux to access the controller, you will need to set the device permissions.

You can either do this manually by typing

sudo su root

OR

sudo chmod -R 777 /dev

to run the node,

OR you can add the provided UDEV rule to your rules.d folder to permanently enable this for your system:

sudo cp YOUR_PATH/ds5_ros/udev/99-dualsense.rules /etc/udev/rules.d

Change pydualsense.py

Add attribute cable_connection in function init():

def init(self):
    ...
    self.cable_connection = True
    ...

Change function writeReport() in pydualsense.py to catch the IOError when controller is disconnect to the PC

def writeReport(self, outReport):
    """
    write the report to the device

    Args:
        outReport (list): report to be written to device
    """
    try:
        self.device.write(bytes(outReport))
    except IOError:
        self.cable_connection = False

Usage

Initialize the controller

from pydualsense import *

ds = pydualsense() # open controller
ds.init() # initialize controller

Close the controller

ds.close() 

LED

Set color RGB. RGB are integer values and in range 0-255.

ds.light.setColor(255, 0, 0)

Rumble effect

Control the rumble effect of left motor or right motor. Intensity is in range 0-255.

ds.setLeftMotor(255)

Adaptive Trigger

Set trigger mode for the buttons and control the intensity.

ds.TriggerR.setMode(TriggerModes.Rigid)
ds.TriggerR.setForce(1, 255)

Other

Other effects and enumerations could be found under pydualsense.py and enums.py

Topic

Publisher

Joy

  • Topic: joy
  • Message type: Joy

Subscriber

Joy feedback

Controler Mapping

Button

buttons[0] = cross

buttons[1] = circle

buttons[2] = triangle

buttons[3] = square

buttons[13] = cross up

buttons[16] = cross right

buttons[14] = cross down

buttons[15] = cross left

buttons[6] = rear left 2 button

buttons[7] = rear right 2 button

buttons[4] = rear left 1

buttons[5] = rear right 1

buttons[8] = stick left button

buttons[9] = stick right button

buttons[10] = PS

buttons[11] = share

buttons[12] = options

buttons[17] = track pad button

Axes

joy_msg.axes[0] = stick left leftward (-1.0 -> 1.0, default ~0.0)

joy_msg.axes[1] = stick left upward (-1.0 -> 1.0, default ~0.0)

joy_msg.axes[2] = stick right leftward (-1.0 -> 1.0, default ~0.0)

joy_msg.axes[3] = stick right upward (-1.0 -> 1.0, default ~0.0)

joy_msg.axes[4] = rear left 2 pushDown (0.0 -> 1.0, default = 0)

joy_msg.axes[5] = rear right 2 pushDown (0.0 -> 1.0, default = 0)

Other controll function like touch pad can be found in pydualsense.py

Header for C++

HeaderFile: rgbIntToFloat.h with function rgbIntToFloat(int, int, int) to change RGB 3 * 8 bit to float32 value

Credits

https://github.com/flok/pydualsense

ds5_ros's People

Contributors

linhphan210 avatar marcomasa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.