labstreaminglayer / plugin-UE4

LabstreamingLayer plugin for Unreal Engine 4
MIT License
10 stars 7 forks source link

How is this supposed to work? #3

Closed AlePax closed 3 years ago

AlePax commented 4 years ago

Hi there!

I'm trying to get some LSL streams into UE4 using the latest build (Muse2+BlueMuse), but I just can't understand how is this plugin supposed to work...the editor just keeps on crashing whatever BP LSL node I use... is there an example map and/or blueprint you can share, or just some hints on how to get EEG and PPG streams maybe? Thanks in advance!

cboulay commented 4 years ago

Before starting with the UE4 plugin, can you confirm that you can access your streams using simpler approaches like LabRecorder and/or pylsl?

AlePax commented 4 years ago

Yeah, I can access the streams through BlueMuse, already tested in OpenVibe and I can see / process streams. For testing purposes I created an actor BP and put it in the scene. The BP has inlet and outlet LSL components in its root. I'd like to get the heart pulse value from the Muse PPG stream and pass such value to a variable. EEG stream will be processed through OpenVibe and sent to BCI-UE4 plugin through TCP, but I might consider doing everything with your plugin too. image image image

P.S. A little warning: I'm a complete noob regarding EEG stuff, just started exploring! But I know UE4 enough, been developing VR apps for the last 5 years.

cboulay commented 4 years ago

In the screenshot above you seem to be setup for an Outlet, but that's not what you want. To get the data in from another source (Outlet) you need to create a sink (Inlet). Then you'll have to provide the Inlet with the information it needs to resolve the stream. In the LSL Bridge screenshot, you can see the info you need: stream names (both use "Muse-83FD") and the types ("EEG", and "PPG").

AlePax commented 4 years ago

Mmhmh OK, not working yet... log reports a single value of 0.0. What am I missing here? image image image

cboulay commented 4 years ago

I haven't used UE4 in about 6 years so I can't remember what's needed to get the On Stream Updated to be setup correctly. I'm sure you need an Inlet configured but I don't know how you connect that component to the inlet. Anyway, once that's setup correctly, you should be able to run its output into the For Each Loop, then log the individual elements.

"On Stream Updated Float" --> "For Each Loop" --> "Print String"

I'm not sure, but I think the DEBUG block is incorrect. My reading of it is that you are copying the Inlet's array to a variable called "Inlet Stream Array" then, upon an event, you're printing the contents of that array. However, on BeginPlay, the inlet's array is empty, so copying it will copy an empty array. If my understanding is incorrect, and SET doesn't copy but makes a pointer, then I would expect the block to work, but you will have to trigger your TEST event many times.

Maybe @brifsttar can help?!

AlePax commented 4 years ago

Haha, great! 👍 yeah you're right, if things work like that the value is 0.0 upon begin play. Thanks for the hints anyway, gonna test a little bit more and keep you posted if I ever succeed! :)

brifsttar commented 4 years ago

Hi,

I had never tested inlet before, so I just made a PR for a fix (#4). It tested the following BP, it works as intended:

image

cboulay commented 4 years ago

Thanks @brifsttar !

@AlePax , just to be clear, the LSLOutlet in @brifsttar 's example is just to generate some dummy data and push it to a stream so the LSLInlet has something to pull from. In your case, you already have an Outlet somewhere else on the network (coming from a muse) so you only need the top part of the blueprint.

AlePax commented 4 years ago

Great! Thanks guys, gonna test ASAP! 👍

AlePax commented 4 years ago

I run a test with the latest build, but I cannot read the stream from device.... LSLInlet always reports a single 0.0 value and only if I call OnStreamUpdate. When I try the above example BP the simulated LSLOutlet stream works regularly.

I double-checked the device with OpenVibe server / client and it all works. Thanks for the support guys, but I suspect I'm gonna need another way to get PPG stream into UE...

cboulay commented 4 years ago

I double-checked the device with OpenVibe server / client and it all works.

I don't know what this means. Are you sure this is using an LSL inlet and that it's fetching data? To verify that the PPG stream is in fact working properly, I would suggest using something that you can be certain is trying to use the LSL inlet in the correct way. I can recommend BrainProducts LSL viewer: https://pressrelease.brainproducts.com/lsl-viewer/

If that shows the PPG data streaming, then yes it's a problem in the UE4 implementation.

AlePax commented 4 years ago

I don't know what this means. Are you sure this is using an LSL inlet and that it's fetching data? To verify that the PPG stream is in fact working properly, I would suggest using something that you can be certain is trying to use the LSL inlet in the correct way. I can recommend BrainProducts LSL viewer: https://pressrelease.brainproducts.com/lsl-viewer/

If that shows the PPG data streaming, then yes it's a problem in the UE4 implementation.

I mean I can see LSL streams perfectly. Gonna test that lsl-viewer too.

EDIT: it works for both streams, EEG and PPG.

Screenshot (131) Screenshot (130)

cboulay commented 3 years ago

Hi @AlePax ,

I finally had an excuse to use this plugin today so I did a little updating and documentation.

AlePax commented 3 years ago

Great, thanks! :) Gonna check ASAP!