-
Notifications
You must be signed in to change notification settings - Fork 0
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
rewrote flight interface to receive commands #14
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed
def run_decision_handler(self, command: decision_command.DecisionCommand) -> bool: | ||
""" | ||
Uploads decision commands to drone. | ||
""" | ||
if command is None: | ||
return False | ||
if command == "RESUME": | ||
self.resume_handler() | ||
return True | ||
if command == "STOP": | ||
self.stop_handler() | ||
return True | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the struct, not strings
command = None | ||
|
||
try: | ||
command: decision_command.DecisionCommand = command_in_queue.queue.get() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be get_nowait(), since get() is blocking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewd
command = None | ||
|
||
try: | ||
command: decision_command.DecisionCommand = command_in_queue.queue.get_nowait() | ||
interface.run_decision_handler(command) | ||
except queue.Empty: | ||
pass | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe move this block to the end so we're guaranteed that the command is not none
- remove the line initializing command = none
- instead of passing in the exception, continue instead
- put the
interface.run_decision_handler(command)
line after the try catch block so the continue will skip it
if command is None: | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from above, we can remove this check
ecccca2
to
23a4e87
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed
from . import conversions | ||
from .. import drone_odometry_local | ||
from modules import drone_odometry_local | ||
from modules import decision_command | ||
|
||
from ..common.mavlink.modules import drone_odometry | ||
from ..common.mavlink.modules import flight_controller | ||
|
||
|
||
from . import conversions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
take a look at the convention for imports https://uwarg-docs.atlassian.net/wiki/spaces/CV/pages/2253226033/Python+Style+Convention#Imports
|
||
interface.run_decision_handler(command) | ||
|
||
odometry_out_queue.queue.put(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this above the try catch, we always want to output the odometry
@@ -38,4 +41,13 @@ def flight_interface_worker( | |||
if not result: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass instead of continue, if we don't get an printer
odometry but do get a command we do want to send the command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
No description provided.