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

Khalil Hawari Bootcamp #139

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

Khalil Hawari Bootcamp #139

wants to merge 13 commits into from

Conversation

Khalil-Hawari
Copy link

(Awaiting review, as of this post)

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 129 to 130
if result:
bounding_boxes.append(box)
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of skipping failed boxes, we acc wanna return an empty list - in data science, when part of a data point is corrupted, we skip the whole data point instead of returning partial data, in this case, 1 image is 1 data point, and the boxes are part of the image, so we skip the whole image if any of the boxes fail

Comment on lines 73 to 81
on_waypoint = (
report.position.location_x - self.acceptance_radius
<= self.waypoint.location_x
<= report.position.location_x + self.acceptance_radius
) and (
report.position.location_y - self.acceptance_radius
<= self.waypoint.location_y
<= report.position.location_y + self.acceptance_radius
)
Copy link
Contributor

Choose a reason for hiding this comment

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

acceptance radius we consider to be strictly <, not <=

Comment on lines 73 to 81
on_waypoint = (
report.position.location_x - self.acceptance_radius
<= self.waypoint.location_x
<= report.position.location_x + self.acceptance_radius
) and (
report.position.location_y - self.acceptance_radius
<= self.waypoint.location_y
<= report.position.location_y + self.acceptance_radius
)
Copy link
Contributor

Choose a reason for hiding this comment

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

this gives us a square acceptance, we actually want to use a circle, consider delta_x ^ 2 + delta_y ^ 2 < acceptance_radius ^ 2 instead

Comment on lines 84 to 85
if on_waypoint:
command = commands.Command.create_land_command()
Copy link
Contributor

Choose a reason for hiding this comment

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

try to keep variables in scope, since on_waypoint is only used inside the if statement, you should only calculate it inside the if statement (it also avoids unnecessary calculations

)

# Handle unexpected halts
if report.position != report.destination:
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not how we check if the drone has reached a location - use the acceptance radius instead

Comment on lines 118 to 119
i = 0
winning_i = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

it's better to store the landing pad object, not the index of the winning landing pad

Comment on lines 115 to 116
wp_x = self.waypoint.location_x
wp_y = self.waypoint.location_y
Copy link
Contributor

Choose a reason for hiding this comment

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

why would you use the waypoint location instead of the drone's position?


sq_dist = (lp_x - wp_x) ** 2 + (lp_y - wp_y) ** 2

if (sq_dist < winning_dist) or (winning_dist == -1):
Copy link
Contributor

Choose a reason for hiding this comment

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

if you wanted to check if it was the first landing pad, I would suggest i == 1
however, we usually want to avoid this kind of hard coded edge case handling, instead, initialize winning_dist to infinity (search up how infinity is represented in python)

Comment on lines 126 to 128
same_loc = (
wp_x - self.acceptance_radius <= lp_x <= wp_x + self.acceptance_radius
) and (wp_y - self.acceptance_radius <= lp_y <= wp_y + self.acceptance_radius)
Copy link
Contributor

Choose a reason for hiding this comment

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

why only - and not + this time?
but also, this is again a square, we want to use a circle instead

Comment on lines 130 to 131
if same_loc:
return i
Copy link
Contributor

Choose a reason for hiding this comment

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

why would you need to explicitly check if it is the same loc? if it was the same loc, wouldn't that landing pad also have the smallest distance and you'd return it anyways?

Copy link
Author

Choose a reason for hiding this comment

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

Correct, I had figured that if it were the same location then there was no point in continuing the loop -> it could just return right there.
However, if this rarely ever happens then it's not worth checking. I'll remove it, thx

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 81 to 84
else:
command = commands.Command.create_set_relative_destination_command(
self.waypoint.location_x, self.waypoint.location_y
)
Copy link
Contributor

Choose a reason for hiding this comment

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

note that this is relative position, not absolute, you can't just use the location of the waypoint (make sure you run your tests before requesting a rereview

# ============
# ↓ BOOTCAMPERS MODIFY BELOW THIS COMMENT ↓
# ============

# Do something based on the report and the state of this class...
# print("RUN")
Copy link
Contributor

Choose a reason for hiding this comment

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

it's ok to have print statements, but we want to delete commented out code, take a look at the style guide section on dead code

Comment on lines -64 to -66
# Default command
command = commands.Command.create_null_command()

Copy link
Contributor

Choose a reason for hiding this comment

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

don't modify code outside the comment guards - you deleted this and then copied it back down below

Comment on lines 77 to 80
print("HALTED AT: ", report.position.location_x, report.position.location_y)
print(
"DESTINATION WAS: ", report.destination.location_x, report.destination.location_y
)
Copy link
Contributor

Choose a reason for hiding this comment

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

it's worth taking a look at python string formatting - I'd recommend looking at f-string docs, as well as special characters such as -t (no need to change anything here, just smth to keep in mind)

Comment on lines 94 to 97
elif not self.approaching_wp:
command = commands.Command.create_set_relative_destination_command(
self.waypoint.location_x, self.waypoint.location_y
)
Copy link
Contributor

Choose a reason for hiding this comment

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

incorrect, you need relative instead of absolute coords

predictions = self.__model.predict(
source=image, conf=0.7, device=self.__DEVICE, verbose=False
)
# print("PREDICTIONSSS: ", prediction)
Copy link
Contributor

Choose a reason for hiding this comment

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

delete or uncomment


# Get the Result object
prediction = ...
prediction = predictions[0]
# print("PREDICTION: ", prediction)
Copy link
Contributor

Choose a reason for hiding this comment

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

delete or uncomment

Comment on lines 117 to 119
# print("BOXES-CPU TYPE: ", type(boxes_cpu))
# print("BOXES-CPU: ", boxes_cpu)
# print("BOXES-CPU ND SHAPE", boxes_cpu.shape)
Copy link
Contributor

Choose a reason for hiding this comment

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

delete or uncomment

Comment on lines 128 to 130
# print("RESULT: ", result)
# print("BOX: ", box)

Copy link
Contributor

Choose a reason for hiding this comment

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

delete or uncomment

if result:
bounding_boxes.append(box)
else:
return []
Copy link
Contributor

Choose a reason for hiding this comment

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

is this what the function is supposed to return? take another look at the return annotation, as well as your own code on line 136

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