Nintendo Switch Pro Controller gyro/accel data
Hi guys,
I'm a beginner with max and I'm trying to make a simple patch that lets me rotate a cube with the gyro data of a nintendo switch 1 pro controller. When I make a gamepad object and open the help file, I find that the controller is already connected and outputting data into max, and that all of the buttons and joysticks are working as they should. The only problem is the gyro data seems to be more like an accelerometer - I can spin the controller very slowly around one axis and keep the data below 1, but if I spin it fast the numbers increase. The data is moving too fast for me to tell if it is exactly the same as the accel data, but in any case it doesn't work to rotate the cube the way I need it to. If this isn't just a me problem, you should be able to see it in the help file of the gamepad object, so I'm not including an original patch here.
I bought the controller used so there might be something messed up about it, but I wanted to check here to see if anybody else has encountered the same problem. I found some stuff online about the gyro and accel data being fused in the switch controller, but I don't understand exactly what that means, or if it's relevant here.
Thank you!
I know nothing about that nintendo, but accel any gyro are 2 different kind of
sensors. gyro measures speed of rotation, not absolute position.
faster you move, higher the output, once you stop moving it drops to theoretical 0 0 0.
Oh, I'm dumb. So is gyro different than roll, pitch, and yaw? And is there a way to map those data streams with the gamepad object?
gyro gives you the delta since last update for roll, pitch and yaw.
You basically need to accumulate incoming gyro data to get a value for roll, pitch and yaw, and also calibrate the default "0 0 0" position by yourself.
Something like this should work, although I don't have a gamepad with a gyro to test.
Not sure what the incoming data will mean though, if it's radians, degrees or something else.
all you need to do is to grab that 6 axis and see what range you get etc.
I can not help you wth that, have no such device.
when you know what to expect at input, then you can try to smooth, scale or do any kind
of math to the input.
back to accelerator and gyroscpe, that names are missleading.
Accelerator outputs absolute values depending on how sensor is positioned in gravity field.
gyroscope is only outputing something when one moves it, and decribes how fast one moves the thing.
TFL, thanks so much for that patch. It does work, with the small addition of something to filter out the lower gyro values so that data doesn't keep accumulating while the controller is just sitting at rest (but in which the sensor continues to register very small micro-movements).
Source audio, thanks for clarifying that regarding gyro vs. accel. It is indeed rather confusing...