Page 1 of 1

A good library to use with a Logitech gamepad

Posted: Tue Apr 05, 2022 8:16 am
by Maxorzoom
This might seem like an easy beginner question (sorry to ask) but what library should I use if I want to use a brushless DC motor and control them with a controller. Also would I be able to initialized it such as motor.setTargetvelocity(controller input) or how would I go around starting it. Thank you for your time

Re: A good library to use with a Logitech gamepad

Posted: Tue Apr 05, 2022 8:29 am
by mparadis
I'm not sure what kind of game controller libraries are out there, but there are probably lots of examples online if you search for "logitech controller python example" or something.

The implementation would be a bit more complicated than setTargetVelocity(controller input). I suspect the controller library will output the controller stick position in the form of an X,Y pair or an angle and magnitude. setTargetVelocity accepts a number from -1.0 to 1.0, where -1.0 is full speed reverse, and 1.0 is full speed forward. If you want the speed and direction of the motor to correspond to how far the controller stick is tilted, you'll have to do some math to convert from your XY or angle/magnitude values into a single duty cycle value for setTargetVelocity.