An overview of this program function.
Go to Introduction
How install and run this program in Linux.
Go to Installation and Execution
Legend of the buttons clickable.
Go to Legend of Buttons
A rapid description of how the program works.
Go to How it works
The goal of this assignment is to design, develop, test and deploy the code for an interactive simulator of a (simplified) typical
vision system, able to track an object in a 2-D plane.
This assignment requires the use of a shared memory in which two processes operate
simultaneously, as happens in reality in similar applications.
In our case we don't have a camera, so we will simulate the creation of the moving image using an
ncurses window. Using arrow keys, we will move a spot in a window to simulate the perception of
the camera. The spot that we will see by moving will produce the creation of a realistic RGB image in the simulated, shared, video memory while in a second ncurses window, also 80 x 30, the position trace of the center of the
image will be shown.
There will be an additional function, useful for debugging. By pressing a
key, or by operating the mouse on a button, a snapshot of the image memory will be saved on a
.bmp file.
The main difference between this assignment and the previous one, is that in this third assignment at the beginning, the process A asks the user to select how to run process A. The three modalities are descripted below in the section "How it Works"
. Go to How it works.
Keyboard Buttons:
- Key Down -> moves the cursor down.
- Key Up -> moves the cursor up.
- Key Left -> moves the cursor to the left.
- Key Right -> moves the cursor to the right.
Window Button:
- P (blue button): print button, save a snapshot of the current bmp image.
Two GitHub libraries will be used:
- ncurses, which was already used in the first assignment
- libbitmap.
To work with the bitmap library, you need to follow these steps:
- Download the source code from this GitHub repo in your file system.
- Navigate to the root directory of the downloaded repo and run the configuration through command
./configure
. Configuration might take a while. While running, it prints some messages telling which features it is checking for. - Type
make
to compile the package. - Run
make install
to install the programs and any data files and documentation. - Upon completing the installation, check that the files have been properly installed by navigating to
/usr/local/lib
, where you should find thelibbmp.so
shared library ready for use. - In order to properly compile programs which use the libbitmap library, you first need to notify the linker about the location of the shared library. To do that, you can simply add the following line at the end of your
.bashrc
file:
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
1.Open the terminal
2.Download the repository:
git clone https://github.com/MickyMori/ARP_Assignment_2
This repository contains:
- This 'README.md' file.
- The
src
folder, which contains the source code for the ProcessA, ProcessB and Master processes. - The
include
folder contains all the data structures and methods used. You can ignore the content of this folder, as it already provides you with all the necessary functionalities. - The
compiler.sh
andrun.sh
files.
3.Compile the source files:
bash compiler.sh
Once this command has been run, logFiles
, out
and bin
folders will be created.
4.Execute the program:
bash run.sh
If you want to read a specific log file of a process:
Go in the log files directory:
cd logFiles
Process A log file:
cat processA.log
Process B log file:
cat processB.log
Master log file:
cat master.log
If you want to see a snapshot created by pressing the print button you have to go to out
directory.
There are 3 processes:
- Process A: asks the user to select how to run process A. The user can decide to run the process in three modality:
- typing
n
, the process starts in normal mode: it draws a green circle in the bitmap, which center corresponds to the same location where the cursor is every time the user moves it using the keyboard buttons See the Legend of clickable Buttons. This process passes all the bmp map to the Process B using the shared memory. One of the main problems of the use of the shared memory is that a situation arises in which are done the operations of reading and writing from memory at the same time, and so, we use combined semaphores to avoid this type of situation. - typing
c
, the process starts in client mode: it follows the same steps as normal mode, but it also writes on a TCP connection with a server thecmd
value associated to the key pressed. - typing
s
, the process starts in server mode: it receives thecmd
value from the TCP connection mentioned in the client mode and follows all the steps explained for the normal mode of course without listening to keyboard inputs.
-
Process B: extracts from the bmp passed by the Process A, the location of the circle drawn in it and calculate the center of it and after this process re-draw the same circle on another bitmap. This process also keeps track of the cursor that is moved by the user through the Process A.
-
Master: his main function is to start all the processes.