This project is a 2D simulation of a drone interacting with its environment. The drone can be controlled by the user through their keyboard. The environment includes obstacles that should be avoided as well as targets that should be approached by the drone.
- +: Drone (controlled by player)
- *: Obstacles to be avoided
- Numbers: Targets to be reached
This project was developed as part of the course "Advanced and Robot Programming" .at the University of Genoa (UniGe).
The architecture for this project was strongly dictated by the assignment.
Legend:
- B: Blackboard server
- D: Drone component
- I: Input component
- T: Target component
- O: Obstacle component
- W: Watchdog
The project includes the following components:
File: main.cpp
Entrypoint of the project. Responsible for creating and running the other components. Serves as the master process. Also runs the blackboard server component.
Files: blackboard.(c|h)pp
Responsible for rendering the information to the window. Runs a game loop that periodically uses select
to check, whether any process have new data available.
Files: drone.(c|h)pp
Periodically receives positions of obstacles and targets as well as keyboard input. Updates the drone position accordingly, following a simple physical model and sends the new position back to the blackboard server.
Files: keyboard.(c|h)pp
Watches for keyboard input and reports it to the blackboard server.
Files: obstacles.(c|h)pp
Manages the obstacles. Periodically checks, whether obstacles have and expired and should be removed or whether new ones should be created. Reports any changes to the blackboard server.
Files: targets.(c|h)pp
Manages the targets. Receives detected collision and destroys targets accordingly. Also responsible for creating new targets.
Files: keyboard.(c|h)pp
Watches for keyboard input and reports it to the blackboard server.
Files: watchdog.(c|h)pp
Watches other components by periodically checking shared log file. Terminates program, if one component stops responding.
The project is structured as follows
- src/: Contains the source code files for the project.
- include/: Contains the header files for the project.
- build/: The directory where the project will be built. Gets created automatically.
- appsettings.json: The configuration file for the project.
- CMakeLists.txt: The CMake configuration file for building the project.
- build.sh: A script for building the project.
Files irellevent for the project are omitted.
- Download latest release binary from GitHub
- make executable
chmod +x drone-simulator_linux_amd64
- copy
appsettings.json
from GitHub - run binary
-
g++
$\geq$ 12.3.0 -
cmake
$\geq$ 3.10
./build.sh
-j {THREADS}
: Number of threads for parallel building. Directly passed to cmake/make. Defaults to 8.-r
: Run the project after build step. Defaults to false.-h
: Show help message.
mkdir build
cd build/
cmake ..
make
./dronesim
In order to enable debugging symbols, run cmake
with the corresponding flag.
cmake -DCMAKE_BUILD_TYPE=Debug ..
- Move the drone using
E
: Move upC
: Move downS
: Move leftF
: Move rightW
,R
,X
,V
: Move diagonallyD
: Stop moving
- Use
Q
to quit the game. - Avoid obstacles (
*
) and reach targets (1
,2
,3
, ...).