Skip to content

Commit

Permalink
update with latest api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
martha-johnston committed Jan 10, 2025
1 parent d3fedee commit 57d6f95
Show file tree
Hide file tree
Showing 5 changed files with 4,001 additions and 4,548 deletions.
3 changes: 2 additions & 1 deletion lib/src/resource/registry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import '../components/sensor/sensor.dart';
import '../components/servo/client.dart';
import '../components/servo/servo.dart';
import '../resource/base.dart';
import '../services/discovery.dart';
import '../services/vision.dart';

/// {@category Viam SDK}
Expand Down Expand Up @@ -69,7 +70,7 @@ class Registry {
registerSubtype(ResourceRegistration(Sensor.subtype, (name, channel) => SensorClient(name, channel)));
registerSubtype(ResourceRegistration(Servo.subtype, (name, channel) => ServoClient(name, channel)));
registerSubtype(ResourceRegistration(VisionClient.subtype, (name, channel) => VisionClient(name, channel)));
registerSubtype(ResourceRegistration(DiscoveryClient.subtype, (name, channel) => DiscoverClient(name, channel)));
registerSubtype(ResourceRegistration(DiscoveryClient.subtype, (name, channel) => DiscoveryClient(name, channel)));
}

/// The [Subtype] available in the SDK
Expand Down
4 changes: 3 additions & 1 deletion lib/src/robot/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:grpc/grpc_connection_interface.dart';
import 'package:logger/logger.dart';

import '../gen/common/v1/common.pb.dart';
import '../gen/robot/v1/robot.pb.dart';
import '../gen/google/protobuf/struct.pb.dart';
import '../gen/robot/v1/robot.pbgrpc.dart' as rpb;
import '../gen/stream/v1/stream.pbgrpc.dart';
Expand Down Expand Up @@ -356,7 +357,8 @@ class RobotClient {
/// var modelsFromModules = await machine.getModelsFromModules();
/// ```
Future<List<ModuleModel>> getModelsFromModules() async {
final request = rpb.GetModelsFromModulesRequest();
final response = await _client.getModelsFromModules(request);
return response.model.map((d) => ModuleModel.fromProto(d)).toList();
return response.models;
}
}
4 changes: 3 additions & 1 deletion lib/src/services/discovery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:grpc/grpc_connection_interface.dart';

import '../../protos/common/common.dart';
import '../../protos/service/discovery.dart';
import '../gen/service/discovery/v1/discovery.pbgrpc.dart';
import '../gen/app/v1/robot.pb.dart';
import '../media/image.dart';
import '../resource/base.dart';
import '../robot/client.dart';
Expand All @@ -29,7 +31,7 @@ class DiscoveryClient extends Resource implements ResourceRPCClient {
/// // Example:
/// var resources = await myDiscoveryService.discoverResources('myWebcam');
/// ```
Future<List<ComponentConfig>> discoverResources(String discoveryName, {Map<String, dynamic>? extra}) async {
Future<Iterable<ComponentConfig>> discoverResources(String discoveryName, {Map<String, dynamic>? extra}) async {
final request = DiscoverResourcesRequest(name: name, extra: extra?.toStruct());
final response = await client.discoverResources(request);
return response.discoveries;
Expand Down
Loading

0 comments on commit 57d6f95

Please sign in to comment.