Skip to content

olexamatej/robot-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Robot Simulation

A 2D mobile robot simulator with autonomous and remote-controlled navigation capabilities. Built as a university project for ICP course 2024.

Features

  • Interactive map creation with drag-and-drop functionality
  • Autonomous robots that navigate and avoid obstacles automatically
  • Click on any robot to take manual control via keyboard or GUI buttons
  • Customizable robot parameters (detection range, rotation angle, speed)
  • Obstacle placement system
  • Save/load map configurations from text files
  • Real-time simulation with pause/resume functionality
  • Visual feedback with color-coded robot selection

Technology Stack

  • Language: C++
  • GUI Framework: Qt5
  • Graphics: Qt Graphics View Framework
  • Build System: Make, qmake
  • Documentation: Doxygen

Building and Running

Build

make build

Run

./robots

Or combined:

make run

Generate Documentation

make doxygen

Usage

Main Menu

Launch the application to access the main menu where you can create new maps or load existing ones.

Main Menu

Creating a Map

  1. Select "Create New Map" from the main menu
  2. Choose an existing map or create a new one

Map Selection

  1. Set map dimensions

Set Map Size

  1. Drag and place robots and walls on the map

Base Map

Each robot can be configured with different parameters:

  • Initial direction
  • Rotation direction (left/right)
  • Detection distance (how far the robot can see obstacles)
  • Rotation angle (angle to rotate when detecting an obstacle)
  1. Modify robot configurations at any time during map creation

Map During Creation

  1. Save the map to a .map file

Running Simulation

  1. Load an existing map
  2. Click "Start Simulation"

Robots During Simulation

The simulation can be paused at any time to add/remove robots or walls, or change robot configurations.

  1. Click on any robot to select it (selected robot turns green)
  2. Use the control buttons at the bottom of the screen to manually control the selected robot

Robot Controls

Implementation Details

Core Functionality

The application supports creating maps where robots and obstacles can be added interactively. Each robot can be configured with the following parameters:

  • Robot name: Unique identifier for the robot
  • Rotation direction: Clockwise or counter-clockwise rotation preference
  • Detection distance: The range at which the robot detects obstacles
  • Rotation angle: The angle by which the robot rotates upon detecting an obstacle
  • Initial angle: The orientation angle at which the robot starts when simulation begins

Maps can be saved to .map files in a readable text format and loaded later. The simulation window demonstrates robot behavior in real-time, with the ability to pause at any moment. Any robot can be controlled by clicking on it - the selected robot changes color from red to green, and manual control buttons become available.

Physics Model

The simulator uses simplified physics operating with:

  • Discrete time steps: Simulation advances in fixed time intervals
  • Continuous 2D space: Robots move in a continuous coordinate system
  • Uniform linear motion: Constant velocity forward movement
  • Uniform rotation: Constant angular velocity rotation
  • No physical forces: Mass, inertia, and acceleration are not considered

Time steps are sufficiently fine relative to movement speed to ensure:

  1. Robots detect obstacles before collisions occur
  2. Visualization appears smooth and continuous

Robot Behavior

All robots start in autonomous mode, navigating using a simple collision avoidance algorithm:

  1. Move forward in a straight line
  2. Continuously scan for obstacles within configured detection range
  3. Upon detection, rotate by the configured angle in the configured direction
  4. Continue forward motion after rotation

Manual Control Mode

Clicking on any robot switches it to manual control mode (indicated by green color). In this mode, the robot can be in one of four states:

  • Stationary: No movement
  • Moving forward: Advances in the current direction
  • Rotating counter-clockwise: Turns left
  • Rotating clockwise: Turns right

Safety feature: Robots in manual mode automatically halt forward motion when obstacles are detected within the detection range.

Limitations

  • Map size can exceed screen resolution, potentially causing the application window to extend beyond screen boundaries
  • Manual edits to .map files may cause undefined behavior
  • Collision detection is performed at discrete time steps, requiring appropriate step size configuration

Project Structure

├── src/              # Source code
│   ├── Pages/        # GUI pages (Menu, Create, Simulation)
│   ├── assets/       # Qt resources
│   └── *.cpp/hpp     # Core classes (Robot, Map, Controller, etc.)
├── maps/             # Saved map configurations
├── examples/         # Example map files
├── docs/             # Documentation and images
├── build/            # Build artifacts
└── Makefile          # Build configuration

Contributors

  • olexamatej - Game logic, pathfinding, and map creation system
  • megy123 - Main menu, map and config loading/saving and pixel art sprites

License

This project was created as a university assignment for the ICP course. See ASSIGNMENT.md for the original project requirements.

About

2D robot sim with map editor and obstacles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors