Skip to content

Commit

Permalink
Create Velocity class #16
Browse files Browse the repository at this point in the history
  • Loading branch information
RexBerry committed Oct 12, 2022
1 parent bef139c commit 1548642
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion flight/avoidance/obstacle_avoidance.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import utm


# Input points are dicts with time and UTM coordinate data
# May change in the future
InputPoint = dict[str, float | int | str]
Expand Down Expand Up @@ -95,6 +94,43 @@ def from_mavsdk_position(cls, position: mavsdk.telemetry.Position) -> "Point":
return cls(easting, northing, zone_number, zone_letter, position.absolute_altitude_m)


@dataclass
class Velocity:
"""
A velocity in 3D space
Attributes
----------
north_vel : float
Eastward velocity in meters per second
east_vel : float
Northward velocity in meters per second
down_vel : float
Downward velocity in meters per second
"""

north_vel: float
east_vel: float
down_vel: float

@classmethod
def from_mavsdk_velocityned(cls, velocity: mavsdk.telemetry.VelocityNed) -> "Velocity":
"""
Factory method accepting a mavsdk.telemetry.VelocityNed object
Parameters
----------
velocity : mavsdk.telemetry.VelocityNed
A velocity (NED) from MAVSDK
Returns
-------
A new Velocity object
"""

return cls(velocity.north_m_s, velocity.east_m_s, velocity.down_m_s)


async def calculate_avoidance_path(
drone: mavsdk.System,
obstacle_data: list[InputPoint],
Expand Down

0 comments on commit 1548642

Please sign in to comment.