Skip to content

Commit

Permalink
Add code to check matching UTM zones #16
Browse files Browse the repository at this point in the history
  • Loading branch information
RexBerry committed Oct 18, 2022
1 parent fddf682 commit 9558936
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion flight/avoidance/obstacle_avoidance.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async def calculate_avoidance_path(
drone : mavsdk.System
The drone for which the path will be calculated for
obstacle_data : list[InputPoint]
Previously known positions
Positions at previous times of the obstacle (probably another drone)
avoidance_radius : float
The radius around the predicted center of the obstacle the drone should avoid
Expand All @@ -163,6 +163,21 @@ async def calculate_avoidance_path(
# Convert drone position to UTM Point
drone_position: Point = Point.from_mavsdk_position(raw_drone_position)

# Convert obstacle data to list of Point
obstacle_positions: list[Point] = [Point.from_dict(in_point) for in_point in obstacle_data]

# TODO: Make the function work if UTM zones differ
# Check if all positions are in the same UTM zone
point: Point
for point in obstacle_positions:
if (
point.utm_zone_letter != drone_position.utm_zone_letter
or point.utm_zone_number != drone_position.utm_zone_number
):
raise ValueError(
"Points are in different UTM zones (Note: tell obstacle avoidance team to fix this)"
)

# Get velocity of drone
raw_drone_velocity: mavsdk.telemetry.VelocityNed
async for velocity in drone.telemetry.velocity_ned():
Expand Down

0 comments on commit 9558936

Please sign in to comment.