Hello,
I want to write a small programm using python that allows over the crazyflie using a game controller and simultaneously send back data to computer (as the client does, but with python library for more adaptiability). I figured out how to read data from the crazyflie, but not yet how to extract input signal from the game device, convert it to and send to the drone as control signal.
Would be glad for any tips, suggestions or instructions.
Controlling with joystick/gamepad using python-client
Re: Controlling with joystick/gamepad using python-client
The easiest might be to look at pygame, pygame has APIs to handle joysticks.
In the Crazyflie client we have a custom implementation for Linux and we use pysdl2 for Windows and Mac.
In the Crazyflie client we have a custom implementation for Linux and we use pysdl2 for Windows and Mac.
Re: Controlling with joystick/gamepad using python-client
Hi arnaud,
it I want to study the client code to "copy" the way it handles joystick input, which files should I look into ?
Really appreciate the help.
it I want to study the client code to "copy" the way it handles joystick input, which files should I look into ?
Really appreciate the help.
Re: Controlling with joystick/gamepad using python-client
The input subsystem of the client is there: https://github.com/bitcraze/crazyflie-c ... tils/input, the low level drivers for SDL and Linux are in a subfolder: https://github.com/bitcraze/crazyflie-c ... putreaders
This code became a bit too complex to our taste (it handles all assisted mode as well as the joystick mapping), but has been designed to be independant from the graphical client (it is used in the headless client as well) so you should even be able to use the JoystickReader object directly in your project and have all mapping and assisted mode functionality. You can look in the headless client for an 'simple' example of how it is used and in the gui client for all the functionalities.
This code became a bit too complex to our taste (it handles all assisted mode as well as the joystick mapping), but has been designed to be independant from the graphical client (it is used in the headless client as well) so you should even be able to use the JoystickReader object directly in your project and have all mapping and assisted mode functionality. You can look in the headless client for an 'simple' example of how it is used and in the gui client for all the functionalities.
Re: Controlling with joystick/gamepad using python-client
I'm studying the joystick input subroutine. The code is easy enough to understand. There is one thing I haven't got though: what is the role of the pysdl2.py file ?
Re: Controlling with joystick/gamepad using python-client
linuxjsdev.py is used for Linux, pysdl2.py is used for Mac, Windows and anything not Linux. Both files implements the same low level function to access and ready joystick. We have had problems on linux with sdl so this is why there is a pure-python joystick driver for Linux.