Skip to content

yanvgf/line-follower-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

line-follower-simulator

This project aims to design a straightforward simulator for a line follower robot using Python.

main_v2

The robot is capable of navigating along user-designed tracks utilized as maps, given that the line is distinguishable from the rest of the map, commonly by being darker. The robot's movements are governed by the user-defined control logic and sensor positioning. In the video above, the robot employs a PID control strategy to accurately trace the specified line.

Note: This project is currently under development, and several features are yet to be implemented.

Requirements

To begin, install the necessary packages. The requirements.txt file contains all the required packages and their versions for running this project.

For those using conda, create a new environment using the following command (Linux or WSL):

$ conda create --name line-follower-simulator --file requirements.txt

Alternatively, you can install the packages via pip:

$ pip install -r requirements.txt

Usage

The main interaction occurs through two files: setup.py and main.py.

setup.py

In this file, users configure robot parameters (chassis width, wheel radius, initial speed, number of sensors, etc.) and position it within the arena. However, a default setup is already available for users to skip this stage if they wish. Parameters need to be specified within the code, as displayed in the image below:

parameters

Once the parameters are set, execute the setup.py file using the following command:

$ python setup.py

A prompt will appear in the terminal asking whether the user wants to overwrite the existing setup file. To create a custom setup, users should respond with 'yes' (y).

overwrite

First, users will be prompted to place the robot within the arena. This involves clicking on the map to position the robot and scrolling to rotate it. Then, sensors must be positioned on the robot by simply left-clicking to place each sensor.

setup_v2

The setup process is complete once all sensors are positioned. The robot's position, sensor placements, and parameters will be automatically saved in the setup.txt file, eliminating the need to repeat this procedure every time.

main.py

The simulation executes based on the robot parameters and setup defined in the setup stage. To run the simulation, use the following command:

$ python main.py

The simulation will continue until the robot reaches the goal or until you close the window.

Changing robot and map images

Users can modify the robot and map images by replacing the robot.png and map.png files in the images folder. Ensure that your robot is positioned at zero angle in the image (i.e., pointing to the right).

The robot will follow any black or dark line present on the map.

References

Some of the code used in this project was based on the following videos:

Releases

No releases published

Packages

No packages published

Languages