Skip to content

A simple simulation environment for programmable moving robots, developed as a project for the Programming Methodologies exam at UNICAM.

License

Notifications You must be signed in to change notification settings

marco-caputo/FollowMe_Robot_Simulator

Repository files navigation

FollowMe Robot Simulator

This is a simple 2D simulation environment for programmable moving robots, developed as a project for the Programming Methodologies exam at UNICAM.

This application can run a simulation based on:

  • An environment, made of two-dimensional labeled areas;
  • A program made of instructions followed by all robots in the simulation.

Building and running

To build the program, first open a terminal window in the main folder of the project, then run the build command using the correct version of the Gradle wrapper based on your OS:

gradlew.bat build   (on Windows)    
gradlew build       (on macOS/Linux)

After building, execute the Gradle wrapper run command to launch the application.

gradlew.bat run   (on Windows)    
gradlew run       (on macOS/Linux)

Application usage

Once the application has been successfully launched, the main window of the app will be shown, containing the following main sections:

  • The simulation view, composed of the simulation time stopwatch and the two-dimensional cartesian plane.
  • The program source code text box on the left.
  • The control panel on the bottom.

Here's a brief explanation of the commands available in the control panel:

Settings section

Command Usage
Load environment button Loads a .txt file from file system as simulation environment.
Load program button Loads a .txt file from file system as robots' program.
Instruction interval setter Sets the time interval between the execution of each instruction.

Note that modifying any of these settings will cause the current simulation to reset, along with the stopwatch timer (all robots added to the current simulation will be moved to the new one).

Robots section

Command Usage
Add robots button Opens a menu window for adding new robots to the current simulation.
Clear robots button Removes all robots currently added into the simulation.

The Add Robots menu window is composed of two sections with the following functionalities:

  • Adding single robots with a given movement configuration in a specific position on the plane.

  • Adding a given amount of robots in positions randomly chosen among coordinate ranges, all of them having a given movement configuration.

Note that is possible to add robot in both ways at the same time using the "Add robots" button according to the given information.
All fields are manually editable.

Simulation section

Command Usage
Play seconds button Runs the current simulation for the given amount of seconds. (with or without real-time animation)
Play steps button Runs the current simulation for the given amount of steps. (with or without real-time animation)
Play one step button Runs the current simulation until the next instruction is executed. Note that this is equivalent to the previous command used with "1" step and no animation.

All fields are manually editable.

View section

Command Usage
Move view buttons Scrolls the simulation view in the four directions.
Zoom view slider Increases or reduces the zoom factor.

File formats

Environment

To describe the environment of the simulation, a .txt file containing lines of the following format is used:

Syntax Described area
label CIRCLE x y r A circular area labeled with label, having its center sitting in position (x, y), with radious r (meters).
label RECTANGLE x y w h A rectangular area labeled with label, having its center sitting in position (x, y), with width w and height h (meters).

Program

The robots' program is composed of a sequence of instructions and iteration constructs. Such programming language includes the following commands:

  • Instructions
Syntax Semantics
MOVE x y s Sets the robot's movement configuration in the direction associated to the relative position (x, y) and setting its velocity to s (m/s).
MOVE RANDOM x1 x2 y1 y2 s Sets the robot's movement configuration in the direction associated to a random absolute positon having its coordinates in ranges [x1, x2] and [y1, y2] and setting its velocity to s (m/s).
CONTINUE s The robot continues moving according to its configuration for s simulation steps.
STOP The robot stops its motion, setting its velocity to 0 (m/s).
SIGNAL label The robot start signaling a condition described by label.
UNSIGNAL label The robot stop signaling a condition described by label.
FOLLOW label dist s Sets the robot's movement configuration in the direction associated to the absolute position obtained as an average of positions of robots that are currently signaling a label condition and are not further than _dist meters from the robot. If no such robot exists, a direction obtained from a random relative position in ranges [-dist, dist] and [-dist, dist] is set. In any case, sets the robot velocity to s (m/s).
  • Iteration constructs
Syntax Semantics
REPEAT n
cmd1
...
cmdn
DONE
Repeats the sequence of instructions cmd1, ..., cdmn for n times.
UNTIL label
cmd1
...
cmdn
DONE
Repeats the sequence of instructions cmd1, ..., cdmn until the robots reaches an area labeled with label.
DO FOREVER
cmd1
...
cmdn
DONE
Repeats the sequence of instructions cmd1, ..., cdmn forever.

Note that every area label and robot's condition label must be composed only of alphanumerical characters and "_" character.

Sample files for both environment and program are respectively available in the following paths internal to the project:

app/src/test/samples/environmentSamples
app/src/test/samples/programSamples

About

A simple simulation environment for programmable moving robots, developed as a project for the Programming Methodologies exam at UNICAM.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages