Robotics Mapping Project

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Part 1: Mapping 

We found that when using the update LCD screen command for sparki, the LCD did not save 
the data as it was supposed to. Therefore, we decided to save the x and y values in a 2D array. 
Since the Sparki does not have much memory, we decided to only save the location every 5 
loops. We did this with the assumption that a loop 
takes .1s, so we would get a new data point every 
half second. Using this data, we completely 
re­plotted the map (after clearing the display) 
each time we added a new point. 
 
Even with this method, we ran into issues with 
memory limits. To get around this, we disabled 
the accelerometer and magnetometer, freeing up 
valuable storage space. We also minimized our 
error by resetting the x and y values when we 
passed the starting line. Below is a picture of the 
map we obtained after following the line­following 
map for one loop. 
 
 
Part 2: Path Planning 
Using Dijkstra’s algorithm we were able to plan our path to find the end goal of a maze. To do 
this we first hard­coded a discrete map. From this we were able to create a cost matrix. For 
nodes that are inaccessible (in objects), we used infinity for their cost so the algorithm will never 
try to go to them. Then we used the given Dijkstra implementation to work backward and 
calculate the true cost of each possible path. 
Using this inverted system, we created an array of the nodes needed to traverse the shortest 
path. Once this array was created, we were able to pass each node in it to a GoTo function that 
makes the robot drive to that node.  
We implemented this traversal by comparing the current location of the robot to the location of 
the node we want to move to next. We used this information to tell the robot to turn to the 
direction we want to go in and then move forward to the next node. 
Orientation can be calculated using the theta position which we defined in the mapping code.  It 
would also be possible to use the magnetometer to give Sparki a heading.  Unfortunately, we 
needed to disable this sensor to allow enough memory for the path planning and therefore we 
need to rely on the orientation based on Sparki’s motion or other features described by a 
different sensor. 
 
 
2​
a) Since Dijkstra’s algorithm runs in O(|V|​ ), where V is the number of nodes in the map, 
out Sparki is able to find a shortest path in this order of time. The actual time will depend 
on the processing speed of the Sparki’s CPU 
b) The major limitation of Sparki in terms of implementing larger maps is that the bot does 
not have enough memory to hold the larger maps. A large amount of space would be 
needed to store the adjacency matrix needed to implement Dijkstra’s algorithm on a 
large map with many nodes. 
c) As for dealing with moving objects it would be necessary to calculate the shortest path, 
take a step, then recalculate, in order to determine if the obstacles have moved in the 
way. 
d) To ensure that the robot has the correct orientation when it reaches the goal node, we 
have to keep track of Sparki’s angle relative to the orientation of the map, as it is moving. 
Then, once Sparki reaches its goal, it can compare its heading to the goal heading, and 
turn in place until the orientations are aligned. 
 

You might also like