E poc Emotiv

Hi, help me please

How integrate Emotiv epoc with UE4?

The best place to start would be to create a new plug-in. We recommend that people use plug-ins, because it makes it easier to share your code with others, and easy for people to load and unload depending on if they have the corresponding hardware!

I would start by creating a plug-in that when loaded, tries to hook into the Epoc device. Then, I’d make a new UActorComponent called UEpocComponent, which can have hooks to access the data and events from the Epoc. The advantages of using a component for this is that you can easily attach one to any actor that needs the data or events directly, and the interface can remain the same between native code and Blueprints.

You also have the option of making a BlueprintFunctionLibrary defined class with a set of static functions that you can use to read the data from anywhere. However, if you need event callbacks from the device, this is a less flexible way to go about the integration.

Hope that helps, good luck!

Heyho! I’m trying this on many different ways, without success so far… please help me get this running, i will also share the solution.

my last attempt orientated at your advise, Nick Whiting: I took the BlankPlugin to start with the EmotivPlugin creation.
to make use of the static functions for connection and receiving data packages from the epoc, I integrated the .libs and .dlls in the plugin’s build.cs via:

[FONT=Courier New]PublicLibraryPaths.Add( EmotivSDKPath );

PublicAdditionalLibraries.Add( Path.Combine(EmotivSDKPath, “Libraries”, “edk.lib”) );
PublicAdditionalLibraries.Add( Path.Combine(EmotivSDKPath, “Libraries”, “edk_utils.lib”) );

PublicDelayLoadDLLs.Add( Path.Combine(EmotivSDKPath, “Libraries”, “edk.dll”) );
PublicDelayLoadDLLs.Add( Path.Combine(EmotivSDKPath, “Libraries”, “edk_utils.dll”) );

PrivateIncludePaths.Add( Path.Combine(EmotivSDKPath, “Includes”) );

The header files, delivered with the EmotivSDK are included and found, the compiler just can’t link the function’s implementation.
When trying to use a static function from the EmotivSDK, like [FONT=Courier New]EE_EngineRemoteConnect, the compiler gives the following error-message:
[FONT=Courier New]error LNK2019: unresolved external symbol __imp_EE_EngineRemoteConnect referenced in function “private: virtual bool __cdecl FEmotivPlugin::ConnectToEpoc(void)” (?ConnectToEpoc@FEmotivPlugin@@EEAA_NXZ) D:\Entwicklung\UnrealEngine4\Emotiv1\Intermediate\ProjectFiles\EmotivPlugin.cpp.obj

I tried a lot, but no matter what, the compiler complains on this… while the path of the libraries are correct (otherwise the compiler complains about not finding the files).

So here is the plugin, to catch the problem: EmotivPlugin@DropBox

I hope you can help me, my head is exploding xD
thanks!!

I asked about this on Emotiv’s forums, I’d be interested in what you can create because as they said they won’t develop a wrapper or a plugin unless there is high demand.

I think, to fusion EmotivSDK and UE4 should not be the big deal. The EmotivSDK is free (Link!) and comes with libraries and documentation, along with many code examples. The Hardware is not even needed by using its emulator.

If we got the configuration of Unreal Build Tool once for adding the libraries to the plugin, we can share it then for easy access.

So let us find a solution together :smiley:

Just wanted to give a heads up that if you’re looking for some examples of how to integrate inputs with ue4, all of my current plugins (see sig) are available on github and use the component + interface setup for event-driven bindings along with input mapping support. 2 bind to SDK libs, headers and dlls and one uses a direct dll bind due to lack of required lib. Hopefully that should give you a good starting point and following the emotive api will take care of the rest.

Emotiv use in VR should be very interesting, how accurate is the device in real world scenarios?

Darn, this reminded me that I own one of these headsets which I never even tried. I got a brand new one on eBay half-price and it’s been sitting on the shelf ever since.

I’d love to help this effort but I have so little free time lately I’m afraid to jump into yet another project. :frowning:

