Skip to content

added route for calculating which points drone should fly to.#57

Open
vayer2005 wants to merge 16 commits into
mainfrom
mapping_points
Open

added route for calculating which points drone should fly to.#57
vayer2005 wants to merge 16 commits into
mainfrom
mapping_points

Conversation

@vayer2005

@vayer2005 vayer2005 commented Oct 19, 2024

Copy link
Copy Markdown
Member

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 apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  • Test A
  • Test B

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.

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Comment thread src/mapping/views.py Outdated
points = MappingRoute(
points_on_route=json.dumps(final_grid), altitude=json.dumps(alt)
)
points.save()

Copy link
Copy Markdown

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

Comment thread src/mapping/views.py Outdated
Comment on lines +122 to +133
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)

Copy link
Copy Markdown

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 😉

Comment thread src/mapping/views.py Outdated
Comment on lines +72 to +100
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)

Copy link
Copy Markdown

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 👀

Copy link
Copy Markdown
Collaborator

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

Comment thread .vscode/settings.json

Copy link
Copy Markdown
Collaborator

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

Comment thread src/mapping/models.py

Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

Comment thread src/mapping/models.py Outdated
altitude = models.FloatField()

# methods
def save(self, **kwargs):

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

Comment thread src/mapping/views.py Outdated
Comment on lines +72 to +100
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)

Copy link
Copy Markdown
Collaborator

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

@21chanas3 21chanas3 left a comment

Copy link
Copy Markdown
Collaborator

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

Comment thread .vscode/settings.json

Copy link
Copy Markdown
Collaborator

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

Comment thread src/mapping/models.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

Comment thread src/mapping/models.py Outdated
altitude = models.FloatField()

# methods
def save(self, **kwargs):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

Comment thread src/mapping/service.py Outdated
Comment on lines +10 to +11
for i in range(xcount * ycount):
meshGrid.append(((i % xcount) + overlap) / (xcount - (1 - 2 * overlap)))

Copy link
Copy Markdown
Collaborator

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?

Comment thread src/mapping/service.py Outdated
Comment on lines +17 to +20
for i in range(xcount * ycount):
meshGrid.append(
(math.floor(i / xcount) + overlap) / (ycount - (1 - 2 * overlap))
)

Copy link
Copy Markdown
Collaborator

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

@vayer2005
vayer2005 requested a review from 21chanas3 April 3, 2025 02:55
@vayer2005
vayer2005 removed the request for review from afahimi April 15, 2025 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants