Skip to content

Commit

Permalink
Fix weird merge resolution and bolster integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hexbabe committed Aug 1, 2024
1 parent 4aa8c94 commit 82941aa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
29 changes: 27 additions & 2 deletions integration-tests/tests/oak_d_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ 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)
Expand All @@ -64,13 +64,38 @@ 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)
test.That(t, err, test.ShouldBeNil)
})

t.Run("Get image method", func(t *testing.T) {
stream, err := cam.Stream(timeoutCtx)
test.That(t, err, test.ShouldBeNil)
img, _, err := stream.Next(timeoutCtx)
test.That(t, err, test.ShouldBeNil)
bounds := img.Bounds()
test.That(t, bounds.Dx(), test.ShouldEqual, defaultWidth)
test.That(t, bounds.Dy(), test.ShouldEqual, defaultHeight)
})

t.Run("Get images method (one image)", 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, len(images), test.ShouldEqual, 1)
test.That(t, metadata, test.ShouldNotBeNil)

img := images[0]
test.That(t, img.SourceName, test.ShouldEqual, componentName)
bounds := img.Image.Bounds()
test.That(t, bounds.Dx(), test.ShouldEqual, defaultWidth)
test.That(t, bounds.Dy(), test.ShouldEqual, defaultHeight)
test.That(t, metadata.CapturedAt, test.ShouldHappenBefore, time.Now())
})

t.Run("Shut down the camera", func(t *testing.T) {
test.That(t, cam.Close(timeoutCtx), test.ShouldBeNil)
})
Expand Down
6 changes: 3 additions & 3 deletions src/components/oak.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,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
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

0 comments on commit 82941aa

Please sign in to comment.