I’ll subscribe to the thread and lurk for the time being…

this is nice. but the plugin is still not working :frowning:
To access the [FONT=Courier New]edk.dll directly via [FONT=Courier New]FPlatformProcess::GetDllHandle(*DllFilepath) returns a null-pointer… trying the [FONT=Courier New]sixense_x64.dll instead works fine here.

What about the libraries are not compatible with UE4? The [FONT=Courier New].libs and [FONT=Courier New].dlls came from a win32 folder in the Emotiv SDK. There’s no win64 version, could this be the problem?

The UserManual tells us this:
“Emotiv delivers the Emotiv API in the form of a dynamically linked library named edk.dll.”
“The Emotiv API is exposed as an ANSI C interface that is declared in 3 header files (edk.h,
EmoStateDLL.h, edkErrorCode.h) and implemented in 2 Windows DLLs (edk.dll and
edk_utils.dll). C or C++ applications that use the Emotiv API simply include edk.h and link
with edk.dll.”

My Brother is working with the Emotiv Epoc for Neurofeedback, so I just got positive responses. This is a topic, where Games play a big role in psychotherapy, while UE4 will bring the perfect user experience to the therapeutical software-“tools”.
I think, the Epoc is a nice tradeoff between functionality and consumer friendliness.

And soon we will have the Emotiv Insight.

So the reason hydra needed a direct dll bind was that the static lib wasn’t compiled for VS2013(1800) and I knew the direct dll api binding from my experience with UDK. Leap and Myo use modern SDKs with up to date developer resources so this hasn’t been an issue for those.

The lack of a 64bit dll may be a showstopper though. UE4 shipping mode supports the 32 bit mode, but I can’t imagine trying to develop with constant cooking and repackaging. Try the emotiv forum to see if you can get them to build 64bit binds.

If you do find the 64bit dll, do note that with C++ access you can alternatively use a direct windows bind if need be. All you need to do is find an emotiv example that compiles and copy that implementation. Including Windows.h works without issue (example use case is the JoystickPluginby Ikarus76 which binds to windows DirectInput). That said it is most likely the 32/64bit issue not the UE dll bind wrapper.

from GitHub - codehunks/emotiv: Sample Apps for EPOC EMOTIVE device

thx, this is so helpfull!
really looking the wrong way all the time :o I will try this way, getnamo.

Yes! I’m looking forward to this! The main functionality and practicality will be awesome, so many genius game mechanics are possible! also easy stress-level diagnostics, etc.
For eeg-raw-data processing, I think the Epoc+ will be the choice, cause of more sensors for better localisation of certain brain-activities. just the wetting of the sensor-pads sucks xD

still waiting for the anser of the Emotiv Support Team: http://emotiv.com/forum/messages/forum15/topic4501/message19613/?result=new#message19613

While By using [FONT=Courier New]HINSTANCE dllHandle = LoadLibrary( TEXT( “edk.dll” ) ); from the [FONT=Courier New]windows.h, it would be possible to avoid the UBT here?

For my personal purposes, I would create a [FONT=Courier New]CortexComponent which handles EmoData-package interpretation from the Epoc per Tick. While there is only one Epoc on the client, A [FONT=Courier New]PlayerCortexComponent is derived from [FONT=Courier New]CortexComponent to manage library loading, Epoc connection and EmoData-package delivery per Tick. Along with an [FONT=Courier New]AiCortexComponent, derived from [FONT=Courier New]CortexComponent, to simulate the EmoData-package delivery.
while the data interpretation and game reactions in [FONT=Courier New]CortexComponent could get overridden individually, these classes and the [FONT=Courier New]dll’s would be easily sharable.
Do not have a clue how to manage networking, but are there objections on going this way?

This seems reasonable. I generally try to follow the API that sdk uses so that users can e.g. Emotiv’s documentation to understand the how of what they want achieve easier. For the unreal side having your data encapsulated as a component allows users to add emotiv capability to any of their own classes.

