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

Feature/flight structure #29

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0a8c6f8
Prelim Interop Testing
cjhr95 Oct 27, 2021
ad080ff
JSON Parsing for Waypoints & St. Obstacles
cjhr95 Mar 2, 2022
4849718
Prelim Base Flight Structure
cjhr95 Mar 4, 2022
e2ad2f7
Flight Structure w/o Decorators
cjhr95 Mar 9, 2022
c90eaa2
Settings w/ Decorators
cjhr95 Mar 9, 2022
51e3348
Test
cjhr95 Mar 16, 2022
c007851
JSON Parsing Documentation
cjhr95 Mar 23, 2022
59ef20b
Single Line Docstring and Test File Removal
cjhr95 Mar 23, 2022
17d9c3a
Documentation updates
cjhr95 Apr 8, 2022
86e31b9
Redundant Task
mat-px Nov 4, 2021
4be6bfc
pre-commit config from IARC
mat-px Nov 4, 2021
5c2816e
gitignore from IARC
mat-px Nov 4, 2021
332a2c0
Update .pre-commit-config.yaml
mat-px Nov 4, 2021
1b80126
Update README.md
mat-px Nov 4, 2021
5fed42d
Update README.md
mat-px Nov 4, 2021
e1fa9f7
Add json, xml, yaml, and mixed line ending hooks
mrouie Nov 5, 2021
c283b6a
Resolved errors
mrouie Nov 5, 2021
e3f7cfe
Create object bounding box script.
ClayJay3 Nov 5, 2021
fdee5e9
Update object_bounding_box.py
ClayJay3 Nov 10, 2021
a68ed20
Test file. remove pls
mrouie Mar 2, 2022
c85e276
Auto-Formatting
fallscameron01 Feb 9, 2022
317d562
Initial text detection
fallscameron01 Feb 9, 2022
3664a47
notes on random ideas
fallscameron01 Feb 9, 2022
db2ed9b
Updated format, typing
fallscameron01 Feb 11, 2022
91a8e3f
Filtering detected text
fallscameron01 Feb 11, 2022
d1cf74b
Plan for getting text color
fallscameron01 Feb 11, 2022
b05b5f9
Update doc, fix char check
fallscameron01 Feb 11, 2022
5dee156
Image processing, fixed detection
fallscameron01 Feb 16, 2022
ebb5cf6
Draw line around detected characters
fallscameron01 Feb 16, 2022
79f6418
Autoformatting
fallscameron01 Feb 16, 2022
26b1d7b
New preprocessing, rotate images
fallscameron01 Feb 23, 2022
058fbe4
Put functions in class
fallscameron01 Feb 23, 2022
089acfd
Add check for full-image text
fallscameron01 Feb 23, 2022
970e16f
Fix crop/rotation, cleanup
fallscameron01 Mar 2, 2022
ee9b833
Add get_text_characteristics, cleanup
fallscameron01 Mar 2, 2022
322595d
Cleanup and documentation updates
fallscameron01 Mar 2, 2022
25f1927
Add command line args
fallscameron01 Mar 4, 2022
a1961b3
Initial obstacle avoidance code
cmspencer109 Mar 4, 2022
7240e91
Document and type all functions
cmspencer109 Mar 6, 2022
b21c2d2
Resolve documentation issues and dead code
cmspencer109 Mar 9, 2022
117921c
Add poetry python dependencies and dev dependencies
mrouie Mar 11, 2022
aeb9168
Reformat file.
mrouie Mar 11, 2022
bbe1e1c
AirDrop & ODLC States
cjhr95 Apr 15, 2022
5c5a33f
Revert "Documentation updates"
cjhr95 Apr 15, 2022
1a6f2e0
Documentation
cjhr95 Apr 15, 2022
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
3 changes: 3 additions & 0 deletions flight/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions flight/.idea/flight.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions flight/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions flight/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions flight/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions flight/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions flight/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Initialization file for state exporting"""
from typing import Dict
from states.state import State
from states.start_state import Start
from states.pre_processing import PreProcess
from states.takeoff import Takeoff
from states.waypoints import Waypoints
from states.land import Land
from states.final_state import Final

STATES: Dict[str, State] = {
"Start State": Start,
"Pre-Processing": PreProcess,
"Takeoff": Takeoff,
"Waypoints": Waypoints,
"Land": Land,
"Final State": Final
}
121 changes: 121 additions & 0 deletions flight/state_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
"""Class to contain setters and getters for settings in various flight states"""

DEFAULT_WAYPOINTS: int = 14 # Total number of waypoints flown to in Auto. flight of SUAS2022
DEFAULT_RUN_TITLE: str = "N/A" # Title of flight mission for logging
DEFAULT_RUN_DESCRIPTION: str = "N/A" # Description of current flight mission for logging


class StateSettings:
mrouie marked this conversation as resolved.
Show resolved Hide resolved
"""
Initialize settings for state machine
Functions:
__init__: Sets preliminary values for SUAS overheads
simple_takeoff() -> None: Enables access to status of simple_takeoff
-> bool: Setter to determine if testing takeoff procedure desired
num_waypoints() -> None: Enables access to number of waypoints in the competition
-> int: Sets the number of waypoints in the competition
run_title() -> None: Enables access to set name of the current flight
-> str: Sets the name of the current flight for logging
run_description() -> None: Enables access to description of current flight mission
-> str: Sets the description of current flight mission
Member Variables:
__num_waypoints: Number of waypoints on flight plan
__run_title: Title of Competition
__run_description: Description for Competition
"""
def __init__(self, takeoff_bool: bool = False, num_waypoints: int = DEFAULT_WAYPOINTS,
title: str = DEFAULT_RUN_TITLE, description: str = DEFAULT_RUN_DESCRIPTION):
Copy link
Member

Choose a reason for hiding this comment

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

Missing type annotation for None return type

"""Default constructor results in default settings
Args:
takeoff_bool: bool - determines if a simple takeoff procedure should be executed for testing
num_waypoints: int - Number of waypoints, extracted from SUAS mission plan
title: str - Title of current flight mission, for logging purposes
description: str - Description of current flight mission, for logging purposes
"""
self.__simple_takeoff = takeoff_bool
self.__num_waypoints = num_waypoints
self.__run_title = title
self.__run_description = description
Copy link
Member

Choose a reason for hiding this comment

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

I know it may seem redundant, but since this is the first time we're referencing these variable names,
they should be typed as well


mrouie marked this conversation as resolved.
Show resolved Hide resolved
# ---- Takeoff settings ---- #
@property
def simple_takeoff(self) -> bool:
"""Establishes simple_takeoff as a private member variable
Args:
N/A
Returns:
bool: Status of simple_takeoff variable
"""
return self.__simple_takeoff

@simple_takeoff.setter
def simple_takeoff(self, simple_takeoff: bool) -> None:
"""Setter for whether to perform simple takeoff instead of regular takeoff
Args:
simple_takeoff: bool - True for drone to go straight up, False to behave normally
Returns:
None
"""
self.__simple_takeoff = simple_takeoff

# ---- Waypoint Settings ---- #
@property
def num_waypoints(self) -> int:
"""Establishes num_waypoints as private member variable
Args:
N/A
Returns:
int: Number of waypoints in the competition
"""
return self.__num_waypoints

@num_waypoints.setter
def num_waypoints(self, waypoints: int) -> None:
"""Set the number of waypoints given by Interop System
Args:
waypoints: int - Number of waypoints present in mission plan
Returns:
None
"""
self.__num_waypoints = waypoints

# ---- Other settings ---- #
@property
def run_title(self) -> str:
"""Set a title for the run/test to be output in logging
Args:
N/A
Returns:
str: Created title for flight mission
"""
return self.__run_title

@run_title.setter
def run_title(self, title: str) -> None:
"""Sets the title of the flight mission for logging
Args:
title: str - Desired title for the flight
Returns:
None
"""
self.__run_title = title

@property
def run_description(self) -> str:
"""Set a description for the run/test to be output in logging
Args:
N/A
Returns:
str: Desired description for flight mission
"""
return self.__run_description

@run_description.setter
def run_description(self, description: str) -> None:
"""Sets a description of the flight mission
Args:
description: str - Written description for flight mission for logs
Returns:
None
"""
self.__run_description = description
3 changes: 3 additions & 0 deletions flight/states/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions flight/states/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions flight/states/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions flight/states/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions flight/states/.idea/states.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions flight/states/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions flight/states/final_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Final state to end all drone processes"""
import logging
from mavsdk import System
from state import State
from ..state_settings import StateSettings


