Skip to content

constantino-garcia/bitalino_controller

Repository files navigation

Bitalino controller in Python

A Python project designed to control a BITalino board by means of Plugins (inspired by the OpenBCI library). This repository is intended to provide a "bare-bones" BITalino controller, which should be improved as part of a undergraduate course on biosignals. Therefore, it is unlikely that new features will be added in the future. However, if you are interested in further develop the project, don't hesitate in forking it (see License).

Installation

This project is implemented in Python and should work for both Python 2.7 and 3.X. The code has been tested in both Linux and Windows operating systems. It should also work out of the box in MacOS-based systems (untested).

The project depends on the packages listed in requirements.txt. At the same time, some of these packages have some system-dependencies that should be met before trying to install them:

  • In MacOS: install git.
  • In Debian/Ubuntu-based distributions:
$ sudo apt install python-xlib libbluetooth-dev git
$ pip install PyBluez
  • In Windows: install git and then follow steps 1, 2 and 3 about preparing PyBluez on Windows 10. For step 4 we need to manually compile the PyBluez library. Open a Windows terminal that has python and git commands available (you may use Anaconda prompt) and proceed as follows:
# 1) Download the latest code
$ git clone https://github.com/pybluez/pybluez
$ cd pybluez
# 2) Build the library
$ python setup.py install
$ python setup.py bdist_wheel
# 3) Install the library. A .whl file should be available under dist. Note that the version number may differ.
$ pip install dist\PyBluez-0.30-cp38-cp38-win_amd64.whl

Once you have completed the previous steps, you may install the python dependencies using the following pip command:

$ pip install -r requirements.txt

Once all the dependencies are satisfied, it is enough to download the project sources and run the proper python script.

Basic usage

Before using the Python scripts the BITalino board should be Bluetooth-paired with your computer (Bluetooth code is 1234).

BitalinoController.py provides a simple user interface to manage plugins and communicate with the BITalino board. Several command line arguments can be used to configure the board. For a complete list, consult

python BitalinoController.py --help

For a basic usage, only the MAC address of the BITalino board is required:

$ python BitalinoController.py -m 20:16:02:26:61:54

The program should stablish a Bluetooth connection with the board and open a simple terminal (indicated with a $ symbol). Available commands are:

  • \start: starts the streaming of data.
  • \stop: stops the streaming.
  • \exit: ends the script.

Plugins

Use of plugins

Plugins are based on the Yapsy plugin system. To obtain a list of the available plugins, the following command can be used:

python BitalinoController.py -l

Art the moment, only two plugins are available. A print plugin and a TCP-streaming plugin. Please note that, as part of the course, the TCP-streaming plugin is severely limited, and it only streams the last active channel.

The Yapsy plugin systems looks for available plugins under the plugins folder. To use a plugin just use its name after the -p argument. Additional arguments for the plugin should be specified after its name. For example, to print samples and stream the last active channel through TCP to the local 6666 port:

python BitalinoController.py -p stream 127.0.0.1 6666 -p print

Create new plugins

To create a new plugin, a new class extending IPluginBitalino should be created. For a minimal example, see plugins/PluginPrint.py. Finally, describe your plugin with a [name-of-class].yapsy-plugin (see plugins/PluginPrint.yapsy-plugin).

A basic visualization tool

When using the BitalinoController with the default parameters of the PluginStream, a basic signal visualizer can be used if the optional-requirements.txt file has been installed:

$ pip install -r optional-requirements.txt # installs additional optional dependencies

The following command starts a client listening at localhost:6666 which plots the channel streamed by PluginStream:

$ python BitalinoGUI.py 

License

This project is licensed under the terms of the GPL v3 license.

About

Python controller designed to work with BITalino boards through plugins

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages