Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
be62332
Add new validating flow; Remove ffc model from meta.json and code; Re…
hexbabe Jul 18, 2024
c06fa64
Make lint
hexbabe Jul 18, 2024
02e73b3
Remove immediate model assignment
hexbabe Jul 18, 2024
8c8c43e
Remove undeclared var
hexbabe Jul 19, 2024
9b1dc00
Add impl
hexbabe Jul 23, 2024
0240db7
Merge branch 'main' into RSDK-8331
hexbabe Jul 23, 2024
45b4c08
Fix up merge more:
hexbabe Jul 23, 2024
b2e1db1
Make lint
hexbabe Jul 23, 2024
c7393a8
Address logging craziness
hexbabe Jul 24, 2024
3469ef9
Change default dimensions
hexbabe Jul 24, 2024
5d11327
Change config obj names to better camel case
hexbabe Jul 25, 2024
1c119c5
Fix this logging stuff ugh
hexbabe Jul 26, 2024
e96b933
Make lint
hexbabe Jul 26, 2024
9fedbd7
Change dir structure in preparation for service
hexbabe Jul 29, 2024
fb94ef1
Change logger names one more time for clarity
hexbabe Jul 29, 2024
8cc2041
Fix hanging event loop bug
hexbabe Jul 29, 2024
3602fc8
Migrate from OakCamera SDK to DepthAI v3
hexbabe Jul 31, 2024
64efd5f
Merge in changes from other branch
hexbabe Jul 31, 2024
4aa8c94
Resolve merge
hexbabe Jul 31, 2024
197fbc2
Fix weird merge resolution and bolster integration tests
hexbabe Aug 1, 2024
6f57630
Fix close/reconfigure; Add in fps setting for color
hexbabe Aug 1, 2024
2c91634
Change language of log and comments to reflect SDK change
hexbabe Aug 1, 2024
55273f2
Don't double set rgb/bgr support
hexbabe Aug 1, 2024
f17422b
Fix typo in func name
hexbabe Aug 1, 2024
5616edb
Why was canon.yaml gitignored? My bad
hexbabe Aug 1, 2024
ad30c6a
Unhardcode defaults and also clean up defaults const vars
hexbabe Aug 5, 2024
ccb5f89
Exit configure with more clear failure
hexbabe Aug 5, 2024
45fb0ac
Make lint
hexbabe Aug 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .canon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file provides project-level configuration for the canon dev environment utility. https://github.com/viamrobotics/canon
oak:
default: true
image_arm64: ghcr.io/viamrobotics/cloud-build-base:arm64
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# top level
.build-venv
.canon.yaml
.build-env
.DS_Store
.pytest_cache
.venv
build
module.tar.gz
oak-integration-tests

Expand Down
5 changes: 3 additions & 2 deletions integration-tests/tests/oak_d_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ func TestCameraServer(t *testing.T) {
test.That(t, err, test.ShouldBeNil)
})

t.Run("Get images method", func(t *testing.T) {
t.Run("Get images method (two images)", func(t *testing.T) {
images, metadata, err := cam.Images(timeoutCtx)
test.That(t, err, test.ShouldBeNil)
test.That(t, images, test.ShouldNotBeNil)
test.That(t, metadata, test.ShouldNotBeNil)
test.That(t, len(images), test.ShouldEqual, 2)
for _, img := range images {
test.That(t, img.SourceName, test.ShouldEqual, componentName)
bounds := img.Image.Bounds()
Expand All @@ -64,7 +65,7 @@ func TestCameraServer(t *testing.T) {
t.Run("Reconfigure module", func(t *testing.T) {
cfg := resource.Config{
Attributes: utils.AttributeMap{
"sensors": []string{"color"},
"sensors": []string{"depth"},
},
}
err := cam.Reconfigure(timeoutCtx, resource.Dependencies{}, cfg)
Expand Down
26 changes: 21 additions & 5 deletions src/components/helpers/shared.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
from typing import Dict, List, Literal, Optional, Tuple
from numpy.typing import NDArray

from depthai_sdk.components.camera_component import CameraComponent
from depthai import CameraBoardSocket


def get_socket_from_str(s: str) -> CameraBoardSocket:
if s == "cam_a":
return CameraBoardSocket.CAM_A
elif s == "cam_b":
return CameraBoardSocket.CAM_B
elif s == "cam_c":
return CameraBoardSocket.CAM_C
else:
raise Exception(f"Camera socket '{s}' is not recognized or supported.")


class Sensor:
component: Optional[CameraComponent] = None
def get_unique_name(self) -> str:
if self.sensor_type == "color":
return f"{self.socket_str}_rgb"
else:
return f"{self.socket_str}_mono"

def __init__(
self,
socket: Literal["cam_a", "cam_b", "cam_c"],
socket_str: Literal["cam_a", "cam_b", "cam_c"],
sensor_type: Literal["color", "depth"],
width: int,
height: int,
frame_rate: int,
color_order: Literal["rgb", "bgr"] = "rgb",
interleaved: bool = False,
):
self.socket = socket
self.socket_str = socket_str
self.socket = get_socket_from_str(socket_str)
self.sensor_type = sensor_type
self.width = width
self.height = height
Expand All @@ -35,7 +51,7 @@ class Sensors:
def __init__(self, sensors: List[Sensor]):
self._mapping = dict()
for sensor in sensors:
self._mapping[sensor.socket] = sensor
self._mapping[sensor.socket_str] = sensor

self.color_sensors = self._find_color_sensors()
self.stereo_pair = self._find_stereo_pair()
Expand Down
22 changes: 15 additions & 7 deletions src/components/oak.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ def reconfigure(
config (ComponentConfig)
dependencies (Mapping[ResourceName, ResourceBase])
"""
self._close()

if self.model == self._oak_d_model:
self.oak_cfg = OakDConfig(config)
elif self.model == self._oak_ffc_3p_model:
Expand Down Expand Up @@ -199,10 +201,16 @@ async def close(self) -> None:
Implements `close` to free resources on shutdown.
"""
LOGGER.info("Closing OAK component.")
self.worker_manager.stop()
self.worker_manager.join()
self._close()
LOGGER.debug("Closed OAK component.")

def _close(self) -> None:
if self.worker_manager:
self.worker_manager.stop()
self.worker_manager.join()
if self.worker:
self.worker.stop()

async def get_image(
self,
mime_type: str = "",
Expand Down Expand Up @@ -278,7 +286,7 @@ async def get_images(
"""
LOGGER.debug("get_images called")

self._wait_until_worker_running()
await self._wait_until_worker_running()

# Split logic into helpers for OAK-D and OAK-D like cameras with FFC-like cameras
# Use MessageSynchronizer only for OAK-D-like
Expand Down Expand Up @@ -352,15 +360,15 @@ async def get_point_cloud(
details = "Cannot process PCD. OAK camera not configured for stereo depth outputs. See README for details"
raise MethodNotAllowed(method_name="get_point_cloud", details=details)

self._wait_until_worker_running()
await self._wait_until_worker_running()

# By default, we do not get point clouds even when color and depth are both requested
# We have to reinitialize the worker/OakCamera to start making point clouds
# We have to reinitialize the worker/pipeline+device to start making point clouds
if not self.worker.user_wants_pc:
self.worker.user_wants_pc = True
self.worker.reset()
await self.worker.configure()
self.worker.start()
self.worker.configure()
await self.worker.start()

while not self.worker.running:
LOGGER.info("Waiting for worker to restart with pcd configured...")
Expand Down
Loading