Thursday, June 26, 2014

Screencast of the game - June 26, 2014

Link to Screencast of the game on June 26th 2014

Everything You've Ever Wanted to Know About the Emotiv Software Developer Kit (SDK)

Overview
The SDK is a toolset that allows the development of games or applications which use the Emotive neuroheadsets, The neuroheadset is a headset worn by the player/user which interprets brain signals and sends this information to the Emotive EmoEngine. The Emotiv EmoEngine translates the detection results into an EmoState, or a data structure containing information about the current state of all activate Emotiv detections. 

The Emotiv API (Application Programming Interface) will be useful to our project since it enables application developers to write software applications that work with the neuroheadsets and detection suites. 

The Suites:
Expressiv Suite: 
The Expressive Suite is responsible for handling the facial expressions of the player. Among the detected expression are blinking, winking, brow movement, and mouth movement (smile, smirk, laugh).
The sensitivity adjustment panel to the right of the Expressiv Suite panel allows the user to check the performance of the detection and adjust the sensitivity. If the expression is too easily triggered or "false positive" expressions are being detected, the sensitivity can be lowered.
Affectiv Suite:
The Affectiv Suite reports on the emotions experienced by the user and displays them in a real time graph.
The Affectiv Suite reports on engagement, boredom, frustration, meditation, and excitement (long and short term)
Cognitiv Suite:
Evaluates the player's brainwave activity to understand the user's intent to perform distinct physical actions on an object
The 13 actions are split into two groups-6 directional actions and 6 rotations plus disappear.
Cognitiv allows 4 of these actions to be chosen/recognized at a time, not including neutral. An action power is associated with each action as well.

Programming with the Emotiv SDK
Using the API to communicate with the EmoEngine:
Prior to calling Emotiv API functions and during intialization, the application must establish a connection to the EmoEngine by calling EE_EngineConnect or EE_EngineRemoteConnect
Use EE_EngineConnect to directly communicate with an Emotiv headset and EE_EngineRemoteConnect to communicate with SDKLite or to connect your application with EmoComposer or EmotiveControlPanel

EmoEngine publishes events that can be retrieved by the application by calling EE_EngineGetNextEvent( ). Most applications should poll for new EmoStates 10-15 times per second. (Can be done in main event loop or when other input devices are periodically queried).

To close the connection with the EmoEngine, call EE_EngineDisconnect ().

Categories of EmoEngine events:
-Hardware-related events: Events that communicate with users connect or disconnect Emotiv input devices to the computer (example: EE_UserAdded)
-New EmoState events - events that changed the user's facial, cognitive or emotional state
You can retrieve these by calling EE_EmoEngineEventGetEmoState ( )
-Suite specific events: Events relating to training and configuring Cognitiv and Expressive detection suites (example: EE_CognitiveEvent)

Most API functions return a value of type int. Most Emotive API functions return EDK_OK if they succeeded.


Connect to the EmoEngine:
Initialize the connection with the Emotiv EmoEngine by calling EE_EngineConnect ( ).

Buffer Creation:
Buffers temporarily use memory to store information while data is being transferred.
Buffer is created by using EE_EmoStateCreat ( ). Invoking EE_EngineGetNextEvent (), will get the current EmoEngine event type.
If result of getting the event type (EE_EmoEngineEventGetType ( )) is EE_EmoStateUpdated, there is a new detection event for a particular user. EE_EmoEngineEventGetEmoState () copies the EmoState information from event handle into EmoState buffer.
For example, ES_ExpressiveIsBlink (eState) could be used to access the blink detection.

EDK_NO_EVENT means that no new events have been published since the previous call.

EE_EmoStateFree ( ) / EE_EmoEngineEventFree ( ) can be used to free up memory allocated for EmoState buffer and EmoEngineEventHandle.

