Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extremely lost #17

Open
JunSeiichi opened this issue Mar 3, 2023 · 9 comments
Open

Extremely lost #17

JunSeiichi opened this issue Mar 3, 2023 · 9 comments
Assignees

Comments

@JunSeiichi
Copy link

Hi all, I would like to integrate this API into my unity 3d environment as part of my university project. Upon reading the steps listed in the README, I'm completely lost. May I seek assistance or if there is a video guidance on the integration of this API into an external unity workspace? If no, other than importing the entire repository as a plugin into my unity work space, which is the specific line I am supposed to change (for the clientId etc)? And after which, is there additional coding required on my end in order to interact with this plugin?

In addition, I would like to know if it is feasible to use the specific parameter within the performance metrics (met) to be served as a control mechanism (ie: Focus parameter into a lighting object) to control the lighting environment. If not, would it simply meant that I can only use the entire met parameter itself to perform this interaction that I wanted?

Hope to seek any advice soon!

@tungntEmotiv
Copy link
Contributor

Hi @JunSeiichi ,
Sorry because the README can't help you. Have you tried with SimpleExample.unity (https://github.com/Emotiv/cortex-v2-example/tree/master/unity/Assets) ? In the example we tried to wrap some function for easier use.
The workflow should be:

  1. Fill the clientId and clientSecret of your application
    // Please fill clientId and clientSecret of your application before starting private string _clientId = ""; private string _clientSecret = "";
  2. Init EmotivUnityItf and call start
    // init EmotivUnityItf without data buffer using EmotivUnityItf _eItf = EmotivUnityItf.Instance; _eItf.Init(_clientId, _clientSecret, _appName, _appVersion, _isDataBufferUsing); // Start _eItf.Start();
  3. Create a session with your headset( you should put the headsetId)
    _eItf.CreateSessionWithHeadset(HeadsetId.text);
  4. After create session successfully, you can subcribe data, create a record, load profile for training etc..
    Please let me know if I can help more. Thanks

@JunSeiichi
Copy link
Author

Much appreciate with the response. If there's any issue I faced in the next few days, will bring it up. May I also check if there is already a SDK approval license and Emotiv Student Subscription already been made approved, would I be able to make use of the Performance Metrics suite to control certain objects in the workspace?

As per brought up earlier, I would like to make use of the PM to control a "Lighting" object such that when the user is concentrating on the "game", the "Lighting" will be brightened up and vice versa.

@JunSeiichi
Copy link
Author

Hi @tungntEmotiv , I've dropped you an email hoping for a quicker response.

Right now, I'm facing the error code of 32135 pertaining to the incorrect cortex token.
This is after my "attempt" in integrating the cortex API to my workspace.

I have also tested out the simpleexample that you had link earlier and there's no issue with it which led to me adapting the code into my environment with some removal of codes to fit my usage.

Please do assist pertaining to the error code as it is not found in the documentation.

@tungntEmotiv
Copy link
Contributor

Hi @JunSeiichi,
Sorry for late response.
The error said that the cortex token is used in generateNewToken() api is not match with the cortex token generated after authorize api . I don't know why you get the issue. So my suggestion to fix this issue as below:
In the file https://github.com/Emotiv/unity-plugin/blob/master/Src/Authorizer.cs line 363
You change as below:
// notify change sate ConnectServiceStateChanged(this, ConnectToCortexStates.Authorizing); _ctxClient.HasAccessRights(); return;
We will re-authorize each time open your application instead of call generateNewToken()
If issue still happen, please send us the the clientId which used for your application.

@JunSeiichi
Copy link
Author

JunSeiichi commented Mar 10, 2023

Hi @tungntEmotiv ,
Thanks for the response, I've managed to get through the token issue with the provided remedy.

The next query that I would like to clarify is that is it possible to use a specific PM suite expression to control an gameobject in unity? Say the Focus of emotiv PM suite to control a light gameobject.

@tungntEmotiv
Copy link
Contributor

Hi @JunSeiichi ,
I think you can use PM expression to control something. You can reference below guide
After create session with the headset as I mentioned above. You need to subscribe "met" for performance metric
as below:
List<string> _streams = new List<string> {}; _streams.Add("met"); _eItf.SubscribeData(_streams);
You can see the output for performance metrics data kind of https://emotiv.gitbook.io/cortex-api/data-subscription/data-sample-object. You can control the light base on the focus value returned .
Another way to control something by our brain easier by training your brain then subscribe "com" for mental command . Reference to https://emotiv.gitbook.io/cortex-api/bci

@JunSeiichi
Copy link
Author

Hi @tungntEmotiv .
Thanks for the response. Pertaining to the subscription that you have mentioned above, I've already linked them up and getting output for the performance metrics, but with regards to the extraction of the focus value, how would I be able to extract and send this focus value feedback from the output string as stated in the documentation back to unity then? Right now, I'm only seeing it as output as an array of strings.

"met":[false,null,false,null,null,false,null,true,0.266589,false,null,true,0.098421],

Pertaining to the alternative method that you've proposed, I will not be using it as it is not the core of my project.

@tungntEmotiv
Copy link
Contributor

Hi @JunSeiichi ,

As API documentation the focus value relates to 2 last indexes. For example: "foc.isActive" =true,"foc" = 0.098421 as you mentioned as above. You might check if "foc.isActive" = true -> get the focus value.
Sorry we can not help to do some example code to extract the focus value, you might do it yourself.

@JunSeiichi
Copy link
Author

Hi @tungntEmotiv,

Thanks for the suggestions, might want to check if this retrieval is only valid if we are using DataBuffer? Since if we do not use Data Buffer (_IsDataBufferUsing = false), there will be a need to getPM data prior to the checking of the "foc.isActive".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants