-
Notifications
You must be signed in to change notification settings - Fork 267
Bootcamp Complete - Tejas Srikanth #49
base: main
Are you sure you want to change the base?
Conversation
TongguangZhang
left a comment
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
| # * device | ||
| # * verbose | ||
| predictions = ... | ||
| predictions = self.__model.predict(source=image, conf=0.7, show_conf=True) |
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 parameters of interest above - we want to set the source, conf, device, and verbose (but not the show_conf)
| # Plot the annotated image from the Result object | ||
| # Include the confidence value | ||
| image_annotated = ... | ||
| image_annotated = prediction.orig_img |
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.
We're looking for the annotated image (with the confidence threshold), not the original image
| # Hint: .shape gets the dimensions of the numpy array | ||
| # for i in range(0, ...): | ||
| for i in range(0, boxes_cpu.shape[0]): | ||
| # Create BoundingBox object and append to list | ||
| # result, 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.
let's remove this commented out code since we're not using it (the if statement and result, box =) we can go back for it in the git history if we ever need it
| result, box = bounding_box.BoundingBox.create(boxes_cpu[i]) | ||
|
|
||
| if not result: | ||
| return ([], image_annotated) |
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.
let's remove unnecessary brackets, return [], image annotated will work here
| self.commands = [ | ||
| commands.Command.create_set_relative_destination_command( 4, 1), | ||
| commands.Command.create_set_relative_destination_command( 0.0, -2), | ||
| commands.Command.create_set_relative_destination_command(-4, 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.
let's not hardcode the coordinates - use self.waypoint instead
| # ↑ BOOTCAMPERS MODIFY ABOVE THIS COMMENT ↑ | ||
| # ============ | ||
|
|
||
| def getL2Norm(self, l1: location.Location, l2: location.Location) -> int: |
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.
technically this doesn't give us the L2 norm - it gives the square of the L2 norm, let's rename the function to be more descriptive (btw, we try to use snake_case instead of camelCase)
| # ============ | ||
|
|
||
| def getL2Norm(self, l1: location.Location, l2: location.Location) -> int: | ||
| return (l2.location_x - l1.location_x) * (l2.location_x - l1.location_x) + (l2.location_y - l1.location_y) * (l2.location_y - l1.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.
let's use ** 2 to make it explicit that we're squaring and not multiplying
| elif report.status == drone_report.drone_status.DroneStatus.HALTED and not self.landed_at_waypoint: | ||
|
|
||
| self.landed_at_waypoint = True | ||
| min_landing_distance = 10000000 |
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.
let's try to not use arbitrary values or magic numbers - set this to infinity instead with min_landing_distance = float('inf')
|
|
||
| elif report.status == drone_report.drone_status.DroneStatus.HALTED and not self.landed_at_waypoint: | ||
|
|
||
| self.landed_at_waypoint = True |
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.
we're not actually landing at the waypoint here, just stopped, let's rename this to be more descriptive
| if report.status == drone_report.drone_status.DroneStatus.HALTED and self.command_index<len(self.commands): | ||
| command = self.commands[self.command_index] | ||
| self.command_index += 1 | ||
|
|
||
| elif report.status == drone_report.drone_status.DroneStatus.HALTED and not self.landed_at_waypoint: | ||
|
|
||
| self.landed_at_waypoint = True | ||
| min_landing_distance = 10000000 | ||
| for landing_pad in landing_pad_locations: | ||
| distance_to_lp = self.getL2Norm(landing_pad, report.position) | ||
| if distance_to_lp < min_landing_distance: | ||
| self.landing_pad_cache = landing_pad | ||
| min_landing_distance = distance_to_lp | ||
|
|
||
| location_delta_x = self.landing_pad_cache.location_x - report.position.location_x | ||
| location_delta_y = self.landing_pad_cache.location_y - report.position.location_y | ||
| self.commands.append(commands.Command.create_set_relative_destination_command(location_delta_x, location_delta_y)) | ||
| command = self.commands[self.command_index] | ||
|
|
||
| self.command_index += 1 | ||
|
|
||
| elif report.status == drone_report.drone_status.DroneStatus.HALTED and not self.has_sent_landing_command: | ||
| self.has_sent_landing_command = True | ||
| 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.
let's use the acceptance radius here too - we don't want to land if the drone is too far from the waypoint
No description provided.