atar-axis / xpadneo

Advanced Linux Driver for Xbox One Wireless Controller (shipped with Xbox One S)
https://atar-axis.github.io/xpadneo/
GNU General Public License v3.0
1.92k stars 111 forks source link

How to use xpadneo to control my robot using Raspberry pi #300

Closed shubhammathur196 closed 3 years ago

shubhammathur196 commented 3 years ago

Hello , I want to use my xbox controller m to control a robot using Raspberry pi . Please suggest me a way to do it How can i use the outputs I get the changes in the controller to use it in the python code and control my robot

kakra commented 3 years ago

There's an evdev lib for python. You should get the idea by looking at the python examples in the repository. There's also #298 which is about detecting connection loss for robot control. That guy may have some tips for you how to start. There have been questions about robot control in the past, you may want to browser some of the older or maybe closed issues.

From what I can tell you from past questions, you may want to prefer not using a bluetooth connection directly on the robot. Instead, use a software like netstick that is able to transfer input events via IP protocol, so you could use wifi to control the robot which is much more reliable and has a better range. It is also more easy to detect connection issues that way. Setup the netstick server on your control station where you either attach the gamepad via USB, or use bluetooth. If your control station is also a raspberry pi, you may be able to attach it with some extra batteries to your gamepad to stay mobile for remote control.

Apart from that, your question is mostly out of scope for this project. I'm happy to help you with suggestions or problem analysis but I won't be able to help much with the implementation details, especially since I don't know python very well (I can read it, but I have almost zero confidence in writing python code, I'm a Ruby/C/Go guy). Basically, you need a library to open the evdev device of the controller to read the input events, then create an event loop listening for events, and let the robot act accordingly. With proper abstraction and modularization, you can easily uncouple the connection mode (wifi vs bluetooth vs cable) from your control code, thus make it agnostic to even the gamepad type to easily adapt it to any sort of input controller. I suggest starting out with some sketches and diagrams to properly design the code modules of your application, then teach yourself about the different protocol layers needed, then refine your paper drafts, then go to the editor and start coding.

If you'd like me to look at your intermediate steps and mentor some of the choices, I can try to do so. But the implementation and research will be mostly on your part. IOW, that looks like an interesting project, I'll try to help where I can and afford the time.

no-response[bot] commented 3 years ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.