Prerequisites • Compile • Execute • Commands • Documentation • GUI Screenshots • Demo
Tanks Simulator is a liquid tank control system game that features a graphical user interface and a set of tasks for tank, sensor, user input, and graphics management. Built using Allegro 4 graphics library and EasyPThread library for real-time tasks.
-
Allegro 4 - A cross-platform, open-source graphics library for game and multimedia programming. To install Allegro 4.4 under Ubuntu (or derivatives thereof), execute these commands from the terminal:
sudo apt update sudo apt install liballegro4.4 liballegro4-dev allegro4-doc
-
EasyPThread - An educational real-time C library.
-
To compile the project the first time:
-
Move the
tanksimulator-main
folder (from now on referred to astanksimulator-main/
) where thou prefer. -
Launch a terminal window and navigate to
tanksimulator-main/
. -
Create the
obj
folder and move it insidetanksimulator-main/
, i.e.,tanksimulator-main/obj/
. -
Type:
make
-
-
To compile the project again:
-
Navigate to
tanksimulator-main/
. -
Type:
make
-
-
To compile the project from scratch:
-
Navigate to
tanksimulator-main/
. -
Type:
make clean make
-
The compilation produces the executable file tanksimulator-main/main
. The program should be run as superuser (i.e., root user), e.g.,
sudo ./main
# Enter your user account password when prompted
The following table lists the mouse commands available in the system:
Movement | Action |
---|---|
Click on a tank | Sets the desired liquid level (indicated by a red horizontal bar) |
Left-click and drag on an outlet valve | Adjusts the valve opening to control the flow rate of the liquid |
Click the r@andomize! button | Randomizes all the system parameters and tank colors |
The following table lists the keyboard commands available in the system:
Key | Action | Range | SI Unit |
---|---|---|---|
P p |
Increases proportional gain by 0.2 Decreases proportional gain by 0.2 |
[0, 20] | - |
I i |
Increases integral gain by 2 Hz Decreases integral gain by 2 Hz |
[0, 200] | Hz |
D d |
Increases derivative gain by 0.02s Decreases derivative gain by 0.02s |
[0, 2] | s |
F f |
Increases feedforward dry/wet ratio by 5% Decreases feedforward dry/wet ratio by 5% |
[0, 100] | % |
W w |
Increases filter window size by 1 Decreases filter window size by 1 |
[0, 20] | - |
K k |
Increases valve constant by 0.1 m²/s Decreases valve constant by 0.1 m²/s |
[0.1, 1] | m²/s |
R r |
Increases tanks radius by 0.1 m Decreases tanks radius by 0.1 m |
[0.1, 1] | m |
H h |
Increases tanks height by 0.02 m Decreases tanks height by 0.02 m |
[0.5, 9] | m |
U u |
Increases utilization scale by 1 Decreases utilization scale by 1 |
[0.5, 20] | - |
SPACE | Restores default values | ||
ESC | Exits the program |
The system has N liquid tanks, where N is equal to 5. There are a total of 12 periodic tasks, 2 for each tank plus 2 additional tasks:
- τT,1, ..., τT,N: tasks responsible for tank management
- τS,1, ..., τS,N: tasks responsible for sensor management
- τU: task responsible for user input management
- τG: task responsible for graphics management
The following diagram illustrates the relationship between tasks and resources:
Liquid tanks with their inlet and outlet valves and randomizer button:
A set of keyboard commands is available to control the system. More detailed instructions are in the next section.
The GUI displays the range and current value of each adjustable parameter of the control system.
The GUI includes a task analyzer that displays task Deadline Misses and Response Times (instantaneous, red bar, average, blue bar, and maximum, red rightest thin line, respectively). It is powered by the EasyPThread library.