-
Notifications
You must be signed in to change notification settings - Fork 126
RSDK-11613 — Update Go camera API with new GetImages signature #5183
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
Conversation
|
Warning your change may break code samples. If your change modifies any of the following functions please contact @viamrobotics/fleet-management. Thanks!
|
4987baa to
fa020c0
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.
Reviewed these changes synchronously, LGTM
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.
Nice work!
some non-blocking requests, mostly about adding more tests
components/camera/camera.go
Outdated
|
|
||
| data, err := rimage.EncodeImage(ctx, ni.img, ni.mimeType) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("could not encode image: %w", err) |
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.
could you make this more descriptive by including what encoding was attempted? e.g.
"could not encode image with encoding %s : %w", ni.mimeType, err)
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.
great call I'll add
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.
added
| images, _, err := camClient.Images(ctx, []string{"color", "depth"}, nil) | ||
| test.That(t, err, test.ShouldBeNil) | ||
| test.That(t, len(images), test.ShouldEqual, 2) | ||
| test.That(t, images[0].SourceName, test.ShouldEqual, "color") | ||
| test.That(t, images[1].SourceName, test.ShouldEqual, "depth") | ||
|
|
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.
Question: if the filter was in the opposite order []string{"depth", "color"}, would it be expected that images[0] is the depth image, and images[1] is the color image? Is the order of request required in the order of response? Can you make a test?
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.
How to handle order would be entirely on the module implementer, client and server should have no opinions.
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.
I'll add a test to make that clear
| test.That(t, rimage.ImagesExactlyEqual(depthImg, expectedDepth), test.ShouldBeTrue) | ||
| }) | ||
|
|
||
| t.Run("empty and nil filters", func(t *testing.T) { |
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.
can you add a few more more tests, which test a filter that doesn't exist, and duplicates?
case 1: []string{"no_such_source"}
case 2: []string{"color", "no_such_source"}
case 3: []string{"color", "color"}
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.
I have case 1 and 2 in camera_test.go
case 3 is not handled by the client, it is handled by the server
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.
I'll add a test for case 3 to make it more explicit though
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.
Added all three to be extra safe
| func encodeImageFromUnderlyingType(ctx context.Context, img image.Image) (pb.Format, []byte, error) { | ||
| switch v := img.(type) { | ||
| case *rimage.LazyEncodedImage: | ||
| format := pb.Format_FORMAT_UNSPECIFIED | ||
| switch v.MIMEType() { | ||
| case utils.MimeTypeRawDepth: | ||
| format = pb.Format_FORMAT_RAW_DEPTH | ||
| case utils.MimeTypeRawRGBA: | ||
| format = pb.Format_FORMAT_RAW_RGBA | ||
| case utils.MimeTypeJPEG: | ||
| format = pb.Format_FORMAT_JPEG | ||
| case utils.MimeTypePNG: | ||
| format = pb.Format_FORMAT_PNG | ||
| default: | ||
| } | ||
| return format, v.RawData(), nil |
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.
Feels really nice getting to delete this
2d5876b to
edf294c
Compare
073cfe3 to
0c8254d
Compare
RSDK-11613
Todo:
Manual Tests
Data Manager GetImages
Re-ran this test #5209 (comment) exactly as outlined and made sure it still works off of this feature branch.
DataManager ReadImage
Changed config to use
"method": "ReadImage"instead of"method": "GetImages", filtered_camera still works as expected.Stream server
Live streams working as expected.
GetImages filter_source_names
Using a go client script to call
Imageson animage_filecamera with below configRequesting invalid source
Requesting with no sources specified
Logged:
Requesting source "preloaded" specified
Number of sources checks out.
Requesting duplicate sources "color" and "color"
Nice.