Welcome to the Python on LEGO EV3 Framework that was created in the course of the thesis "Open-Source LEGO EV3 Python
Framework for Teaching". The framework contains the two sample projects that where the main contribution of the thesis. In the following sections we will describe the steps you need to consider before using the projects on your EV3 robot. In addition the abstract of the related thesis is listed so you can get an impression of the work. You can access the full thesis [here](https://cloud.cps.unileoben.ac.at/).
## Preperation Steps
You need to prepare you EV3 Brick before you can use it with Python and the given projects.
### EV3 Dev
We chose the operating system _ev3dev_ which makes the Lego robots compatible with all types of script languages, inculding Python3. You need to download the latest image from the [EV3 DEV Website](https://www.ev3dev.org/downloads/). With the image you need to flash a microSD card. The software platform runs directly from the microSD card and does not interfere with the original firmware. After putting the SD card into your Brick turn it on and the Brick will start to boot. After the first boot that takes several minutes from now on your Brick will boot from the SD card everytime. There are several possibilitys to communicate with your brick but we connected it via a USB-Cable and used Microsoft's editor Visual Studio Code. But it is also possible to use other editors and communicate via an SSH connection. To see the alternatives and in case of problems visit the [Getting Started with ev3dev-Guide](https://www.ev3dev.org/docs/getting-started/).
You can download the editor [here](https://code.visualstudio.com/Download). The extension `ev3dev-browser` is specially created for working with devices on which the _ev3dev_ image is booted. You can install it directly inside the extension Browser of VS Code.
After installing the extension, you should see the text _EV3DEV DEVICE BROWSER_ at the lower edge of the Explorer. Click on the arrow next to the text and afterward on the appearing text "Click here to connect to a device". In the pop-upped box you can search for your device and by clicking on it, you can connect it. If the connection succeeded, you can see the device in the Explorer with a green dot on the right side. Once your device is connected, you can simply run the opened projects by clicking `F5`.
If you want a more precise instruction, visit this [GitHub Repository](https://github.com/ev3dev/vscode-hello-python).
### Dowload program
As a last step, you need to download the program code you want to run on your robot. Simply open the program inside of VS Code and, if needed, adapted the Ports according to your environment. When the program is customized and the robot is connected, simply press `F5` and the robot will download the program and run it.
## Open-Source LEGO EV3 Python Framework for Teaching: **Abstract**
The primary aim of the thesis is to explore the applicability of the programming language Python on the LEGO MINDSTORMS® Education EV3 set. As Python is one of the popular programming languages and important for the fields of data science and machine learning, applying it in the context of robotics is relevant for our university.
The EV3 Brick already has MicroPython, a slimmed down version of Python, available. Since it can be frustrating, not being able to use all one's knowledge, the application of the full Python libraries should be achieved by using the _ev3dev_ operating system.
The focus lied on creating two beginner-friendly sample projects that test the possibilities of the software platform.
The first project has a robot follow a given line with two different approaches. One program works direct with the color recognized and one with the intensity of reflected light, both measured by the color sensor.
The second project uses camera-based object recognition to have the robot sort two differently colored cubes. The device used for this is Pixy2, which is especially set up for working with the LEGO robotic sets. The program is build in an object-oriented way and switches between different methods that represent the states of the robot.
The test for evaluating the generated codes is based on varying environmental settings. The behavior of the robot inside them is documented and capabilities are summarized.
In the first project, the color recognition program is better able to cope with different environmental conditions, but rather slower and jerkier than the intensity of reflected light program under certain circumstances. Throughout the second project the work with the detection of Pixy2 was often
tedious as a big part of it was captured by troubleshooting rather than fully testing the capabilities in the environment settings.
The full project extent is documented on the Git of the chair, including the developed code. The framework on Git as well as the thesis illustrate that the use of Python on the EV3 is possible and rather simple with the _ev3dev_ system.