Skip to content

Commit 8b43ac8

Browse files
authored
[RSDK-8402] Migrate from OakCamera to DepthAI v3 (#51)
* Add new validating flow; Remove ffc model from meta.json and code; Reorganize files * Make lint * Remove immediate model assignment * Remove undeclared var * Add impl * Fix up merge more: * Make lint * Address logging craziness * Change default dimensions * Change config obj names to better camel case * Fix this logging stuff ugh * Make lint * Change dir structure in preparation for service * Change logger names one more time for clarity * Fix hanging event loop bug * Migrate from OakCamera SDK to DepthAI v3 * Fix weird merge resolution and bolster integration tests * Change language of log and comments to reflect SDK change * Don't double set rgb/bgr support * Fix typo in func name * Why was canon.yaml gitignored? My bad * Unhardcode defaults and also clean up defaults const vars * Exit configure with more clear failure * Make lint
1 parent f4ec2f5 commit 8b43ac8

File tree

7 files changed

+294
-267
lines changed

7 files changed

+294
-267
lines changed

.canon.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This file provides project-level configuration for the canon dev environment utility. https://github.com/viamrobotics/canon
2+
oak:
3+
default: true
4+
image_arm64: ghcr.io/viamrobotics/cloud-build-base:arm64

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# top level
2-
.build-venv
3-
.canon.yaml
2+
.build-env
43
.DS_Store
54
.pytest_cache
65
.venv
6+
build
77
module.tar.gz
88
oak-integration-tests
99

integration-tests/tests/oak_d_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ func TestCameraServer(t *testing.T) {
4040
test.That(t, err, test.ShouldBeNil)
4141
})
4242

43-
t.Run("Get images method", func(t *testing.T) {
43+
t.Run("Get images method (two images)", func(t *testing.T) {
4444
images, metadata, err := cam.Images(timeoutCtx)
4545
test.That(t, err, test.ShouldBeNil)
4646
test.That(t, images, test.ShouldNotBeNil)
4747
test.That(t, metadata, test.ShouldNotBeNil)
48+
test.That(t, len(images), test.ShouldEqual, 2)
4849
for _, img := range images {
4950
test.That(t, img.SourceName, test.ShouldEqual, componentName)
5051
bounds := img.Image.Bounds()
@@ -64,7 +65,7 @@ func TestCameraServer(t *testing.T) {
6465
t.Run("Reconfigure module", func(t *testing.T) {
6566
cfg := resource.Config{
6667
Attributes: utils.AttributeMap{
67-
"sensors": []string{"color"},
68+
"sensors": []string{"depth"},
6869
},
6970
}
7071
err := cam.Reconfigure(timeoutCtx, resource.Dependencies{}, cfg)

src/components/helpers/shared.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
11
from typing import Dict, List, Literal, Optional, Tuple
22
from numpy.typing import NDArray
33

4-
from depthai_sdk.components.camera_component import CameraComponent
4+
from depthai import CameraBoardSocket
5+
6+
7+
def get_socket_from_str(s: str) -> CameraBoardSocket:
8+
if s == "cam_a":
9+
return CameraBoardSocket.CAM_A
10+
elif s == "cam_b":
11+
return CameraBoardSocket.CAM_B
12+
elif s == "cam_c":
13+
return CameraBoardSocket.CAM_C
14+
else:
15+
raise Exception(f"Camera socket '{s}' is not recognized or supported.")
516

617

718
class Sensor:
8-
component: Optional[CameraComponent] = None
19+
def get_unique_name(self) -> str:
20+
if self.sensor_type == "color":
21+
return f"{self.socket_str}_rgb"
22+
else:
23+
return f"{self.socket_str}_mono"
924

1025
def __init__(
1126
self,
12-
socket: Literal["cam_a", "cam_b", "cam_c"],
27+
socket_str: Literal["cam_a", "cam_b", "cam_c"],
1328
sensor_type: Literal["color", "depth"],
1429
width: int,
1530
height: int,
1631
frame_rate: int,
1732
color_order: Literal["rgb", "bgr"] = "rgb",
1833
interleaved: bool = False,
1934
):
20-
self.socket = socket
35+
self.socket_str = socket_str
36+
self.socket = get_socket_from_str(socket_str)
2137
self.sensor_type = sensor_type
2238
self.width = width
2339
self.height = height
@@ -35,7 +51,7 @@ class Sensors:
3551
def __init__(self, sensors: List[Sensor]):
3652
self._mapping = dict()
3753
for sensor in sensors:
38-
self._mapping[sensor.socket] = sensor
54+
self._mapping[sensor.socket_str] = sensor
3955

4056
self.color_sensors = self._find_color_sensors()
4157
self.stereo_pair = self._find_stereo_pair()

src/components/oak.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,12 @@ async def get_point_cloud(
363363
await self._wait_until_worker_running()
364364

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

373373
while not self.worker.running:
374374
LOGGER.info("Waiting for worker to restart with pcd configured...")

0 commit comments

Comments
 (0)