Source code for the MiniSeg Real-Time Systems course project of Lund University. It enables the MinSeg robot (Visit website) to balance itself and to follow translational position setpoints. Additionally, a graphical user interface to communicate with the robot and to tune the controller is provided.
Have a look at the wiki for a detailed explanation of the achievements of this work.
This repository contains both the controller code and the graphical user interface. If you're an LTH student taking the FRTN01/FRTN60 project course or you're working on stabilizing the MinSeg for another reason, feel free to take the code presented here as a guide. It is worth mentioning that the controller was tested with an internal measurement unit called MPU9250. So if your MinSeg comes for instance with a MPU6050 you will have to use a different approach for reading the sensor values.
The possibility to visualize real-time data and communicate with the Arduino is very useful regarding the development process. If you've understood how to define a communication interface and how to use the GUI and the Arduino communication API, you can accelerate the development process significantly. So feel encouraged to make use of the user interface during your work.
The communication between both instances takes place using Bluetooth and is defined in a global interface file according to the JSON format. In case the communication interface needs to be changed, this file needs to be updated.
The C communication interface code generation is automated by this script. The controller can make use of the updated interface after the code generation.
The GUI reloads the interface definition dynamically on every bootup, so nothing has to be changed manually.
The code for the controller is located under controller and can be compiled and uploaded to an Arduino (Tested with Arduino Mega 2560).
The graphical user interface is built using the Qt framework and its python bindings. The python environment can be built using Python 3.10 (download) by typing:
cd gui # Source directory should be miniseg/gui!
your\local\python\install\dir\python.exe -m venv venv
venv\Scripts\pip.exe install -r requirements.txt
cd ..
Before being able to run the GUI for the first time, graphical resources must be generated by running the resource generation sctipt.
# Make sure to run this in a Windows Powershell terminal!
.\gui\resources\generate.ps1
If Windows doesn't allow you to run Powershell scripts, then you might have to set the execution policy according to
# Make sure to run this in a Windows Powershell terminal!
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
When the above has been followed correctly, the GUI can be run from the repository root by typing
# Make sure to run this in a Windows Powershell terminal
# and the current directory is the repo root
.\run.ps1