PS4 Dual Shock Motion Control

GPC2 script programming for Titan Two. Code examples, questions, requests.

Re: PS4 Dual Shock Motion Control

Postby DeviateSquirrel » Fri Feb 19, 2021 10:06 pm

EDTracker with a new sketch flashed to it works great so far! Right now I’m challenged with it needing to be on Port A. When it’s on PROG it’s way too slow. I’ve got a Bluetooth module coming tomorrow so I can use it for authentication and free up a port.
User avatar
DeviateSquirrel
First Sergeant
First Sergeant
 
Posts: 46
Joined: Sun Jan 17, 2021 11:07 pm

Re: PS4 Dual Shock Motion Control

Postby SirBrass » Tue Feb 23, 2021 1:37 pm

What is EDTracker?
User avatar
SirBrass
First Sergeant
First Sergeant
 
Posts: 55
Joined: Sat Dec 05, 2020 3:47 am

Re: PS4 Dual Shock Motion Control

Postby DeviateSquirrel » Tue Feb 23, 2021 3:37 pm

3 axis DIY head tracker - https://youtu.be/PQBAozc59Pc
User avatar
DeviateSquirrel
First Sergeant
First Sergeant
 
Posts: 46
Joined: Sun Jan 17, 2021 11:07 pm

Re: PS4 Dual Shock Motion Control

Postby Yearoh » Sun Mar 14, 2021 11:48 am

DeviateSquirrel wrote:I wonder if the Bluetooth adapter for the T2 would allow the motion from the controller to go through the T2.

It makes sense that the gyros only output when in motion as they’re ultimately measuring angle and at rest there’s nothing to measure. I would expect something besides an on/off output though. With 3 axis an on/off would only allow for a few angles I think (the primary axes and 45s off those axes though I don’t see how you’d get negative values).

I’ve been doing a little research on head tracking software and found a now defunct company called EDTracker. Even though the company went under you can still get the hardware and I believe the software is on Git. Near as I can tell it reads as a standard HID so I’m thinking it’ll show up in GTuner. I’ll let you know how it turns out.



I know that for motion control/mapping a combination of gyro and accelerometer needs to be used to reduce interference/spikes and to stop gyro drift as well as to smooth the signal. It’s the same principles whether it’s for drone control or a bunch of other stuff which is fortunate because the really difficult stuff has already been worked out math wise, for example algorithms that use 80% accelerometer and 20% gyro to give nice outputs than can be easily adjusted for sensitivity etc.

The challenge for me is converting this into code that will run on the titan. There’s code out there written in C as well as python but you can’t just copy/paste, and I posted it looking for help but didn’t get too far, although it is a bit of an out there request.

I hope this can help you a little. Also i recall reading someone wanting to use a head movement mechanic for when you are piloting a helicopter in battlefield & it enters look mode by holding the stick down and then you’d use the gyro etc so maybe their post could also help (you’ll have to search as i can’t remember any more)
User avatar
Yearoh
Master Sergeant
Master Sergeant
 
Posts: 38
Joined: Fri Jul 10, 2020 9:32 am

Re: PS4 Dual Shock Motion Control

Postby DeviateSquirrel » Sun Mar 14, 2021 4:55 pm

This exercise has taken me down quite the rabbit hole of rotational geometry -- quaternions are wild!

As near as I can tell, the sensor fusion (where gyro and accel values are combined) happens in the PS4 itself. I can output gyro values from the EDTracker device to joystick XYZ values and map them back to gyro values to feed the PS4 but I haven't yet gotten the accel values out at the same time. And, ideally, I'd have them output straight to the gyro and accel fields that the T2 reads from the DS4.

Baby steps but getting closer!
User avatar
DeviateSquirrel
First Sergeant
First Sergeant
 
Posts: 46
Joined: Sun Jan 17, 2021 11:07 pm

Re: PS4 Dual Shock Motion Control

Postby Yearoh » Thu Mar 25, 2021 10:24 pm

This is a thread about gyro control I posted ages ago, it’s not going to have any magic bullets but there’s some C++ code That might help you (maybe)
User avatar
Yearoh
Master Sergeant
Master Sergeant
 