(I wonder if anyone's reading this still. If you are, congrats)

Cognitiv commands! (The fun part):
The user's conscious mental intention can be detected and control the movement of a 3D virtual object. The ouput of the Cognitiv detection indicates what the users are mentally engaged in at a certain time. These commands are then sent to a separate application called EmoCube which controls the movement of the 3D block.

Commands reach the EmoCube via a UDP network connection. The action/command is communicated as two comma-separated, ASCII formatted values. The first value is the action type and the second is the action power value, ES_CognitiveGetCurrentAction ( ) and ES_CognitiveGetCurrectActionPower ( ), respectively.

Above is an example of  calling the cognitive commands

Above picture shows how the cognitive training process works. 

Below is an example of extracting Cognitive specific event information from the EmoEngine event:

Cognitiv Training:
Before training an action, the action must be set using the API function, EE_CognitiveSetTrainingAction ( ). 
Examples of Cognitiv actions: COG_PUSH, COG_LIFT
If no action is chosen, neutral will be trained. 
To begin the training, use COG_START. If training is successfully started, an EE_CognitivTrainingStarted event will be sent. 
After 8 seconds of training, two events will be sent from the EmoEngine:
1. EE_CognitiveTrainingSucceeded: If the EEG signal was good enough during training to update the algorithm for the player's behavior/signature, the training will be updated.
2. EE_CognitiveTrainingFailed: If quality of EEG signal wasn't good enough, the process will restart and user will be asked to start the training again.




Wednesday, June 25, 2014

Scientific Computing Essentials - Lab 1

For our first Scientific computing essentials (SCE) assignment, we had to create a C++ program that would calculate the average, sum, minimum and maximum of a set of 920 random numbers we were given.

Creating the program involved utilizing the class fstream in order to read-in the numbers from the RandomNumber.tsv file. This was probably the hardest part of the project for me since it was something I'd never done anything like before.

We next worked on finding the sum of the numbers. At first, the function I created for adding the numbers was only adding the first number, so I had to create a while loop which would continue to add the numbers from the file as long as the numbers were still being read-in. 

Once we found the sum, we were able to find the average by simply dividing by 920, the number of random numbers in the file. This is a weakness of our program since it can only been applied to sets of 920 random numbers. 

We next found the minimum and maximum of our number set by using a function which first set an initial value for the maximum and then compared the subsequent numbers to the previously set value for the extreme, either minimum or maximum.  For example, to find the maximum we set our initial value as 0 since we knew we had many numbers that were greater than 0. This could be another weakness in our program since if the random number set's maximum is less than 0, the program would simply think the maximum was 0. We used the same idea to find the minimum, except our initial value was 1. Knowing we had many negative numbers, our minimum would surely be less than 1. However, this causes the same weakness we could potentially encounter with finding the maximum. 

Finally, we used cin and cout functions in order to print the sum, average, maximum and minimum.

Tuesday, June 24, 2014

Day 5 - June 24, 2014

Goal for the day: fix all the problems identified last week! 

The first thing I did today was to set the points back to 0 when the player dies. I also programmed the game to reset the points after the player completes the level. Therefore, the maximum number of points a player can score per game is 30.

Using a bool, I tackled the next of my problems and made the time stop when the player completed the game and had this time display on the pop-up screen at the end of the game.

Finally, I created a variable called finalScore (data type = float) which would be responsible for creating a finalScore out of the time elapsed in the 2nd level and the number of points scored. This involved transforming strings into floats and basic operators such as + and -.




Thursday, June 19, 2014

Screen cast of game prototype from 6-19-201

Link to a screen cast of the game prototype as of June 19th 


Day 4 -Setting up a scoring system

Created a goal at the end of the game plane which the player has to pass through to finish the level. At this time as well, the pop up window will appear that I set up previously.


Set up a scoring system where each block is worth 10 points. When the player block passes through them, the score total at the top left hand corner will update itself and the blocks that have been passed through are destroyed. 

I added the score gained by passing through the goals to the pop up window. 

Day 3 - Game Behavior


Day 3- June 17th 2014
Created a main menu with a GUI button that the player can click when he/she is ready to advance to the first level.


Changed the game behavior so that when the player block falls off of the game plane, instead of respawning back to its original position, the player loses and is taken back to a "die menu" which states that the player lost and has a GUI button for "Try Again" which will take the player to the first level. 



I also created a pop-up like window which will show up when the player block passes through a block which is the end of level 2. The pop up window shows how long the level took and how many points the player scored. 


In addition, I created a timing system at the top left corner which will reset for each level and play a part into calculating the player's score. (The faster they complete the level, the better). 

*This picture was taken on Day 4 after other aspects of the game were changed as well*

Friday, June 13, 2014

Day 2 - Creating a Game Prototype within Unity

Made it so that colliding with a box tagged goal would take the player to the next level. 

Also made it so that falling off the plane would take the player back to the starting position

Wrote a script so that when the player collides with certain blocks, it will win certain numbers of points. 

(Points show up on the bottom of the screen and are hard to notice though)



Got the player to be able to fly/jump (above picture)

Created  GUIText thing so that points would be more visible
Tried to write a script so that the point total would update itself, but:
Ended the day with all these fun errors ^ 

Tuesday, June 10, 2014

Day 1 - Moving a Block



Game Trial - June 10, 2014

Level 1 of the Earthquake game

-Unclear what to do once the blue and purple consoles are found
-Once the player falls into the water, it would be better for the game to end (take the player to a
game over" type of screen so they realize they can't swim in the water
-Better way of displaying the "find our friends and don't get wet" message
-putting the message on the people made it unclear that those people counted as the people that you had to find 
-adding a way of marking which people/consoles have been found, since they all are similar looking
-green symbols are confusing
-hard to understand what the symbols on the left side of the bottom right hand chart mean
-where's the math?