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

Adding OAKD support to Donkeycar #1162

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Conversation

mdlopezme
Copy link

Still pending testing from different oak cameras. ( We have OakD Pro Wide, OakD Lite, OakD LR)

Is there an specific place were we should add documentation to use this parts?
From Triton AI (Specifically @raymondsong00 's effort)

raymondsong00 and others added 4 commits January 23, 2024 19:04
* Add oak_d camera

* Add to config

* Add rgb to config
* Add oak_d camera

* Add to config

* Add rgb to config

* Add test to manage.py

* Add small fix

* Update inputs for OAK-D

* fixes to previous issues

---------

Co-authored-by: Moises Lopez <[email protected]>
Co-authored-by: Moisés López <[email protected]>
@Ezward
Copy link
Contributor

Ezward commented Feb 21, 2024

The donkeydocs github has the docs. You can add documentation to the cameras page https://github.com/autorope/donkeydocs/blob/master/docs/parts/cameras.md

Copy link
Contributor

@DocGarbanzo DocGarbanzo left a comment

Choose a reason for hiding this comment

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

The code looks generally fine, please see my couple of comments for improvements and alignments. As with all parts code, some demo or confirmation that the part is working should be included in the PR.

from collections import deque
import numpy as np
try:
import depthai as dai
Copy link
Contributor

Choose a reason for hiding this comment

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

This should go into the RPi or Nano (wherever this is expected to work) section of setup.cfg.



logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove - logging should not be done on a file / module basis but is passed through in manage.py from the environment or command line instead.


# Create pipeline
self.pipeline = dai.Pipeline()
# self.pipeline.setCameraTuningBlobPath('/tuning_color_ov9782_wide_fov.bin')
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls remove commented code.


if rgb_apply_cropping:
camera.setSensorCrop(rgb_sensor_crop_x, rgb_sensor_crop_y) # When croping to keep only smaller video

Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary blank line

camera.setSensorCrop(rgb_sensor_crop_x, rgb_sensor_crop_y) # When croping to keep only smaller video

camera.setVideoSize(rgb_video_size) # Desired video size = ispscale result or smaller if croping

Copy link
Contributor

Choose a reason for hiding this comment

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

additional blank line (pep-8 only wants one within a function).

self.roi_distances.append(int(coords.y))
self.roi_distances.append(int(coords.z))

# return self.frame
Copy link
Contributor

Choose a reason for hiding this comment

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

Commented code.

xinSpatialCalcConfig.out.link(spatialLocationCalculator.inputConfig)


def run(self):
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 correct. The run method should return the same data as run_threaded if the part is called as a non-threaded part. However, if you designed the part to be threaded, then it is fine to not have the run method at all. The update method runs in a separate thread and in general updates member variables which are then used by the run_threaded method. So in case you want to implement the run method as well, it would sense to do it by filling these members accordingly and then returning them the same way as run_threaded, such that everything happens within the run function itself.

def update(self):
# Keep looping infinitely until the thread is stopped
while self.on:
self.run()
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 you would generally do it.

self.device = None
self.queue = None
self.pipeline = None

Copy link
Contributor

Choose a reason for hiding this comment

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

Indicates missing EOL.

@@ -70,7 +70,7 @@ def write_record(self, record=None):
elif input_type == 'gray16_array':
# save np.uint16 as a 16bit png
image = Image.fromarray(np.uint16(value))
name = Tub._image_file_name(self.manifest.current_index, key, ext='.png')
name = Tub._image_file_name(self.manifest.current_index, key, extension='.png')
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing this, this is indeed a bug!

@chenyenru
Copy link

chenyenru commented May 4, 2024

Dear @DocGarbanzo, sorry we've been working from our organization's fork and did not realize we've been receiving many help from you and the donkeycar community. Thank you for your code review, they are super comprehensive! I'll address them and provide updates here.

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.

5 participants