Project Airspace Routes 2024 - Phase 1
Project Airspace Routes 2024 - Phase 1
Ruben Hidalgo
Cristina Barrado
Miguel Valero
Albert Ruzafa
Table of contents
Page 2
INFO1 Project
Imagine that we want to go from Sabadell to Igualada and want to calculate the best
route on the map:
In a straight line the distance is 40.77 Km. The problem is that we cannot go in a straight
line because we have to use the roads that connect the points on the map, so in fact we
will be traveling 61.3 Km.
The purpose of this project is to build a data model (classes / structs) that represents a
route network like the one above but for the air, which will allow you to nd the
minimum distance path to go from one place to another.
The project has a warm-up mini-project and follows the actual project divided into 4
phases (1 per week) to incrementally build your nal program. The listing below
summarizes the tasks to be done in each phase:
Page 3
INFO1 Project
Write a test program to verify that the minimum path from an origin to a
destination is computed correctly.
Project development
● MEETINGS
The project lasts the nal 5 classes of the course, and thus, the work has to be done
during the 4 weeks in between the 5 classes. A personal dedication of at least 10 hours
per week is expected, including the class hours. Students will work in groups of 4 people,
as published in ATENEA. Groups have to meet twice per week: one meeting during class
and at least a second one out of the class hours. For this reason the students must agree
(and sign) the established time for the meetings outside of the class schedule during the
rst project class. The reserved time for this second meeting must be 2 hours, and can
be face-to-face or using any communications tool. The reserved time and the
location/tool must appear in the signed agreement. The rest of the time, until reaching
the 10 hours limit, must be personal work.
At the end of each meeting one person of the group has to write the summary of the
meeting. This is a document that must contain:
1. group name, date, time, duration and list of assistants,
2. review of code contributed by each member,
3. results of the integration.
4. division of the pending tasks til the next meeting
All meeting minutes will be delivered immediately in ATENEA progress reports section
after ending the meeting.
● DELIVERABLES
In addition to the progress reports, the project has 11 deliverables, more than one per
week. Some are individual (D##) and some are group (G#) deliverables. Look at the
gure below (taken from ATENEA) to have a complete view of the deliverables. At the
group kick-o meeting G1 must be delivered at the end of the class. The rest are
homework deliverables. Individual deliverables count for the Personal Continuous Mark.
Page 4
INFO1 Project
Be sure you deliver on time to reach the minimum 80% of them! Group deliverables are
G1 (group contitution), G0 (delivery of Phase ZERO), G2 (code deliverable for Phase1+2)
and G3 (Phase3+4 -nal- code). Only G3 will be used for the project grade.
Page 5
INFO1 Project
● EXAMS
There will be 2 exams, both individual, both using the computer. The rst exam will be
done during class without previous notication. Duration is 30-40 minutes. The second
exam will be done during the last class. Based on the delivered nal version of the
project, each student will be requested to expand the project with a new functionality.
The time for this last exam will be 1h30m . The new functionality must be working at the
end of the exam.
● CROSS-EVALUATION
The last class, and just before the nal project exam, each group will review the work
done by the other two groups. For this, two laptops of each group will hold in the
desktop a prepared copy of the project code, so the reviewing groups will easily nd it.
They will follow an execution guide and check the correctness of the delivered project.
This activity is a mandatory learning activity that has the objective that you learn to
understand code from others, learn from it and see new ways for solving similar
problems. In addition, at the end of the project, each member will have to evaluate their
project peers.
● TRANSVERSAL COMPETENCES
Page 6
INFO1 Project
In order to fulll the legal mandate, this course must work some transversal
competences. To complete them you have to be sure to deliver D20 and D21 which hold
the transversal competences on communication, critical thinking, social compromise and
sustainability.
● GRADES
The project is a 40% of the course grade, and it is divided as follows:
• 25% for the project code (the last deliverable) and its management reports. This is a
common grade for all the components of the group, except if the minutes of the
meetings show that not all have worked suciently.
• 5% for the rst exam done in writing individually
• 10% for the second exam done on the computer individually the last day.
Quality criteria
Python is a language that has no explicitly declared types. This implies that seeing the
header of a function we can not know the types of data expected by this function. To
solve this lack of detail you must follow the rules of the next paragraph:
Always write a comment in the header of each class, indicating its initialization
and the description of the elds that the class has.
Write a comment in the header of each function, indicating the type of each
argument and the type of the return value. Describe the role of each of the
arguments and of the return value.
For example:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
Page 7
INFO1 Project
v1 = Vector (3,4)
n = norma (v1)
print ("La norma vale:",n)
This does not mean that your comments should be EXACTLY the same as the previous
one, there are many formats. But your code must allow you to understand through the
comments the purpose of all declared functions and classes.
Page 8
INFO1 Project
Page 9
INFO1 Project
Therefore, you need to build a flight plan class and an waypoint class, with the following fields:
Waypoint
- latitude (a number)
- longitude (a number)
- waypoint name (a text)
FlightPlan
- route (a vector of Waypoint, that the drone will follow in order, only one-way)
- the total route distance (a number)
1. Create a waypoint.py file and write the class Waypoint and the basic functions given
below. Write also a test program test_waypoint.py to test the functions of the class.
2. Create a flightplan.py file and write the class FlightPlan and the functions given below.
Write also a test program test_flightplan.py to test all the functions of the class.
3. Add some more advanced functions in the waypoint.py file and extend the test program
test_waypoint.py to test the advanced functions.
4. Write a final test_phaseZERO.py program to test both classes with an interactive menu
with the end user.
Test programs shall import the python modules where the class and its defined functions are.
BUILD TEST PROGRAMS THAT VERIFY ALL THE INPUT CONDITIONS, INCLUDING
ERRONEOUS PARAMETERS, TO VERIFY THAT THEY WORK CORRECTLY.
Page 10
INFO1 Project
Waypoint ()
Input parameters: None. Output parameter: an empty object of class Waypoint
Description: Constructor
ShowWaypoint (wp)
Input parameters: one waypoint. Output parameter: None
Description: Shows on the screen the information of the Waypoint.
Additionally, write a test program for the class Waypoint test_waypoint.py that declares 3
Waypoints and adds them into a list. Finally, it shows the content of the list in the console to check
it works correctly.
FlightPlan ()
Input parameters: None. Output parameter: an empty object of class FlightPlan
Description: constructor.
ShowFlightPlan (fp)
Page 11
INFO1 Project
Additionally, write a test program for the class FlightPlan test_flightplan.py that creates a
FlightPlan and then shows the content of the Waypoint list in the console to check it works
correctly.
Page 12
INFO1 Project
Advanced functions
Write new additional functions for the two classes
Write in the waypoint.py file.
FinishFlightPlan (fp)
Input parameters: a FlightPlan. Output parameter: number.
Description: Sets the attribute total route distance of flight plan. This function shall use the
function CalculateDistance described above. Returns a -1 if the FlightPlan was empty or the
calculated distance otherwise.
PlotFlightPlan (fp)
Input parameters: a FlightPlan. Output parameter: number.
Description: Shows a plot with the flight plan route. Assume that geographic coordinates can
be used in a cartesian plot. Returns a -1 if the FlightPlan was empty or the calculated
distance otherwise.
Page 13
INFO1 Project
a name, all separated by a space character. Returns a -1 if the filename does not exist or the
number of lines/waypoints if it exists.
Page 14
INFO1 Project
We want to generate a data structure capable of storing the following information (for
example):
The nodes of the graph are points A, B, C, D, ... . Each of these nodes has a name, an
x-coordinate, and a y-coordinate.
Nodes may be interconnected through segments, which consist of a source node, a
destination node, and a cost to get from the origin to the destination. Since we are
building a data model to calculate minimum distances, the initial cost will be set to the
Euclidean distance between the two nodes. If this were a GPS device, the cost could be
either distance or time (estimating a specic trac and an average speed between each
segment), as we would like to minimize either the distance or the time traveled.
Page 15
INFO1 Project
The data structure (class diagram) that we will need is the following:
A graph is composed by a list of nodes and the list1 of segments that connect those
nodes.
Each node has a list of nodes that are its neighbors, this is, which are directly connected.
Each segment has a source node and a destination node.
Therefore, we need to build a Node class , a Segment class and a Graph class, with the
following elds:
Node
- Name (a text)
- coordinate x (a numerical oat)
- coordinate y (a numerical oat)
- A list of neighbors (the list of nodes directly connected the current node)
Segment
- Origin node (a Node)
- Destination node (a Node)
- Cost (a numeric oat, which indicates the distance between the source node and the
destination node)
Graph
- Nodes (list of graph nodes)
- Segments (list of segments of the graph)
1. Create a node.py le and write the class Node and the basic functions given
below. Write also a test program test_node.py to test the functions of the class.
2. Create a segment.py le and write the class Segment and the functions given
1
A list is a vector with dynamic size. To create an empty list L use L=[]. To add an element to the list use
L.append(elem) and to remove it use L.remove(elem). Rest of usages are as in vectors.
Page 16
INFO1 Project
below. Write also a test program test_segment.py to test all the functions of the
class.
3. Create a graph.py le and write the class Graph and the functions given below.
Write also a test program test_graph.py to test all the functions of the class.
You can write additional functions if you think they may be convenient so that your code
is neat, understandable, and it allows you to avoid repeating the same instructions in
several places. But remember to add the comments explaining the functionality and the
parameters.
Test programs shall import the python modules where the class and its dened
functions are.
BUILD TEST PROGRAMS THAT VERIFY ALL THE INPUT CONDITIONS, INCLUDING
ERRONEOUS PARAMETERS, TO VERIFY THAT THEY WORK CORRECTLY.
Node (name, x, y)
Input parameters: The name of the node and the horizontal and vertical cartesian location of
the node. Output parameter: an object of class Node with the given values and an empty list
of neighbors
Description: Constructor.
Additionally, write a test program for the class Node test_node.py using as a base the code below,
that declares 3 Nodes and adds the first two as neighbors of the third. Finally, it shows the content
of the third Node in the console to check it works correctly. Extend to test the error conditions.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
Page 17
INFO1 Project
import node
""" ===========================================================================================
Program to test the node
"""
#Main
n1 = node.Node("A",1,20)
n2 = node.Node("B",8,17)
n3 = node.Node("C",15,20)
addNeighbor (n3, n1)
addNeighbor (n3, n2)
print(n3.__dict__)
for n in n3.neighbors:
print (n.__dict__)
print ("OK")
Additionally, write a test program for the class Segment test_segment.py that declares 3 Nodes and
creates a Segment between the first and the second and another between the second and the third.
Check that the segment distance and the list of neighbors of the nodes is correctly updated.
Graph ()
Input parameters: None. Output parameter: a Graph
Description: constructor: Creates an empty Graph.
addNode (g, n)
Input parameters: a Graph and a Node. Output parameter: boolean
Description: Adds the node n in the list of nodes of graph g. Returns True if the operation is
Page 18
INFO1 Project
successful or False if the node was already in the list (the node name shall be the unique
identifier).
plot (g)
Input parameters: a Graph. Output parameter: None
Description: Shows on the screen a plot of the graph, showing the nodes, the segments, and
the costs of the segments.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import node
import segment
import graph
""" ===========================================================================================
Program to test the graph
"""
Page 19
INFO1 Project
graph.addSegment(G, "A","B")
graph.addSegment(G, "A","E")
graph.addSegment(G, "A","K")
graph.addSegment(G, "B","A")
graph.addSegment(G, "B","C")
graph.addSegment(G, "B","F")
graph.addSegment(G, "B","K")
graph.addSegment(G, "B","G")
graph.addSegment(G, "C","D")
graph.addSegment(G, "C","G")
graph.addSegment(G, "D","G")
graph.addSegment(G, "D","H")
graph.addSegment(G, "D","I")
graph.addSegment(G, "E","F")
graph.addSegment(G, "F","L")
graph.addSegment(G, "G","B")
graph.addSegment(G, "G","F")
graph.addSegment(G, "G","H")
graph.addSegment(G, "I","D")
graph.addSegment(G, "I","J")
graph.addSegment(G, "J","I")
graph.addSegment(G, "K","A")
graph.addSegment(G, "K","L")
graph.addSegment(G, "L","K")
graph.addSegment(G, "L","F")
return G
#Main
print ("Probando el grafo...")
G = crearGrafoEjemplo()
graph.plot(G)
graph.plotNode(G, "C")
print ("OK")
The result of the execution of this program must be (more or less) the image below, which is made
using plots.
Page 20
INFO1 Project
CONGRATULATIONS!!!
You already have a Graph class able to add a list of nodes, dene connections between
them, and show them in plots.
Deliver of Phase 1
Work with your group in these functionalities. For this phase deliver only the individual work done
before the next class in ATENEA, and the meeting summaries everytime the group finishes a
meeting.
Page 21