Posts: 38
Joined: Fri Jul 10, 2020 9:32 am

Re: PS4 Dual Shock Motion Control

Postby DeviateSquirrel » Thu Mar 25, 2021 11:12 pm

Did you forget the link?

I think the code pulling the data off the IMU is correct. It’s pretty straightforward; just query the IMU to get raw values and convert them into real-world units.

Right now I’m assuming either that DS4 is sending something else that I haven’t been able to identify or that the data coming from the IMU is being changed in some way before it gets to the PS4.

What I have now is working insofar as when I rotate the IMU my view changes in game but that’s about it. With even minimal use the view gets stuck to one side or the other. Feels like gimbal lock. As I understand, the DS4 doesn’t have anything onboard that could prevent it so that’s likely being managed by the PS4 or the game.
User avatar
DeviateSquirrel
First Sergeant
First Sergeant
 
Posts: 46
Joined: Sun Jan 17, 2021 11:07 pm

Re: PS4 Dual Shock Motion Control

Postby SirBrass » Fri Mar 26, 2021 1:09 pm

DeviateSquirrel wrote:Did you forget the link?

I think the code pulling the data off the IMU is correct. It’s pretty straightforward; just query the IMU to get raw values and convert them into real-world units.

Right now I’m assuming either that DS4 is sending something else that I haven’t been able to identify or that the data coming from the IMU is being changed in some way before it gets to the PS4.

What I have now is working insofar as when I rotate the IMU my view changes in game but that’s about it. With even minimal use the view gets stuck to one side or the other. Feels like gimbal lock. As I understand, the DS4 doesn’t have anything onboard that could prevent it so that’s likely being managed by the PS4 or the game.


I'm getting the same problem. Essentially gimble lock.
User avatar
SirBrass
First Sergeant
First Sergeant
 
Posts: 55
Joined: Sat Dec 05, 2020 3:47 am

Re: PS4 Dual Shock Motion Control

Postby SirBrass » Fri Mar 26, 2021 1:14 pm

From what I observe, accel values map to ds4 rotational position between values of -25 to 25 for each rotational axis (rotation about x, rotation about y, and rotation about z). The gyro, however, seems to bounce around between 1 and 10. It moves from jittering around 1 when the controller is in motion.

Does that help?

My thought is to possibly use T2 code to adjust gyro from 1 to 10 when your view input to the T2 changes, and directly convert position to the appropriate accel values (simple algebra).

If y'all could also be sharing your experimental T2 code, that'd be helpful.
User avatar
SirBrass
First Sergeant
First Sergeant
 
Posts: 55
Joined: Sat Dec 05, 2020 3:47 am

Re: PS4 Dual Shock Motion Control

Postby DeviateSquirrel » Fri Mar 26, 2021 2:44 pm

Most of the code is in the Arduino board on the EDTracker. I’ll pull the relative files and post a link later today.

I think there’s more to this. Accel values can go beyond 25 either way, though practically it’s unlikely as you need to put more effort into moving the controller than you’re likely to do in game. Likewise, gyroscope values aren’t limited to -10 to +10.

The code for JoyShockMapper (https://github.com/JibbSmart/JoyShockMapper) shows one way to use a device with a gyroscope and accelerometer to determine orientation and maps the vector components to XY. EDTracker (https://github.com/brumster/EDTracker2) essentially does the same thing. On a PC these XY values are enough for Elite Dangerous. I think they’d also be enough for Elite Dangerous on a console if you only wanted/ needed headlook occasionally (through a momentary or long lasting toggle). I want headlook to work continually like it does on a PC, however. For that, using the above approach, I’d either need a pair of analog axes or four digital inputs that wouldn’t get in the way of other inputs. There’s already so much to control in Elite Dangerous that, with the limited inputs available on console, I’ve not gone down this path yet (though, at this point, I think I’ll have to). Finding those inputs, and programming the T2 so they don’t get stepped on, is my next step. If we can do that we can ignore the accel/gyro inputs completely.
User avatar
DeviateSquirrel
First Sergeant
First Sergeant
 
Posts: 46
Joined: Sun Jan 17, 2021 11:07 pm

PreviousNext

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 69 guests