Skip to content

Take control of liquid tanks with our intuitive tank simulator game!

License

Notifications You must be signed in to change notification settings

liviobisogni/tanksimulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prerequisites Compile Execute Commands Documentation GUI Screenshots Demo

Description

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.

Prerequisites

  • 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.

How to Compile

  • To compile the project the first time:

    1. Move the tanksimulator-main folder (from now on referred to as tanksimulator-main/) where thou prefer.

    2. Launch a terminal window and navigate to tanksimulator-main/.

    3. Create the obj folder and move it inside tanksimulator-main/, i.e., tanksimulator-main/obj/.

    4. Type:

      make
  • To compile the project again:

    1. Navigate to tanksimulator-main/.

    2. Type:

      make
  • To compile the project from scratch:

    1. Navigate to tanksimulator-main/.

    2. Type:

      make clean
      make

How to Execute

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

Commands

Mouse Commands

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

Keyboard Commands

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

Tasks

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:

GUI

Overview

Liquid tanks with their inlet and outlet valves and randomizer button:

Keyboard Commands

A set of keyboard commands is available to control the system. More detailed instructions are in the next section.

Parameter Ranges and Values

The GUI displays the range and current value of each adjustable parameter of the control system.

Tasks Analyzer

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.