class Final(State):
"""Empty state to end flight
Functions:
run() -> None: Ends the state machine
Member Variables:
None
"""
async def run(self, drone: System):
Copy link
Member

Choose a reason for hiding this comment

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

Missing None return type annotation

"""Do nothing and end
Args:
drone: System - drone object that must be passed to any function with control of the drone
Returns:
None
"""
return
24 changes: 24 additions & 0 deletions flight/states/land.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Landing the drone at home position after each other task is finished"""
import logging
from mavsdk import System
from state import State
from ..state_settings import StateSettings
from states.final_state import Final


class Land(State):
"""
State to land the drone safely after finishing other flight & vision tasks
Functions:
run() -> Final: Running the landing procedure after returning to home
Member Variables:
None
"""
async def run(self, drone: System) -> Final:
"""Run landing function to have drone slowly return to home position
Args:
drone: System - MAVSDK drone object for direct drone control
Returns:
Final: final state for ending state machine
"""
return Final(self.state_settings)
Empty file added flight/states/main.py
Empty file.
26 changes: 26 additions & 0 deletions flight/states/pre_processing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""State to receive data from interop system and perform preliminary calculations"""
import logging
from mavsdk import System
from state import State
from ..state_settings import StateSettings
from takeoff import Takeoff


class PreProcess(State):
mrouie marked this conversation as resolved.
Show resolved Hide resolved
"""
State to accept data and plan out optimal mission structure based on relative distances
Functions:
data_retrieval() -> Takeoff: Connects to Interop and downloads JSON data from system
... # Will add more functions as needed during dev
Member Variables:
None
"""
async def data_retrieval(self, drone: System) -> Takeoff:
"""Prelim function to accept data
Args:
drone: System - MAVSDK drone object for direct drone control
Returns:
Takeoff: the next state, the Takeoff state to advance state machine
"""
return Takeoff(self.state_settings)

