Skip to content
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

Update support for DJI air 3 drones #413

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/backend/app/models/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ class HTTPStatus(IntEnum):
NOT_IMPLEMENTED = 501


class DroneType(IntEnum):
DJI_MINI_4_PRO = 1
class DroneType(StrEnum):
DJI_MINI_4_PRO = "DJI_MINI_4_PRO"
DJI_AIR_3 = "DJI_AIR_3"


class UserRole(IntEnum, Enum):
Expand Down
12 changes: 10 additions & 2 deletions src/backend/app/waypoints/waypoint_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from app.projects import project_deps
from shapely.geometry import shape
from app.waypoints import waypoint_schemas

from app.models.enums import DroneType

# Constant to convert gsd to Altitude above ground level
GSD_to_AGL_CONST = 29.7 # For DJI Mini 4 Pro
Expand All @@ -48,6 +48,7 @@ async def get_task_waypoint(
project_id: uuid.UUID,
task_id: uuid.UUID,
download: bool = True,
drone_type: DroneType = DroneType.DJI_MINI_4_PRO,
take_off_point: waypoint_schemas.PointField = None,
):
"""
Expand Down Expand Up @@ -113,6 +114,7 @@ async def get_task_waypoint(
generate_each_points=generate_each_points,
generate_3d=generate_3d,
take_off_point=take_off_point,
drone_type=drone_type,
)

parameters = calculate_parameters(
Expand All @@ -121,6 +123,7 @@ async def get_task_waypoint(
altitude,
gsd,
2, # Image Interval is set to 2
drone_type,
)

if project.is_terrain_follow:
Expand Down Expand Up @@ -153,7 +156,9 @@ async def get_task_waypoint(
filename=f"{task_id}_flight_plan.kmz",
)
flight_data = calculate_flight_time_from_placemarks(placemarks)
return {"results": placemarks, "flight_data": flight_data}

drones = list(DroneType.__members__.keys())
return {"results": placemarks, "flight_data": flight_data, "drones": drones}


@router.post("/")
Expand Down Expand Up @@ -199,6 +204,7 @@ async def generate_kmz(
description="The Digital Elevation Model (DEM) file that will be used to generate the terrain follow flight plan. This file should be in GeoTIFF format",
),
take_off_point: waypoint_schemas.PointField = None,
drone_type: DroneType = DroneType.DJI_MINI_4_PRO,
):
if not (altitude or gsd):
raise HTTPException(
Expand Down Expand Up @@ -242,6 +248,7 @@ async def generate_kmz(
generate_each_points=generate_each_points,
generate_3d=generate_3d,
take_off_point=take_off_point,
drone_type=drone_type,
)
return geojson.loads(points)
else:
Expand All @@ -255,6 +262,7 @@ async def generate_kmz(
dem=dem_path if dem else None,
outfile=f"/tmp/{uuid.uuid4()}",
take_off_point=take_off_point,
drone_type=drone_type,
)

return FileResponse(
Expand Down
Loading