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

Bootcamp - Davis Liu #109

Closed
wants to merge 8 commits into from
Closed

Bootcamp - Davis Liu #109

wants to merge 8 commits into from

Conversation

davisliu2006
Copy link

No description provided.

Comment on lines 81 to 90
if report.status == drone_status.DroneStatus.HALTED: # if command done
if self.command_index < len(self.commands): # next command
print(f"frame({self.counter}) cmd({self.command_index}) pos({report.position})")
command = self.commands[self.command_index]
self.command_index += 1
elif not self.has_sent_landing_command: # start landing
command = commands.Command.create_land_command()
self.has_sent_landing_command = True

self.counter += 1

Choose a reason for hiding this comment

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

note that we have a acceptance_radius attribute

due to drone position being analog, this is often required when checking if we have reached a location. it is important to double check after the drone has halted that the drone is indeed at the location specified in the command

@@ -69,6 +79,34 @@ def run(
# ============

# Do something based on the report and the state of this class...
pos_x = report.position.location_x
pos_y = report.position.location_y
if report.status == drone_status.DroneStatus.HALTED: # if command done

Choose a reason for hiding this comment

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

apply the double check with location here as well

Comment on lines +125 to +126
if not result:
return [], image_annotated # data is invalid

Choose a reason for hiding this comment

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

nice job returning the whole dataset as wrong, this is common practice done

Copy link

@AaronWang04 AaronWang04 left a comment

Choose a reason for hiding this comment

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

good job adding the check, just some nit picks on PR quality and code flow issues that can be improved!

Comment on lines 86 to 87
def square(x: float) -> float:
return x * x

Choose a reason for hiding this comment

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

unnecessary, if needed the math library has functions for power.

Comment on lines 52 to 53
# self.has_land = False
# self.counter = 0

Choose a reason for hiding this comment

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

pr should be cleaned up without commented out code

Comment on lines 41 to 42
self.trg_x = 0
self.trg_y = 0

Choose a reason for hiding this comment

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

use variable names that are very clear in what it means, it helps reviewers and other members understand the code faster even if it makes the code longer

Comment on lines 86 to 99
def square(x: float) -> float:
return x * x

def wrong_rel_pos(i: int) -> bool: # returns true if the drone halts at wrong position
if i < 0 or i >= len(self.commands):
return False
cmd = self.commands[i]
if cmd.get_command_type() == commands.Command.CommandType.SET_RELATIVE_DESTINATION:
pos_x = report.position.location_x
pos_y = report.position.location_y
return square(pos_x - self.trg_x) + square(pos_y - self.trg_y) > square(
self.acceptance_radius
)
return False

Choose a reason for hiding this comment

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

good use of type hinting!

Comment on lines 116 to 118
cmd_x, cmd_y = command.get_relative_destination()
self.trg_x += cmd_x
self.trg_y += cmd_y

Choose a reason for hiding this comment

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

I think this is redundant, you can just use the waypoint's location_x and location_y to check whether you are at the location you want since you know that is the exact location you are trying to reach

Comment on lines 105 to 122
if wrong_rel_pos(self.command_index - 1): # repeat previous command
command = commands.Command.create_set_relative_destination_command(
self.trg_x - pos_x, self.trg_y - pos_y
)
elif self.command_index < len(self.commands): # next command
print(f"cmd({self.command_index}) pos({report.position})")
command = self.commands[self.command_index]
if (
command.get_command_type()
== commands.Command.CommandType.SET_RELATIVE_DESTINATION
): # update target position
cmd_x, cmd_y = command.get_relative_destination()
self.trg_x += cmd_x
self.trg_y += cmd_y
self.command_index += 1
elif self.land_status == 0: # start landing
command = commands.Command.create_land_command()
self.land_status = 2

Choose a reason for hiding this comment

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

nit pick but generally you want the "double check" if statements to be at the bottom, which makes more sense when reading

Copy link

@AaronWang04 AaronWang04 left a comment

Choose a reason for hiding this comment

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

LGTM, remember that you won't have to cache waypoint location for our specific scenario because waypoint is constant and is passed in as an argument.

@AaronWang04 AaronWang04 closed this Oct 4, 2024
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