23 changes: 23 additions & 0 deletions flight/states/start_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Beginning state of flight operation, proceed to pre-processing"""
import logging
from mavsdk import System
from state import State
from ..state_settings import StateSettings
from states.pre_processing import PreProcess


class Start(State):
"""Preliminary state, proceed state machine into pre-processing
Functions:
begin() -> PreProcess: beginning function to start state machine, proceeding to pre-processing step
Member Variables:
None
"""
async def begin(self, drone: System) -> PreProcess:
"""Initialization function to start flight state machine
Args:
drone: System - drone object for directv drone control
Returns:
PreProcess: data pre-processing state, to advance state machine
"""
return PreProcess(self.state_settings)
55 changes: 55 additions & 0 deletions flight/states/state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""Base State class which all other states inherit"""
import logging
from mavsdk import System
from ..state_settings import StateSettings


class State:
"""
Base State class
Attributes:
drone (System): The drone object; used for flight.
"""

def __init__(self, state_settings: StateSettings):
Copy link
Member

Choose a reason for hiding this comment

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

Missing function docstring and type hint for return type

Copy link
Member

Choose a reason for hiding this comment

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

Still missing docstring & return type hint

logging.info('State "%s" has begun', self.name)
self.state_settings = state_settings

async def run(self, drone: System):
Copy link
Member

Choose a reason for hiding this comment

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

Missing return type hint

Copy link
Member

Choose a reason for hiding this comment

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

Still missing return type hint

"""
Does all of the operations for the state
Parameters
----------
drone : System
The drone system; used for flight operations.
Returns
-------
State or None
Either the next State in the machine or None if the machine stops
Raises
------
Exception
If this function hasn't been overloaded.
"""
raise Exception("Run not implemented for state")

async def _check_arm_or_arm(self, drone: System):
Copy link
Member

Choose a reason for hiding this comment

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

Missing return type hint

Copy link
Member

Choose a reason for hiding this comment

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

Still missing return type hint

"""
Verifies that the drone is armed, if not armed, arms the drone
Parameters
----------
drone : System
The drone system; used for flight operations.
"""
async for is_armed in drone.telemetry.armed():
if not is_armed:
logging.debug("Not armed. Attempting to arm")
await drone.action.arm()
else:
logging.warning("Drone armed")
break

@property
def name(self):
"""Returns the name of the class"""
return type(self).__name__
Loading