PlayStation-JoyInterface-ROS2#

PlayStation Joy Controller Interface Package for ROS2.

Supported controllers#

StatusHardware Name
⬜️DualShock3
⬜️DualShock4
Dualsense

How to use the interface library#

  1. Initialize controller interface with the specific hardware type.

    // Initialize Interface
    const std::string hw_type = "Dualsense";
    ps_interface =
    std::make_unique<p9n_interface::PlayStationInterface>(hw_type);
  2. Set sensor_msg::msg::joy to interface. Then you can access any button state via the interface.

    void Example::onJoyCallback(sensor_msgs::msg::Joy::ConstSharedPtr joy_msg) {
    ps_interface->setJoyMsg(joy_msg);  // set joy message to interface
    
    // When Circle Button Pressed..
    if(ps_interface->pressedCircle()) {
     // You can hook action here
    ...

Buttons and Interface functions.#

TargetTypeFunction NameDescription
AnyboolpressedAny();Return true when pressed
boolpressedSquare();
boolpressedCircle();
boolpressedTriangle();
boolpressedCross();
L1boolpressedL1();
R1boolpressedR1();
R2boolpressedR2();pressedR2Analog() also returns the button status with float
L2boolpressedL2();pressedL2Analog() also returns the button status with float
SelectboolpressedSelect();
StartboolpressedStart();
PSboolpressedPS();
DPad ↑boolpressedDPadUp();pressedDPadY() also returns the button status with float
DPad ↓boolpressedDPadDown();pressedDPadY() also returns the button status with float
DPad ←boolpressedDPadLeft();pressedDPadX() also returns the button status with float
DPad →boolpressedDPadRight();pressedDPadX() also returns the button status with float
DPad ← →floatpressedDPadX();-1.0 : Right, 1.0 : Left
DPad ↑ ↓floatpressedDPadY();-1.0 : Down, 1.0 : Up
Left Stick ← →floattiltedStickLX();-1.0 : Right, 1.0 : Left
Left Stick ↑ ↓floattiltedStickLY();`-1.0 : Down, 1.0 : Up
Right Stick ← →floattiltedStickRX();-1.0 : Right, 1.0 : Left
Right Stick ↑ ↓floattiltedStickRY();-1.0 : Down, 1.0 : Up
R2floatpressedR2Analog();-1.0 : Pressed, 1.0 : Not pressed
L2floatpressedL2Analog();-1.0 : Pressed, 1.0 : Not pressed

Acknowledgements#

We acknowledge attribute and gratitude to the following resources in creating this package.