Skip to content

Commit

Permalink
Add get properties (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
njooma authored Oct 29, 2024
1 parent a57b31e commit 57cb7be
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/src/services/vision.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import '../resource/base.dart';
import '../robot/client.dart';
import '../utils.dart';

/// {@category Viam SDK}
/// The vision service's supported features and settings
typedef VisionProperties = GetPropertiesResponse;

/// {@category Services}
class VisionClient extends Resource implements ResourceRPCClient {
static const Subtype subtype = Subtype(resourceNamespaceRDK, resourceTypeService, 'vision');
Expand Down Expand Up @@ -100,6 +104,21 @@ class VisionClient extends Resource implements ResourceRPCClient {
return response.objects;
}

/// Get info about what vision methods the vision service provides.
/// Currently returns boolean values that state whether the service implements the
/// classification, detection, and/or 3D object segmentation methods.
///
/// ```
/// // Example:
/// var properties = await myVisionService.properties();
/// properties.detections_supported // returns true
/// properties.classifications_supported // returns false
/// ```
Future<VisionProperties> properties({Map<String, dynamic>? extra}) async {
final request = GetPropertiesRequest(name: name, extra: extra?.toStruct());
return await client.getProperties(request);
}

@override
Future<Map<String, dynamic>> doCommand(Map<String, dynamic> command) async {
final request = DoCommandRequest()
Expand Down
7 changes: 7 additions & 0 deletions test/unit_test/services/vision_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ void main() {
expect(response, equals(expected));
});

test('properties', () async {
final expected = GetPropertiesResponse(classificationsSupported: true);
when(serviceClient.getProperties(any)).thenAnswer((_) => MockResponseFuture.value(expected));
final response = await client.properties();
expect(response, equals(expected));
});

test('getObjectPointClouds', () async {
final expected = [
PointCloudObject(
Expand Down

0 comments on commit 57cb7be

Please sign in to comment.