# Bind controller buttons to a package

**URL:** <https://get-help.theconstruct.ai/t/bind-controller-buttons-to-a-package/20023>\
**Category:** Open Discussions\
**Created:** [October 21, 2022, 7:44pm UTC](https://get-help.theconstruct.ai/t/bind-controller-buttons-to-a-package/20023 "2022-10-21T19:44:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shahad78](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@shahad78](https://get-help.theconstruct.ai/u/shahad78)\
**Post date:** [October 21, 2022, 7:44pm UTC](https://get-help.theconstruct.ai/t/bind-controller-buttons-to-a-package/20023/1 "2022-10-21T19:44:05Z")

</div>

I have built a package that avoids obstacles on my robot and I wonder if its possible to run this package using my ps4 controller, the controller is connected using ds4drv .  
I run my package by entering to the robot’s pc and then “rosrun xx xx”

---

<div class="post-metadata">

**Author:** ![girishkumar.kannan](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/girishkumar.kannan/32/6994_2.png) [@girishkumar.kannan](https://get-help.theconstruct.ai/u/girishkumar.kannan)\
**Post date:** [October 22, 2022, 8:09am UTC](https://get-help.theconstruct.ai/t/bind-controller-buttons-to-a-package/20023/2 "2022-10-22T08:09:13Z")

</div>

Hi @shahad78 ,

I am not sure if I could give an exact answer but I can give you some helpful tips.

You can accomplish your task in two methods - the easy way and the hard way.

**Easy Way:**  
You can map your PS4 Controller / Joystick keys to the movement keys on a keyboard. Something like mapping your joystick directions to keyboard W/A/S/D and your action keys to I/J/K/L. You can later test your robot with the teleop program and check if joystick-keyboard key mapping works. However, this may or may not be viable.

**Hard Way:**  
If you are using wired or wireless PS4 controller that can be connected to a PC, you can find a driver package that would transform incoming joystick actions to control signals. You can use a python or c++ library to transport thsese control signals into ROS by writing a program with publisher, that would send these control signals from the joystick driver to ROS core.

You can finally use a subscriber script in your ROS package and utilize these joystick signals to move your robot - either in simulation or the real one!

I hope these tips were helpful to you!

Regards,  
Girish

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [October 29, 2022, 7:00am UTC](https://get-help.theconstruct.ai/t/bind-controller-buttons-to-a-package/20023/3 "2022-10-29T07:00:42Z")

</div>

This topic was automatically closed after 3 days. New replies are no longer allowed.
