FREE - Framework for Remote Experiments in Education

From wwwelab
Jump to navigation Jump to search

System architecture

In the defined architecture, users communicate with a central server, named FREE_Web, through web pages.

This FREE_Web server contains the database with the results of the experiments already carried out and the experimental executions and experimental time schedules requested by users through the web interface. The FREE_Web server is also responsible for mediating real-time communication between users and experiences, exchanging configuration requests, status requests and responses and generated data between users actively connected to the apparatus and apparatus.

Architecture of the new system. It is possible to observe the different layers of software that separate the users, on the left side of the image, from the experimental apparatus, on the right side of the image.


Along with the experimental apparatus, a computer, named RPi_Proxy, acts as an interface between the controller of the experimental apparatus and the FREE_Web server. Each RPi_Proxy is turned on and represents one, and only one, experimental apparatus. It is important to note that this component was named RPi_Proxy because it is, in principle, implemented through the use of a Raspberry Pi, a computer that has communication modules necessary to communicate natively with the microcontrollers usually used to control the devices. However, this component can be implemented in other ways and it is only strictly necessary that it communicates according to the protocol - e.g. a virtual experience with data generated through a numerical model can implement this component with a normal computer without specialized interfaces. The communication between all components is done over the internet, with the exception of the communication between the RPi_Proxy and the experimental apparatus, where communications are made through the protocol that the controller of the apparatus implements.

Communication protocol

To start the connection between the RPi_Proxy and the FREE_Web, when the RPi_Proxy is turned on, it tries to connect to the FREE_Web server. If not successful, it should wait 10 seconds and try again until it manages to make the connection.

  • Label
  • Label

When the connection is successfully established, the server RPi_Proxy sends to FREE_Webo its ID and Secret. These two variables are then checked on the FREE_Web server side as a simple way to authenticate that the connection is coming from an authorized machine. In case of successful verification, the FREE_Web responds to the RPi_Proxy with a message encoded in JSON format that describes the experience to be served by the RPi_Proxy. This configuration message allows the same RPi_Proxy program to be adaptable to different experiences with, for example, different numbers of actuators and sensors without changes to the source code. Based on the information contained in this message, the name of the config_file, the RPi_Proxy looks for the experiment at the indicated address and tries to establish communication with the controller of the experimental apparatus. In order to decouple the RPi_Proxy from the different communication protocols that each experimental controller may implement, the RPi_Proxy must communicate with the devices calling a set of standard methods whose implementation must be adapted to suit the target controller.


(TODO)


After this initial configuration, the connection of the RPi_Proxyao FREE_Weband the RPi_Proxyto the controller of the experiment, the system is ready for the exchange of messages between the components. The messages exchanged between components were defined following an everything is a string philosophy. Thus, the messages exchanged are JSON-formatted strings in which the JSON fields encode the message to be transmitted. The type of each message is identified by the msg_id field of the message JSON, and for the message sent, the reply, if any, must have reply_id with the same value. In order to be adaptable to various types of experimental apparatus, the system does not store apparatus status information so it is possible to send any of the defined messages at any time. The correct sequencing of messages for the successful operation of the apparatus is the responsibility of other user-controlled software layers.

Functions documentation

FREE_Web

RPi_Proxy

interface.py(RPi_Proxy)

How to install

Pre-requisites

Build environment

  • Git (2.30.2+)
  • Python (3.7.0+)

Raspberry PI (RPI_Proxy)

First checkout the project from github (https://github.com/e-lab-FREE/RPi_Proxy), and you can get the code using:

   $ git clone https://github.com/e-lab-FREE/RPi_Proxy

After following the installation guide on the github, you will geet a version of the RPi_Proxy that is able to communicate with a pic experiment and it is configured in particular to communicate with a pic that performed a Pendulum experiment, for changing the experiment the only thing you need is to change the "experiment_details.py" on the pic_intreface folder. We have some of these files for different experiments such as the Langmuir on the following repository: pic_interface.

It's possible to connect experiments that are not controlled with a pic, for example, we have on e-lab an experiment controlled by a Rasberry Pi. To do that it was needed to change the code on the "interface.py" but the name of the function need to be maintained. The code for this RPi_Proxy is presented on the following github: Cavity.

Main Server (FREE_Web)

This software is the dispatcher of the information. By allowing the communications form the frontend and each RPi_Proxy responsable for a experience. To install this you need to install at least Python 3.7.

Then go to the project on github https://github.com/e-lab-FREE/FREE_Web and follow the steps of installation that we present there.

After the installation you will have the version of FREE 0.3.0 with a database and HTML page configured for a pendulum experiment as follow:


  • Label
  • Label

How to add new experiments

Frist one has to have a experiment programed in a controllor of such experiment, after that and after installing the Proxy on a computer capable to comunicate to the main sever, the developor of the experiment needs to create the following enteries on the database: Protocol, Experiment and Apparatuses.

Experiment

Label.

Protocol

Label.

Apparatuses

Label.

Video Streaming

Intro

Video capture and stream

On the raspberry it is running ....

Janus stream server

Accessing the stream

The experiment stream can be access by a html ....

or by using VLC, allowing to grab the video