-
Notifications
You must be signed in to change notification settings - Fork 249
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
base: main
Are you sure you want to change the base?
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
if result: | ||
bounding_boxes.append(box) |
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.
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
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 | ||
) |
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.
acceptance radius we consider to be strictly <, not <=
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 | ||
) |
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 gives us a square acceptance, we actually want to use a circle, consider delta_x ^ 2 + delta_y ^ 2 < acceptance_radius ^ 2 instead
if on_waypoint: | ||
command = commands.Command.create_land_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.
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: |
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 is not how we check if the drone has reached a location - use the acceptance radius instead
i = 0 | ||
winning_i = 0 |
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.
it's better to store the landing pad object, not the index of the winning landing pad
wp_x = self.waypoint.location_x | ||
wp_y = self.waypoint.location_y |
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.
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): |
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.
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)
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) |
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.
why only - and not + this time?
but also, this is again a square, we want to use a circle instead
if same_loc: | ||
return i |
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.
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?
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.
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
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
else: | ||
command = commands.Command.create_set_relative_destination_command( | ||
self.waypoint.location_x, self.waypoint.location_y | ||
) |
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.
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") |
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.
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
# Default command | ||
command = commands.Command.create_null_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.
don't modify code outside the comment guards - you deleted this and then copied it back down below
print("HALTED AT: ", report.position.location_x, report.position.location_y) | ||
print( | ||
"DESTINATION WAS: ", report.destination.location_x, report.destination.location_y | ||
) |
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.
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)
elif not self.approaching_wp: | ||
command = commands.Command.create_set_relative_destination_command( | ||
self.waypoint.location_x, self.waypoint.location_y | ||
) |
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.
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) |
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.
delete or uncomment
|
||
# Get the Result object | ||
prediction = ... | ||
prediction = predictions[0] | ||
# print("PREDICTION: ", prediction) |
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.
delete or uncomment
# print("BOXES-CPU TYPE: ", type(boxes_cpu)) | ||
# print("BOXES-CPU: ", boxes_cpu) | ||
# print("BOXES-CPU ND SHAPE", boxes_cpu.shape) |
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.
delete or uncomment
# print("RESULT: ", result) | ||
# print("BOX: ", box) | ||
|
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.
delete or uncomment
if result: | ||
bounding_boxes.append(box) | ||
else: | ||
return [] |
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.
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
(Awaiting review, as of this post)