added route for calculating which points drone should fly to.#57
added route for calculating which points drone should fly to.#57vayer2005 wants to merge 16 commits into
Conversation
| points = MappingRoute( | ||
| points_on_route=json.dumps(final_grid), altitude=json.dumps(alt) | ||
| ) | ||
| points.save() |
There was a problem hiding this comment.
Fine for now, but we will probably not need the grid to be saved once we've integrated your work with Kai's
| 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.
May need to be refactored in the future according to above 😉
| 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.
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.
+1, also if it is resource-intensive, a celery worker should handle this
There was a problem hiding this comment.
please add this folder to .gitignore. also, in order to have test run by the CI, unittests should be done with django
There was a problem hiding this comment.
Does storing these waypoint as a json instead of an array of Waypoints offer any noticeable speedup?
| altitude = models.FloatField() | ||
|
|
||
| # methods | ||
| def save(self, **kwargs): |
There was a problem hiding this comment.
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
| 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.
+1, also if it is resource-intensive, a celery worker should handle this
There was a problem hiding this comment.
Please add this to .gitignore
| altitude = models.FloatField() | ||
|
|
||
| # methods | ||
| def save(self, **kwargs): |
| for i in range(xcount * ycount): | ||
| meshGrid.append(((i % xcount) + overlap) / (xcount - (1 - 2 * overlap))) |
There was a problem hiding this comment.
Can this be separated into a nested loop for code clarity?
| for i in range(xcount * ycount): | ||
| meshGrid.append( | ||
| (math.floor(i / xcount) + overlap) / (ycount - (1 - 2 * overlap)) | ||
| ) |
There was a problem hiding this comment.
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
xin the boxes that applyHow Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist
Put an
xin 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.