Skip to content

Commit

Permalink
take pictures without async to do it immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
EricPedley committed Jun 26, 2024
1 parent 066cae3 commit 9b70a27
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions uavf_2024/imaging/perception.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,15 @@ def get_image_down_async(self) -> Future[list[Target3D]]:
Non-blocking implementation of the infrence pipeline,
calling get_image_down in a separate process.
"""

self.log("Received Down Image Request")
if not self.recording:
self.recording = True
self.camera.start_recording()
return self.processor_pool.submit(self.get_image_down)
img = self.camera.get_latest_image()
timestamp = time.time()
self.log(f"Got image from Camera at time {timestamp}")
return self.processor_pool.submit(self.get_image_down, img, timestamp)

def _log_image_down(
self,
Expand Down Expand Up @@ -208,31 +213,29 @@ def _log_image_down(
json.dump(log_data, open(f"{logs_folder}/data.json", 'w+'), indent=4)

@log_exceptions
def get_image_down(self) -> list[Target3D]:
def get_image_down(self, img, timestamp) -> list[Target3D]:
"""
Blocking implementation of the infrence pipeline.
Autofocus, then wait till cam points down, take pic,
We want to take photo when the attitude is down only.
"""
self.log("Received Down Image Request")

if img is None:
self.log("Could not get image from Camera.")
return []
self.camera.request_autofocus()
self.log(f"Got past autofocus")
self.pose_provider.wait_for_data()
self.log(f"Got past pose provider wait")

if abs(self.camera.getAttitude()[1] - -90) > 5: # Allow 5 degrees of error (Arbitrary)
self.point_camera_down()
self.log(f"Got past point down")

#TODO: Figure out a way to detect when the gimbal is having an aneurism and figure out how to fix it or send msg to groundstation.

# Take picture and grab relevant data
img = self.camera.get_latest_image()
if img is None:
self.log("Could not get image from Camera.")
return []
timestamp = time.time()
self.log(f"Got image from Camera at time {timestamp}")

localizer = self.make_localizer()
if localizer is None:
self.log("Could not get Localizer")
Expand Down

0 comments on commit 9b70a27

Please sign in to comment.