Additionally I recommend emitting events (via an interface) with your data as this can cut down on the downstream complexity; events tend to encapsulate the context in a much cleaner way. In the Leap plugin for example this means only receiving finger moved events if a finger has been detected and is visible. A user interested in the finger data won’t have to do their own checks and can simply subscribe to the event and act on it when it emits.

after getting a x64 version of the libs and dlls, the dllhandle worked! to get around all the bindings, i integrated the libraries according to the Linking-Static-Libraries-Turotial.
While this is not very encaplulated by a module or plugin, i made it as sharable as possible: https://github.com/Schlabbermampf/EmotivSDK-UE4-integration
this should give you at least the entry point to work with the epoc like they do it in the EmotivSDK examples… in UE4 code.

the CortexComponent is successfully connected to the EmoComposer, which emulates the actual Epoc for development.

what you think? feel free to improve this!
thx guys!

Codewise, looks like a good start, unfortunately I don’t have an epoc to try it out.

Integrate some of their api and post a video of controlling cubes with your mind, should be quite awesome to watch :slight_smile:

UPDATE: take a new look at my github code. all the expressiv, affectiv and cognitiv properties are usable! Still waiting for my brother to bring his epoc around for testing this!
I got no access to an SDK Lite x64 version of the libraries :frowning: In solved it by using the licensed SDK libs and dlls which are available in win64 and win32. Sry, but i removed libraries.

there are still troubles with some static functions from the EmotivSDK, the whole UE4-Editor freezes when for example [FONT=Courier New]EE_CognitivSetActiveActions( UserID, activeCognitivActions ) is called… no clue… emotiv forum… :smiley:
To use the Details Panel for connecting and training, call the CortexComponent’s [FONT=Courier New]OnConstruction() function in the [FONT=Courier New]OnConstruction() function/event of the appended Actor (is there a better solution for this?).

there are a lot of complains about the cognitiv suit, but i read this post from Emotiv that impressed me: https://emotiv.com/forum/forum4/topic4143/messages/
I think a Locked-In patient could handle around 6 cognitiv commands (with training, like a blinded has more capabilities for the other senses) for Computer-Aided-Communication. Thanks to UE4, this already has a beatifull userexperience built-in ;D

Getting Access to beta-alpha-theta-delta waves by computing the raw eeg data is quite a lot of work if you want to dive into neurofeedback and/or therapy.
This is very usefull (take a look at the last post from gmac, sounds very complete and straight forward, just needs to be pressed in code): https://emotiv.com/forum/forum15/topic2118/messages/

Any success on this? Just interested…

I sent them some questions and never got answers so I completely lost my interest on this.

I just wanted to use the Epoc as a marketing gimmick to attract clients but it’s too much of a hassle.

I still believe that using the Epoc in combination with VR would be cool, we’ll see what happens…

I research brain-computer interfaces and I have an Emotiv EPOC+ feeding data into UE4… but I don’t do it directly. For research purposes, you almost always want to copy data to a file. Also, the EEG usually requires some signal processing before you provide any real feedback.

I’ve implemented this two different ways.
(1) Use BCI2000 to get the data from the EPOC (it has a module for that already), and use its AppConnector to transmit the control signal via UDP. You then need a UDP receiver in UE4 to read the data stream.
(2) Use LabstreamingLayer to send out a control signal stream. In UE4, use a plugin to read in the labstreaminglayer stream. I already have a plugin that does this but it’s closed source for now. It needs some work before I release it into the wild.

For both approaches you will need to run at least 1 separate process to read the data from the device and push it (or a processed derivative of it) to a stream. This also solves the 32/64-bit problem.

These notes are intended to help anyone get started that wants to take this approach. I don’t intend to provide specific instructions on any of this. Sorry.

Did you make it? it is runing now? i’m thinking in making a project with emotiv and unreal, and i’m noob at programing for UE4 really need this