Project Report
Project Report
UG PROJECT
MEMBERS
Kumar Sonu - 21095065
Vinit Sharma - 21095129
Divyanshu - 21095043
1
CERTIFICATE
This is to certify that the UG Project entitled “Path Finding Robot Using
Raspberry Pi ” submitted by Kumar Sonu (21095065), Vinit Sharma
(21095129), Divyanshu (21095043) , to the Department of Electronics
Engineering, Indian Institute of Technology (Banaras Hindu University)
Varanasi, in partial fulfilment of the requirements for the award of the degree
“Bachelor of Technology” in Electronics Engineering is an authentic work carried
out at Department of Electronics Engineering, Indian Institute of Technology
(Banaras Hindu University) Varanasi under my supervision and guidance on the
concept vide project grant as acknowledged.
2
DECLARATION
I hereby declare that the work presented in this project titled “Path Finding
Robot Using Raspberry Pi” is an authentic record of our own work carried out
at the Department of Electronics Engineering, Indian Institute of Technology
(Banaras Hindu University), Varanasi as requirement for the award of degree of
Bachelors of Technology in Electronics Engineering, submitted in the Indian
Institute of Technology (Banaras Hindu University) Varanasi under the
supervision of Dr. Vishwambhar Nath Mishra, Department of Electronics
Engineering, Indian Institute of Technology (Banaras Hindu University)
Varanasi. It does not contain any part of the work, which has been submitted for
the award of any degree either in this Institute or in other University/Deemed
University without proper citation.
Divyanshu
3
Contents
1 Introduction
(i) Evolution of Maze-Solving Techniques 6
(ii) Extension to the MAPD problem 7
3 Proposed System 15
(iv) Visualization 20
6 Bibliography 28
4
ABSTRACT
This project explores the design and development of a maze-solving robot that uses
computer vision and a Raspberry Pi to navigate a maze represented as a colored
grid. Each color on the grid corresponds to a specific weight, indicating the cost of
traversing that cell. The red cells denote the starting and ending points for the
robot, while other colors, such as blue and yellow, represent varying weights. The
robot's objective is to find the shortest path to the nearest red grid, using Dijkstra's
algorithm to guide its route.
The system architecture involves a Raspberry Pi with a camera module to capture
an image of the maze. Image processing techniques are used to identify the colors
within the grid and assign corresponding weights. The weights are then utilized to
create a cost map, serving as the basis for the pathfinding algorithm. By employing
Dijkstra's algorithm, the robot calculates the optimal route from the start to the
nearest red cell, considering the weighted costs of each pathway.
The hardware configuration includes motor controllers to drive the robot's
movements and a power management system to ensure consistent operation. The
robot's movement is guided by the calculated path, adjusting as needed to avoid
obstacles and unexpected changes in the environment.
During simulation using pybullet, the robot successfully navigates through a variety
of mazes, demonstrating the ability to identify and follow the shortest path based
on weighted grid cells. This project showcases the utility of combining computer
vision with efficient pathfinding algorithms to solve complex navigation problems.
The results have implications for autonomous robots in real-world scenarios where
weighted pathways influence decision-making.
Future work could focus on implementing the simulation into a real world robot
using raspberry pi, enhancing the accuracy of the computer vision system, exploring
other pathfinding algorithms for greater efficiency, and incorporating additional
sensors to improve the robot's adaptability. Additionally, the application of
machine learning techniques could further optimize the robot's ability to navigate
complex and dynamic environments.
5
Chapter 1
INTRODUCTION
Navigating complex environments is a key challenge for autonomous
robots, particularly when those environments are structured as mazes
with varying costs associated with different pathways. In many real-
world scenarios, robots must find the shortest or least costly path to
reach a target location, often relying on visual data and pathfinding
algorithms to guide their movements. This project addresses the
problem of designing a maze-solving robot that can autonomously
navigate through a maze represented as a colored grid, where each color
indicates a specific weight or cost to traverse that cell.
The maze contains multiple colors, with the red cell serving as both the
starting and ending point for the robot. Other colors, such as blue and
yellow, represent varying levels of difficulty in traversal. The objective
is to develop a system that can capture an image of the maze, process
the color information to determine the corresponding weights, and use
a pathfinding algorithm to calculate the shortest route to the nearest red
cell. This involves integrating computer vision, a Raspberry Pi
microcontroller, and efficient hardware control to ensure the robot can
navigate the maze autonomously and in real-time.
Given this problem context, the primary challenge lies in developing a
robust computer vision system that accurately interprets the color-
coded grid, implementing an effective pathfinding algorithm, and
ensuring reliable hardware functionality for autonomous movement.
The ultimate goal is to create a robot that can efficiently solve the maze
while adapting to the varied costs associated with different pathways,
demonstrating potential applications in a variety of scenarios where
autonomous navigation through weighted grids is required.
6
Extended Multi Agent Pickup And Delivery:
An extension to the above problem is the Multi Agent Pickup and
Delivery system. It is a critical optimization challenge in logistics and
transportation, where autonomous agents collaborate to transport
items from pickup locations to designated delivery points. The
problem becomes increasingly complex when tasks are batched,
requiring efficient scheduling, route optimization, and dynamic
coordination among agents. This scenario has practical applications in
industries such as e-commerce, robotics, and supply chain
management, where timely and cost-effective deliveries are
paramount.
The primary goal of the project is to design and implement an
extended MAPD system capable of handling batched tasks while
ensuring optimal utilization of resources, minimizing delivery times,
and maintaining flexibility in dynamic environments. This study
explores advanced algorithms and strategies to enhance decision-
making and improve the efficiency of multi-agent systems,
contributing to the growing demand for intelligent automation in
logistics.
7
LITERATURE REVIEW
8
Pathfinding Algorithms: The development of algorithms like
Breadth-First Search, Depth-First Search, A*, and Dijkstra's
allowed robots to calculate optimal paths through mazes. These
algorithms offered a more systematic approach to maze-solving
and could handle complex mazes with multiple pathways and
dead-ends.
The Role of Computer Vision
In the late 20th century, computer vision began to play a significant role
in maze navigation. This technology allowed robots to "see" the maze
and make decisions based on visual information. With the advent of
digital cameras and image processing techniques, robots could identify
walls, pathways, and other key features in real time.
Visual Navigation: Robots equipped with cameras could use
computer vision techniques to recognize maze patterns, identify
junctions, and detect obstacles. This approach opened new
possibilities for autonomous navigation in dynamic and complex
environments.
Grid-Based Navigation: The concept of representing mazes as
grids became popular, where each cell in the grid represented a
specific area within the maze. This representation allowed for
more precise navigation and easier implementation of pathfinding
algorithms.
Disadvantages:
Requires careful heuristic design to avoid inefficient paths.
More complex to implement than simpler algorithms.
11
Multi Agent Systems :
Multi-agent systems are systems with several agents that may cooperate or
compete with each other. The agents incorporate knowledge about
themselves and other agents in order to interact with each other. Multi-
agent systems are used in areas of problem-solving where it maybe
difficult, impossible, or ineffective to solve with single agents.
Initially, tape-based navigation robots (Automated Guided Vehicles,
AGVs) were used to transport goods within factory floors . They are
robust but investment heavy , and not at all flexible to change . Also , they
face heavy wear and tear . Later , Autonomous Mobile Robots (AMRs)
were used . Robots using LiDARs and Cameras typically create a map of
the environment and use that to re-localize themselves when traversing in
that world. However , they were difficult to deploy even after having ROS
implementations , and they were costly owing to different expensive
sensors and computing units.
Finally , marker based localization was used . While there is a range of
markers by different universities and industrial vendors, the fundamental
principle is that they contain patterns that are easy to recognize and
interpreted by marker-relevant decoding. This allows the user to get a
unique identity about the marker and a relative pose of the camera to the
marker. This marker-based localization method is relatively inexpensive to
set up as it just involves a physical printout of these patterns and some
industry-relevant packing to prevent wear and tear.
The Multi-Agent Pickup and Delivery (MAPD) problem involves a group
of agents that work together to pick up and deliver packages in a
constrained environment. The challenge is to allocate packages to agents
and determine their delivery routes in a way that minimises the total
distance travelled while ensuring that each package is delivered to its
destination on time. In recent years, several techniques have been
proposed to solve the MAPD problem using real-world differential drive
robots. In this response, we will explain in detail how some of these
algorithms work and solve the problem.
12
Existing Solutions to the MAPD problem :
There exist solutions specific to task execution in terms of MAPF that
were invented because of dynamic environments where agents are subject
to changes, or new goals as part of task execution. Ma, Li, Kumar, and
Koenig developed two decoupled algorithms for their own problem
formulation MAPD, called Token Passing (TP) and Token Passing with
Task Swaps (TPTS). By being decoupled, the algorithms let the agents
assign themselves to tasks and calculate their own paths using some global
information. Both of these algorithms are based on already existing MAPF
solutions. In the TP algorithm described by Ma, Li, Kumar, and Koenig a
token is a shared memory block which contains the current task set, the
planned paths of all agents and all agents’ current assignments. The token
is used to keep track of the other agents’ plans, and to communicate the
own agent’s plan. The algorithm works by idle agents choosing a task from
the task set and trying to find a path that executes the task. They choose
the task with the lowest h-value, which is calculated using the Manhattan
distance between the current position of the agent and the pickup location
of the task. If the task set is empty or the pickup or delivery position is
blocked by other agents for all available tasks, the agent checks if its
current location blocks another agent’s assigned task’s pickup or delivery
location, and if so it moves out of the way. If a task is found, on the other
hand, the agent computes a path to the pickup location and to the delivery
location using A*. When doing so, it makes sure that no path collides with
other agents’ paths saved in the token. At last, it saves its own path in the
token, updates the task set and assignments and passes it on to the system.
The other algorithm that Ma, Li, Kumar, and Koenig developed is an
improvement of TP called TPTS where the task set contains all unexecuted
tasks instead, not only the unassigned as in TP. The authors define an
unexecuted task as a task where an agent has not yet arrived at the pickup
location. This means that when choosing a task, agents can take one that is
already assigned, as long as the agent arrives at the pickup location before
the other agent. When the agent arrives at the pickup location, the other
agent is no longer assigned to that task and is then sent the token in order
to pick a new task for execution. By doing this token swapping, the TPTS
achieves a shorter makespan than TP, but a longer runtime per timestep.
13
Later on, several algorithms have been developed that build on to Ma, Li,
Kumar, and Koenig algorithms. Ma, Hönig, Kumar, Ayanian, and Koenig
developed their own algorithm to include kinematic constraints in the
planning phase for more accurate and faster solutions to real-world
problems. Liu, Wang, Zhou, Shen, and Liu created an algorithm suited for
large-scale robots, which partitions the environment into smaller sectors in
order to simplify the scale of the problem through a segmented approach.
Additionally, Okumura, Machida, Défago, and Tamura created an
algorithm called PIBT that uses backtracking and priority inheritance in
order to ensure collision-free paths and reduce runtime in comparison to
TP. The difference between this approach and TP is that it does not need to
consider free agents when calculating reachability and the computational
cost of finding paths is very inexpensive. Building from search-based
solutions, there is another way of solving the MAPF problem using
conflict-based search (CBS) for optimal solutions. CBS uses a two-level
approach with a high-level and low-level search. The high-level search
uses a Constraint Tree (CT) with nodes containing time and location
constraints for each agent. In each of these nodes, a low level search is
conducted which returns paths for a single agent. There are a number of
algorithms that uses CBS in different ways, for example, the Mul tiple
Delivery Conflict-Based Search (MD-DCBS) algorithm [29]. MD-DCBS
uses a D*-lite algorithm which supports replanning and makes the MD-
DCBS algorithm useful in dynamic environments. The D*-lite algorithm
also makes the MD-DCBS more effective than ordinary CBS because it
can cache some information. There are other approaches that solve the
dynamic path-finding problem, such as the Rolling-Horizon Collision
Resolution (RCHR), which recomputes paths in a rolling-window
approach. This approach reduces complexity by not accounting for
anything outside the time window. It turns out that this approach reduced
agent idle time and thereby throughput. It also produced an adaptable fleet
of agents that can respond to new goal locations in run-time.This results in
reduced run-time for a similar quality solution or better in comparison to
other algorithms, with the added benefit of being scalable up to thousands
of agents in the simulation.
14
Proposed System
The proposed system aims to provide a robust solution for maze-
solving robots, leveraging OpenCV to process overhead images and
generate step-by-step navigation instructions. This system integrates
computer vision and pathfinding algorithms to determine the most
efficient route through a maze or arena.
15
System Components:
1. Overhead Camera: An overhead camera captures the entire
maze or arena from a top-down perspective. This camera provides
a complete view, allowing for accurate analysis of the maze's
structure and grid layout.
2. OpenCV Processing: OpenCV, an open-source computer
vision library, processes the captured image to extract relevant
information about the maze. This includes:
Color Detection: Identifying different colors that represent
various grid types or weights.
Edge Detection: Determining the boundaries of the maze,
walls, and pathways.
Contour Analysis: Recognizing distinct grid cells,
junctions, and key points within the maze.
3. Grid Generation: Once the image is processed, the system
generates a grid representation of the maze. Each cell in the grid
16
corresponds to a specific area within the maze, and this
representation allows for pathfinding and step-by-step
navigation.
4. Pathfinding Algorithm: The system uses a pathfinding
Dijkstra's algorithm to determine the optimal path through the
maze. This involves:
Cost Calculation: Assigning weights or costs to different
grid cells based on color or other characteristics. This allows
the algorithm to account for varying levels of difficulty in
navigating through the maze.
Optimal Pathfinding: Finding the shortest or most efficient
path from the starting point to the desired location. The
algorithm considers turns, junctions, and obstacles to ensure
the robot follows the best route.
5. Extending the solution to Multi-Agent path planning: Once
we have implemented the path finding algorithm for a single
source and single destination, We can easily extend the solution
to multiple sources and multiple destination with variable
distances. We have primarily used the “Token Passing”
approach which focuses on using tokens as tickets to reserve a
specific path to avoid collision.
17
PRELIMINARY RESULTS AND
INSIGHTS
Simulation Setup
The PyBullet environment was used to create a virtual maze and
simulate the robot's movement. The maze was designed with varying
pathways, turns, and endpoints to test the robot's pathfinding abilities.
The image of the maze was manually fed initially and after scanning
the image the environment creates its own grid network to track the
position of the robot.
Image Processing and Grid Generation
OpenCV was used to process the captured images of the maze. The
following steps were performed to generate the grid representation:
Color Detection: The system identified different colors
representing various parts of the maze, including walls, pathways,
and key points (like start and end).
Edge Detection: The edges and contours of the maze were
detected, allowing for accurate delineation of pathways.
Grid Creation: A grid representation of the maze was created,
with each cell corresponding to a specific area within the maze.
This grid formed the basis for the pathfinding algorithm.
Pathfinding and Navigation
The simulation employed a pathfinding Dijkstra’s algorithm to
determine the optimal path through the maze. The algorithm considered
the costs of traversing different grid cells, enabling the robot to find the
most efficient route to the goal. Once the optimal path was determined,
step-by-step navigation instructions were generated for the robot.
18
Output Images And Visualization:
Image of the maze:
The robots initial position is the center red hexagon. The black
hexagons are having infinite weight and the other colour have various
finite weight.
Processed image:
19
The image is processed and a similar is marked with the weights of the
grid boxes in the path. Backtracking is used to determine the minimum
cost path.
20
Multi Agent Path Planning:
In this final segment of the entire task, we have to generate optimal paths
for each agent in the map. Taking into mind the cons and pros of all the
algorithms mentioned in the literature survey, we decided to go with the
decentralized token passing algorithm.
A single token is introduced into the system or multiple tokens are
distributed depending on the parameter passed. The token represents
permission to plan or execute a path. Firstly the agents are mapped to all
the tasks available and the costs of each such combination is calculated
then the token passing algorithm start allocating tokens to the minimum
cost path taking care of collisions in the path. Once a token is assigned for
a particular path any other token cannot be assigned with a crossover path.
When the task is deemed completed the agent releases the token and the
algorithm replans optimal paths for the remaining tasks.
For the simulation purpose we generated random task points which would
act as pickup and delivery locations.
Then we performed simulations for different values of k (number of
tokens) and evaluated the performance of our algorithm for varying
21
number of tasks. The evaluation metrics were the costs of completing all
tasks which are calculated in terms of timesteps
Simulation snapshots:
22
For k : 4 far task placements
23
Hence from the obtained observations we can conclude that for lower
values of k we are able to find suitable paths when the number of tasks are
less, When the number of tasks are more we will eventually be
outnumbered in terms of agents hence the time taken will be more.
Similarly for higher k value we able to plan paths for a decent number of
tasks however we cannot keep on increasing the tasks as in that case there
will be a problem of path collision much more frequently and there will a
need for replanning which would add to the cost.
24
Challenges Faced:
1. Power Management
Power supply stability is critical for reliable operation.
Fluctuations in power can lead to erratic behavior or system
crashes.
Battery capacity must be sufficient to support continuous
operation during maze navigation.
Both wheels should be getting same power for moving in a
straight line.
This could be achieved with PID tuning of the encoded motors.
26
CONCLUSION:
The maze-solving robot project presented here demonstrates a
comprehensive approach to autonomous navigation using computer
vision, pathfinding algorithms, and hardware integration. By utilizing
a Raspberry Pi microcontroller, overhead camera, motor drivers,
encoded motors, and a reliable power source, the proposed system
navigates through complex mazes with high accuracy and efficiency.
The simulation results in the PyBullet environment, coupled with
OpenCV for image processing, validate the effectiveness of the system
in identifying pathways, detecting turns, and reaching the desired
endpoint. The preliminary insights and results indicate that the robot
successfully navigated through simulated mazes, adapting to varying
complexities and potential obstacles.
This project also identifies several challenges in hardware
implementation, including power management, motor control,
communication, image processing, real-time performance, and
structural durability. Addressing these challenges requires careful
design, robust hardware integration, and continuous testing to ensure
reliability in real-world scenarios.
The outcomes of this project have significant implications for robotics
competitions, warehouse automation, search and rescue operations, and
other applications where autonomous robots must navigate through
complex environments. The combination of computer vision and
pathfinding provides a versatile solution that can be adapted to a range
of contexts.
27
BIBLIOGRAPHY:
(PDF) Integrated Task Assignment and Path Planning for
Capacitated Multi-Agent Pickup and Delivery (researchgate.net)
https://www.semanticscholar.org/paper/An-Efficient-Algorithm-for-
Robot-Maze-Solving-Dang-
Song/586efa47a407bbd9c175b6d2f1c556bfe182e023
https://github.com/ShaheerSajid/OpenCV-Maze-Solving
http://wiki.ros.org/tracking_pid
https://www.researchgate.net/publication/321121617_Intelligent_Maze_S
olving_Robot_Based_on_Image_Processing_and_Graph_Theory_Algorit
hms
28