Skip to content

Conversation

@hexbabe
Copy link
Member

@hexbabe hexbabe commented Jul 29, 2025

RSDK-11613

Todo:

  • Write better unit tests instead of just getting stuff to compile
  • Remove POC stream server changes (deferred to another ticket)
  • Manual testing

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 Images on an image_file camera with below config

    {
      "name": "image-file-1",
      "api": "rdk:component:camera",
      "model": "rdk:builtin:image_file",
      "attributes": {
        "preloaded_image": "pizza",
        "color_image_file_path": "/Users/seanyu/Downloads/image.png"
      }
    }

Requesting invalid source

2025-08-19T18:53:05.415Z        ERROR   client  go-sdk-client/client.go:50      camera client: could not gets images from the camera rpc error: code = Unknown desc = camera server GetImages could not call Images on the camera: invalid source name: RAWWWWWWRRRRRR

Requesting with no sources specified

	for _, image := range namedImages {
		logger.Info(image.MimeType())
	}
	logger.Info(respMetadata)

Logged:

2025-08-19T18:54:38.159Z        INFO    client  go-sdk-client/client.go:53      image/jpeg
2025-08-19T18:54:38.159Z        INFO    client  go-sdk-client/client.go:53      image/jpeg
2025-08-19T18:54:38.159Z        INFO    client  go-sdk-client/client.go:55      {2025-08-19 18:54:38.149384 +0000 UTC}

Requesting source "preloaded" specified

2025-08-19T18:56:30.575Z        INFO    client  go-sdk-client/client.go:53      image/jpeg
2025-08-19T18:56:30.575Z        INFO    client  go-sdk-client/client.go:55      {2025-08-19 18:56:30.572539 +0000 UTC}

Number of sources checks out.

Requesting duplicate sources "color" and "color"

2025-08-19T18:57:30.835Z        ERROR   client  go-sdk-client/client.go:50      duplicate source name in filter: color
exit status 1

Nice.

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jul 29, 2025
@github-actions
Copy link
Contributor

Warning your change may break code samples. If your change modifies any of the following functions please contact @viamrobotics/fleet-management. Thanks!

component function
base IsMoving
button Push
genericcomponent DoCommand
board GPIOPinByName
camera Properties
encoder Properties
motor IsMoving
sensor Readings
servo Position
arm EndPosition
audio MediaProperties
gantry Lengths
gripper IsMoving
input_controller Controls
movement_sensor LinearAcceleration
power_sensor Power
pose_tracker Poses
genericservice DoCommand
motion GetPose
vision GetProperties

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jul 29, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jul 29, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jul 29, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jul 31, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Aug 12, 2025
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Aug 25, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Aug 25, 2025
@hexbabe hexbabe requested review from SebastianMunozP and removed request for SebastianMunozP August 25, 2025 19:50
Copy link
Contributor

@SebastianMunozP SebastianMunozP left a 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

Copy link
Member

@bhaney bhaney left a 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


data, err := rimage.EncodeImage(ctx, ni.img, ni.mimeType)
if err != nil {
return nil, fmt.Errorf("could not encode image: %w", err)
Copy link
Member

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)

Copy link
Member Author

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Comment on lines +442 to +447
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")

Copy link
Member

@bhaney bhaney Aug 26, 2025

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?

Copy link
Member Author

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.

Copy link
Member Author

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) {
Copy link
Member

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"}

Copy link
Member Author

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

Copy link
Member Author

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

Copy link
Member Author

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

Comment on lines -137 to -152
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
Copy link
Member

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

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Aug 26, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Aug 26, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Aug 26, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Aug 26, 2025
@hexbabe hexbabe merged commit 1ab734a into viamrobotics:main Aug 26, 2025
18 checks passed
@hexbabe hexbabe deleted the get-images-poc branch August 26, 2025 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test This pull request is marked safe to test from a trusted zone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants