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 states #64

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open

Feature/flight states #64

wants to merge 13 commits into from

Conversation

cjhr95
Copy link
Contributor

@cjhr95 cjhr95 commented Apr 19, 2022

Better flight states, along with JSON parsing.

@cjhr95 cjhr95 added documentation Improvements or additions to documentation flight Pertaining to the physical movement of the drone feature New feature to add Infrastructure Core infrastructure-related task labels Apr 19, 2022
@cjhr95 cjhr95 requested a review from mrouie April 19, 2022 23:28
@cjhr95 cjhr95 self-assigned this Apr 19, 2022
@cjhr95 cjhr95 linked an issue Apr 20, 2022 that may be closed by this pull request
Copy link
Member

@mrouie mrouie left a comment

Choose a reason for hiding this comment

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

Lots of files makes it look like there are lots of mistakes, but in reality, there are just a lot of the same thing, which is fine. Shouldn't be too bad fixing them tho.

Comment on lines 12 to 43
Methods
-------
__init__
Sets preliminary values for SUAS overheads
@Property
simple_takeoff() -> bool
Setter to determine if testing takeoff procedure desired
num_waypoints() -> int
Sets the number of waypoints in the competition
run_title() -> str
Sets the name of the current flight for logging
run_description() -> str
Sets the description of current flight mission

@Setters
simple_takeoff() -> None
Enables access to status of simple_takeoff
num_waypoints() -> None
Enables access to number of waypoints in the competition
run_title() -> None
Enables access to description of current flight mission
run_description() -> None
Enables access to description of current flight mission

Attributes
----------
__num_waypoints: int
Number of waypoints on flight plan
__run_title: str
Title of Competition
__run_description: str
Description for Competition
Copy link
Member

Choose a reason for hiding this comment

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

Attributes section should come first in the class docstring, and it shouldn't list private variables, but rather should list the variables as their accessed, so its list would be what you have just without the leading __ because that's how the instance variables are accessed.
Methods section should not include getters/setters because those functions should never be called explicitly (that's the point of the @Property and @property_name.setter decorators.
For example an instance setting of StateSettings can just set __num_waypoints by doing setting.num_waypoints = ...

Comment on lines 13 to 16
Parameters
----------
run() -> Final
Running the landing procedure after returning to home
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean for this section to be titled "Methods"?


Attributes
----------
N/A
Copy link
Member

Choose a reason for hiding this comment

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

Should be None instead of N/A

Comment on lines 13 to 15
Attributes
----------
N/A
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, should be None instead of N/A

flight/states/land.py Show resolved Hide resolved
Comment on lines 29 to 30
f.close()
f.close()
Copy link
Member

Choose a reason for hiding this comment

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

You don't need an f.close since you're using a context manager.
Also everything should be either structurally subtyped or Any, so you can either replace List with List[Any] if you're sure that the json is to be loaded in as a dictionary mapping strings to lists or you can replace List with just Any so that you can account for any type being mapped. Json typing is really not in a good place right now in python, so that's the only reasonably readable way to do it.
The result should look like this:

with open(filename) as f:
    data_set: Dict[str, Any] = json.load(f)

Comment on lines 51 to 54
Raises
------
General
Designed to detect any error to prevent data corruption and always close the file being read
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, this section is not needed because nothing is being raised with the raise keyword

Comment on lines 20 to 23
Raises
------
General
Designed to detect any error to prevent data corruption and always close the file being read
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't actually raise this.
Instead you're technically "catching" an exception, which is not something you need to mention in the docstring.

Comment on lines 56 to 61
with open(filename) as f:
try:
data_set: Dict[str, List] = json.load(f)
except:
f.close()
f.close()
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, context managers handle file closing, so you don't need any of the try-except or f.close() stuff


Returns
-------
List[Dict[str, float]]
Copy link
Member

Choose a reason for hiding this comment

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

Since you're returning a variable name, I'd take the opportunity to include that in here.
This would look like this (and this is what the colon is meant for).

stationary_obs : List[Dict[str, float]]

instead of just List[Dict[str, float]]

@cjhr95 cjhr95 requested a review from mrouie April 23, 2022 01:58
Copy link
Member

@mrouie mrouie left a comment

Choose a reason for hiding this comment

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

Just a few things and it's ready to go.

Comment on lines +3 to +9
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
Copy link
Member

Choose a reason for hiding this comment

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

Again, these need to be absolute imports.
Ex. from flight.states.state import State


Returns
-------
Land
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean OffAxisODLC?


Methods
-------
run() -> Land
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean run() -> OffAxisODLC?

"""
return

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

Choose a reason for hiding this comment

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

Name this a little less redundantly.
Maybe something like _ensure_arm()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature New feature to add flight Pertaining to the physical movement of the drone Infrastructure Core infrastructure-related task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Core structure for Flight State Machine
2 participants