diff --git a/core/sdk/src/main/java/com/viam/sdk/core/component/camera/Camera.java b/core/sdk/src/main/java/com/viam/sdk/core/component/camera/Camera.java index 69cf9d863..1d13e9170 100644 --- a/core/sdk/src/main/java/com/viam/sdk/core/component/camera/Camera.java +++ b/core/sdk/src/main/java/com/viam/sdk/core/component/camera/Camera.java @@ -2,12 +2,16 @@ import com.google.protobuf.Struct; import com.viam.common.v1.Common; +import com.viam.common.v1.Common.ResponseMetadata; import com.viam.component.camera.v1.Camera.Format; +import com.viam.component.camera.v1.Camera.GetPropertiesResponse; import com.viam.component.camera.v1.Camera.Image; import com.viam.sdk.core.component.Component; import com.viam.sdk.core.resource.Resource; import com.viam.sdk.core.resource.Subtype; import com.viam.sdk.core.robot.RobotClient; +import java.util.AbstractMap.SimpleEntry; +import java.util.Collections; import java.util.List; import java.util.Map.Entry; import java.util.Optional; @@ -50,7 +54,15 @@ public static Camera fromRobot(final RobotClient robot, final String name) { public abstract Image getImage(final Format format, final Optional extra); - public abstract Entry, Common.ResponseMetadata> getImages(); + public Entry, Common.ResponseMetadata> getImages() { + return new SimpleEntry<>( + Collections.singletonList(getImage(Format.FORMAT_UNSPECIFIED, Optional.empty())), + ResponseMetadata.newBuilder().build()); + } + + protected GetPropertiesResponse getProperties() { + return GetPropertiesResponse.newBuilder().build(); + } static Format mimeToFormat(final String mimeType) { switch (mimeType) { diff --git a/core/sdk/src/main/java/com/viam/sdk/core/component/camera/CameraRPCClient.java b/core/sdk/src/main/java/com/viam/sdk/core/component/camera/CameraRPCClient.java index ff3f523a2..c91ab505f 100644 --- a/core/sdk/src/main/java/com/viam/sdk/core/component/camera/CameraRPCClient.java +++ b/core/sdk/src/main/java/com/viam/sdk/core/component/camera/CameraRPCClient.java @@ -10,6 +10,8 @@ import com.viam.component.camera.v1.Camera.GetImageResponse; import com.viam.component.camera.v1.Camera.GetImagesRequest; import com.viam.component.camera.v1.Camera.GetImagesResponse; +import com.viam.component.camera.v1.Camera.GetPropertiesRequest; +import com.viam.component.camera.v1.Camera.GetPropertiesResponse; import com.viam.component.camera.v1.Camera.Image; import com.viam.component.camera.v1.CameraServiceGrpc; import com.viam.sdk.core.rpc.Channel; @@ -53,6 +55,13 @@ public List getGeometries(final Optional extra) { return client.getGeometries(builder.build()).getGeometriesList(); } + @Override + protected GetPropertiesResponse getProperties() { + final GetPropertiesRequest.Builder builder = GetPropertiesRequest.newBuilder(). + setName(getName().getName()); + return client.getProperties(builder.build()); + } + @Override public Image getImage(final Format format, Optional extra) { diff --git a/core/sdk/src/main/java/com/viam/sdk/core/component/camera/CameraRPCService.java b/core/sdk/src/main/java/com/viam/sdk/core/component/camera/CameraRPCService.java index d1d5b2488..e80dfa08c 100644 --- a/core/sdk/src/main/java/com/viam/sdk/core/component/camera/CameraRPCService.java +++ b/core/sdk/src/main/java/com/viam/sdk/core/component/camera/CameraRPCService.java @@ -9,6 +9,8 @@ import com.viam.component.camera.v1.Camera.GetImageResponse; import com.viam.component.camera.v1.Camera.GetImagesRequest; import com.viam.component.camera.v1.Camera.GetImagesResponse; +import com.viam.component.camera.v1.Camera.GetPropertiesRequest; +import com.viam.component.camera.v1.Camera.GetPropertiesResponse; import com.viam.component.camera.v1.Camera.Image; import com.viam.component.camera.v1.CameraServiceGrpc; import com.viam.sdk.core.resource.ResourceManager; @@ -51,6 +53,16 @@ public void getGeometries(Common.GetGeometriesRequest request, responseObserver.onCompleted(); } + @Override + public void getProperties(GetPropertiesRequest request, + StreamObserver responseObserver) { + final Camera camera = getResource( + Camera.named(request.getName())); + final GetPropertiesResponse result = camera.getProperties(); + responseObserver.onNext(result); + responseObserver.onCompleted(); + } + @Override public void getImage(GetImageRequest request, StreamObserver responseObserver) {