This tutorial shows how to control Maqueen V2 robot with your mind using OpenBCI board and MindAffectBCI open source application.
What you need:
- OpenBCI board (Ganglion Board or Cyton Board)
- EEG Headband or cap
- EEG electrodes + cables
- MindAffectBCI
- Maqueen V2 Robot
- Micro:bit
1. OpenBCI board
In this case I used a Ganglion Board. Please make sure to visit OpenBCI documentation page. All the necessary information about the setup and specification are included there.
We are using EEG signal so please remember that as Ganglion specification says:
And all the wires should be connected to top pins:
2. Headband and electrodes
For a headband I recommend to use a solution provided by MindAffectBCI on github. All you need to do is to 3D print stl models below:
attachment.stl (2x)
headstrap_integrated_electrodes.stl (1x)
And to assemble elements and connect with M3 screws and velcro tape. Also OpenBCI electrodes fit perfectly the holes diameters.
For a better signal quality I also recommend to use additional sponges soaked with water like in the picture below:
3. MindAffectBCI
You can download MindAffectBCI open source application here.
On their documentation website you will find all the necessary information about how to set up the environment. If you are new to programming I suggest to install IDE of your choice (I use Intellij).
If the installation was successful you can now test the app and execute this command (use fakedata_test.json):python -m mindaffectBCI.online_bci
If everything is fine and the app is up you should see this menu:
You can start testing the MindAffectBCI app. Try to do Calibration and then Cued Prediction. If during the prediction option you don’t see that system marks blue the predicted option look into the logs.
If you see this error:
Go to decoder.py file and in line 510 change:np.bool
to np.bool_
Also make you sure you have installed Java version 1.8 or lower. Some functions in the Utopia server app will not work on java higher than 1.8.
You will notice that something is wrong if you go to Electrode Quality in the main menu and you see that all electrodes have fixed 0.5 signal.
4. Modifying MindAffectBCI to work with Maqueen V2 + Loader
Now when MindAffectBCI app works we can modify configuration so it worked with Maqueen V2 robot.
In this case go to this github repository and download it.
You can now copy files from this repo to the MindAffectBCI repo corresponding path.
Please be sure to set a correct port in movement_output.py. You can verify ports in Device Managers/ports.
Now you can run the MindAffectBCI app with fakedata_test_maqueen.json to test direction prediction.
Calibration should look like this:
5. Micro:bit and Maqueen setup
Connect Micro:bit microcontroller with your computer via USB port.
Go to python.microbit.org/v/3 and copy the code from microbit_maqueen.py and paste it in the script field on the site:
You can now send it to micro:bit
If you have an additional loader all you need to do is just to connect micro:bit with the Maqueen robot.
I recommend getting a longer USB type B cable for connecting micro:bit. The one you get with a microcontroller is very short and it will be hard to test the Maqueen robot.
If you do not have a loader then you need to modify the files. Which is very simple:
1. noisetag_bci_maqueen.json – delete array [“up”, “down”] in calibration_symbols field
2. movement_output.py – delete functions down and up and values 5: up, 6: down from map objectID2Actions (line:52)
3. robot_control.txt – delete line:3 up, down,
If you would like to modify a robot movement or add new features you have many ways to experiment.
Link to the robot specification is here.
Link to the dfrobot forum is here.
LInk to Micropython documentation is here.
6. Testing
After successful setup we can now start testing controlling a robot with our mind!
Run the MindAffectBCI app with noisetag_bci_maqueen.json configuration.
If the app is up you can now run movement_output.py script which will be listening to the system prediction. You should see this in the logs:
You can now start calibrating the decoder.
But before that make sure that your electrode quality is good and stable.
If Calibration performance is low you can recalibrate it or increase the number in presentation_args.ncal field in noisetag_bci_maqueen.json.
In general the more data the better. Also electrode quality is crucial for the calibration process.
Once you calibrate the model you can go to the Free Typing option in the menu and start controlling a robot!
I hope you find this tutorial helpful!
If you have any questions or any information you would like to share with me feel free to contact me [email protected]
Fantastic work, Pyotr !!