-
-
Notifications
You must be signed in to change notification settings - Fork 0
added route for calculating which points drone should fly to. #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
src/mapping/views.py
Outdated
points = MappingRoute( | ||
points_on_route=json.dumps(final_grid), altitude=json.dumps(alt) | ||
) | ||
points.save() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine for now, but we will probably not need the grid to be saved once we've integrated your work with Kai's
src/mapping/views.py
Outdated
elif request.method == "GET": | ||
# Getting most recent drone rout from MappingRoute | ||
route = MappingRoute.objects.last() | ||
if route is None: | ||
return HttpResponse("No Drone Route Saved", status=204) | ||
|
||
points = { | ||
"points_on_route": json.loads(route.points_on_route), | ||
"altitude": json.loads(route.altitude), | ||
} | ||
|
||
return JsonResponse(points, status=200) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May need to be refactored in the future according to above 😉
src/mapping/views.py
Outdated
area = area_modelled.area_of_interest | ||
p1, p2, p3, p4 = area[0], area[1], area[2], area[3] | ||
p1x = p1["latitude"] | ||
p1y = p1["longidute"] | ||
p2x = p2["latitude"] | ||
p2y = p2["longidute"] | ||
p3x = p3["latitude"] | ||
p3y = p3["longidute"] | ||
p4x = p4["latitude"] | ||
p4y = p4["longidute"] | ||
# required altitude (meters) | ||
alt = (iw * d_focal * gsd) / sw | ||
|
||
# Maximum X and Y distances | ||
ylen1 = distance(p1x, p1y, p2x, p2y) | ||
ylen2 = distance(p3x, p3y, p4x, p4y) | ||
ymax = max(ylen1, ylen2) | ||
|
||
xlen1 = distance(p1x, p1y, p4x, p4y) | ||
xlen2 = distance(p2x, p2y, p3x, p3y) | ||
xmax = max(xlen1, xlen2) | ||
|
||
# Num pictures needed on X-axis and Y-axis | ||
xcount = math.ceil((xmax - (o * width)) / ((1 - o) * width)) + 1 | ||
ycount = math.ceil((ymax - (o * height)) / ((1 - o) * height)) + 1 | ||
|
||
# Creating Mesh Grids | ||
gridl = meshl(xcount, ycount, o) | ||
gridr = meshr(xcount, ycount, o) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having some basic tests for the calculations you did would be appreciated, maybe consider extracting this logic out into a helper class to facilitate that 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, also if it is resource-intensive, a celery worker should handle this
.vscode/settings.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add this folder to .gitignore
. also, in order to have test run by the CI, unittests should be done with django
src/mapping/models.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does storing these waypoint as a json instead of an array of Waypoints
offer any noticeable speedup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^
src/mapping/models.py
Outdated
altitude = models.FloatField() | ||
|
||
# methods | ||
def save(self, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a Singleton, please add that to the class name. Not too sure if a Singleton design pattern is necessary though, we can easily support two mapping areas that we do sequentially
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^
src/mapping/views.py
Outdated
area = area_modelled.area_of_interest | ||
p1, p2, p3, p4 = area[0], area[1], area[2], area[3] | ||
p1x = p1["latitude"] | ||
p1y = p1["longidute"] | ||
p2x = p2["latitude"] | ||
p2y = p2["longidute"] | ||
p3x = p3["latitude"] | ||
p3y = p3["longidute"] | ||
p4x = p4["latitude"] | ||
p4y = p4["longidute"] | ||
# required altitude (meters) | ||
alt = (iw * d_focal * gsd) / sw | ||
|
||
# Maximum X and Y distances | ||
ylen1 = distance(p1x, p1y, p2x, p2y) | ||
ylen2 = distance(p3x, p3y, p4x, p4y) | ||
ymax = max(ylen1, ylen2) | ||
|
||
xlen1 = distance(p1x, p1y, p4x, p4y) | ||
xlen2 = distance(p2x, p2y, p3x, p3y) | ||
xmax = max(xlen1, xlen2) | ||
|
||
# Num pictures needed on X-axis and Y-axis | ||
xcount = math.ceil((xmax - (o * width)) / ((1 - o) * width)) + 1 | ||
ycount = math.ceil((ymax - (o * height)) / ((1 - o) * height)) + 1 | ||
|
||
# Creating Mesh Grids | ||
gridl = meshl(xcount, ycount, o) | ||
gridr = meshr(xcount, ycount, o) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, also if it is resource-intensive, a celery worker should handle this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some questions and housekeeping but should be good. I only checked the style and clarity, you should also wait on @afahimi to comment
.vscode/settings.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this to .gitignore
src/mapping/models.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^
src/mapping/models.py
Outdated
altitude = models.FloatField() | ||
|
||
# methods | ||
def save(self, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^
src/mapping/service.py
Outdated
for i in range(xcount * ycount): | ||
meshGrid.append(((i % xcount) + overlap) / (xcount - (1 - 2 * overlap))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be separated into a nested loop for code clarity?
src/mapping/service.py
Outdated
for i in range(xcount * ycount): | ||
meshGrid.append( | ||
(math.floor(i / xcount) + overlap) / (ycount - (1 - 2 * overlap)) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above here
Description
Added MappingRoute model and routes that stores the arbitrarily long list of points that the drone should go to for mapping.
Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.
Added model and routes to mapping folder.
Resolves # (issue)
Type of change
What types of changes does your code introduce to this project?
Put an
x
in the boxes that applyHow Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. This is simply a reminder of what we are going to look for before merging your code.