-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
base: main
Are you sure you want to change the base?
Conversation
* 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]>
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 |
0ac3693
to
b612919
Compare
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.
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.
donkeycar/parts/oak_d_camera.py
Outdated
from collections import deque | ||
import numpy as np | ||
try: | ||
import depthai as dai |
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 should go into the RPi or Nano (wherever this is expected to work) section of setup.cfg.
donkeycar/parts/oak_d_camera.py
Outdated
|
||
|
||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.INFO) |
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.
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.
donkeycar/parts/oak_d_camera.py
Outdated
|
||
# Create pipeline | ||
self.pipeline = dai.Pipeline() | ||
# self.pipeline.setCameraTuningBlobPath('/tuning_color_ov9782_wide_fov.bin') |
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.
Pls remove commented code.
donkeycar/parts/oak_d_camera.py
Outdated
|
||
if rgb_apply_cropping: | ||
camera.setSensorCrop(rgb_sensor_crop_x, rgb_sensor_crop_y) # When croping to keep only smaller video | ||
|
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.
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 | ||
|
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.
additional blank line (pep-8 only wants one within a function).
donkeycar/parts/oak_d_camera.py
Outdated
self.roi_distances.append(int(coords.y)) | ||
self.roi_distances.append(int(coords.z)) | ||
|
||
# return self.frame |
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.
Commented code.
xinSpatialCalcConfig.out.link(spatialLocationCalculator.inputConfig) | ||
|
||
|
||
def run(self): |
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 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() |
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 you would generally do it.
donkeycar/parts/oak_d_camera.py
Outdated
self.device = None | ||
self.queue = None | ||
self.pipeline = None | ||
|
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.
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') |
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.
Thanks for fixing this, this is indeed a bug!
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 |
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)