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

rewrote flight interface to receive commands #14

Merged
merged 17 commits into from
Jun 26, 2024
Merged

Conversation

ashum68
Copy link
Contributor

@ashum68 ashum68 commented Jun 18, 2024

No description provided.

Copy link
Contributor

@TongguangZhang TongguangZhang left a comment

Choose a reason for hiding this comment

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

reviewed

Comment on lines 72 to 84
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
Copy link
Contributor

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()
Copy link
Contributor

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

Copy link
Contributor

@TongguangZhang TongguangZhang left a comment

Choose a reason for hiding this comment

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

reviewd

Comment on lines 42 to 49
command = None

try:
command: decision_command.DecisionCommand = command_in_queue.queue.get_nowait()
interface.run_decision_handler(command)
except queue.Empty:
pass

Copy link
Contributor

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

  1. remove the line initializing command = none
  2. instead of passing in the exception, continue instead
  3. put the interface.run_decision_handler(command) line after the try catch block so the continue will skip it

Comment on lines 76 to 77
if command is None:
return False
Copy link
Contributor

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

@ashum68 ashum68 force-pushed the flight_interface_commands branch from ecccca2 to 23a4e87 Compare June 23, 2024 16:12
Copy link
Contributor

@TongguangZhang TongguangZhang left a comment

Choose a reason for hiding this comment

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

reviewed

Comment on lines 5 to 12
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
Copy link
Contributor

Choose a reason for hiding this comment

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


interface.run_decision_handler(command)

odometry_out_queue.queue.put(value)
Copy link
Contributor

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:
Copy link
Contributor

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

Copy link
Contributor

@TongguangZhang TongguangZhang left a comment

Choose a reason for hiding this comment

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

lgtm

@ashum68 ashum68 merged commit d6b08ac into main Jun 26, 2024
1 check passed
@ashum68 ashum68 deleted the flight_interface_commands branch June 26, 2024 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants