Skip to content

[RSDK-9110] Add trace debug logging #380

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

Merged
merged 2 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/src/components/arm/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'arm.dart';
/// gRPC client for an [Arm] component.
///
/// Used to communicate with an existing [Arm] implementation over gRPC.
class ArmClient extends Arm implements ResourceRPCClient {
class ArmClient extends Arm with RPCDebugLoggerMixin implements ResourceRPCClient {
@override
final String name;

Expand All @@ -28,14 +28,14 @@ class ArmClient extends Arm implements ResourceRPCClient {
final request = GetEndPositionRequest()
..name = name
..extra = extra?.toStruct() ?? Struct();
final response = await client.getEndPosition(request);
final response = await client.getEndPosition(request, options: callOptions);
return response.pose;
}

@override
Future<bool> isMoving() async {
final request = IsMovingRequest()..name = name;
final response = await client.isMoving(request);
final response = await client.isMoving(request, options: callOptions);
return response.isMoving;
}

Expand All @@ -45,7 +45,7 @@ class ArmClient extends Arm implements ResourceRPCClient {
..name = name
..positions = (JointPositions()..values.addAll(positions))
..extra = extra?.toStruct() ?? Struct();
await client.moveToJointPositions(request);
await client.moveToJointPositions(request, options: callOptions);
}

@override
Expand All @@ -54,15 +54,15 @@ class ArmClient extends Arm implements ResourceRPCClient {
..name = name
..to = pose
..extra = extra?.toStruct() ?? Struct();
await client.moveToPosition(request);
await client.moveToPosition(request, options: callOptions);
}

@override
Future<List<double>> jointPositions({Map<String, dynamic>? extra}) async {
final request = GetJointPositionsRequest()
..name = name
..extra = extra?.toStruct() ?? Struct();
final response = await client.getJointPositions(request);
final response = await client.getJointPositions(request, options: callOptions);
return response.positions.values;
}

Expand All @@ -71,15 +71,15 @@ class ArmClient extends Arm implements ResourceRPCClient {
final request = StopRequest()
..name = name
..extra = extra?.toStruct() ?? Struct();
await client.stop(request);
await client.stop(request, options: callOptions);
}

@override
Future<Map<String, dynamic>> doCommand(Map<String, dynamic> command) async {
final request = DoCommandRequest()
..name = name
..command = command.toStruct();
final response = await client.doCommand(request);
final response = await client.doCommand(request, options: callOptions);
return response.result.toMap();
}
}
18 changes: 9 additions & 9 deletions lib/src/components/base/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'base.dart';

/// {@category Components}
/// gRPC client for the [Base] component.
class BaseClient extends Base implements ResourceRPCClient {
class BaseClient extends Base with RPCDebugLoggerMixin implements ResourceRPCClient {
@override
final String name;

Expand All @@ -25,7 +25,7 @@ class BaseClient extends Base implements ResourceRPCClient {
@override
Future<bool> isMoving() async {
final request = IsMovingRequest()..name = name;
final response = await client.isMoving(request);
final response = await client.isMoving(request, options: callOptions);
return response.isMoving;
}

Expand All @@ -36,7 +36,7 @@ class BaseClient extends Base implements ResourceRPCClient {
..distanceMm = Int64(distance)
..mmPerSec = velocity
..extra = extra?.toStruct() ?? Struct();
await client.moveStraight(request);
await client.moveStraight(request, options: callOptions);
}

@override
Expand All @@ -46,7 +46,7 @@ class BaseClient extends Base implements ResourceRPCClient {
..linear = linear
..angular = angular
..extra = extra?.toStruct() ?? Struct();
await client.setPower(request);
await client.setPower(request, options: callOptions);
}

@override
Expand All @@ -56,7 +56,7 @@ class BaseClient extends Base implements ResourceRPCClient {
..linear = linear
..angular = angular
..extra = extra?.toStruct() ?? Struct();
await client.setVelocity(request);
await client.setVelocity(request, options: callOptions);
}

@override
Expand All @@ -66,31 +66,31 @@ class BaseClient extends Base implements ResourceRPCClient {
..angleDeg = angle
..degsPerSec = velocity
..extra = extra?.toStruct() ?? Struct();
await client.spin(request);
await client.spin(request, options: callOptions);
}

@override
Future<void> stop({Map<String, dynamic>? extra}) async {
final request = StopRequest()
..name = name
..extra = extra?.toStruct() ?? Struct();
await client.stop(request);
await client.stop(request, options: callOptions);
}

@override
Future<BaseProperties> properties({Map<String, dynamic>? extra}) async {
final request = GetPropertiesRequest()
..name = name
..extra = extra?.toStruct() ?? Struct();
return await client.getProperties(request);
return await client.getProperties(request, options: callOptions);
}

@override
Future<Map<String, dynamic>> doCommand(Map<String, dynamic> command) async {
final request = DoCommandRequest()
..name = name
..command = command.toStruct();
final response = await client.doCommand(request);
final response = await client.doCommand(request, options: callOptions);
return response.result.toMap();
}
}
34 changes: 18 additions & 16 deletions lib/src/components/board/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'board.dart';

/// {@category Components}
/// gRPC client for the [Board] component.
class BoardClient extends Board implements ResourceRPCClient {
class BoardClient extends Board with RPCDebugLoggerMixin implements ResourceRPCClient {
@override
final String name;

Expand All @@ -31,7 +31,7 @@ class BoardClient extends Board implements ResourceRPCClient {
final request = common.DoCommandRequest()
..name = name
..command = command.toStruct();
final response = await client.doCommand(request);
final response = await client.doCommand(request, options: callOptions);
return response.result.toMap();
}

Expand All @@ -42,7 +42,7 @@ class BoardClient extends Board implements ResourceRPCClient {
..pin = pin
..high = high
..extra = extra?.toStruct() ?? Struct();
await client.setGPIO(request);
await client.setGPIO(request, options: callOptions);
}

@override
Expand All @@ -51,7 +51,7 @@ class BoardClient extends Board implements ResourceRPCClient {
..name = name
..pin = pin
..extra = extra?.toStruct() ?? Struct();
final response = await client.getGPIO(request);
final response = await client.getGPIO(request, options: callOptions);
return response.high;
}

Expand All @@ -61,7 +61,7 @@ class BoardClient extends Board implements ResourceRPCClient {
..name = name
..pin = pin
..extra = extra?.toStruct() ?? Struct();
final response = await client.pWM(request);
final response = await client.pWM(request, options: callOptions);
return response.dutyCyclePct;
}

Expand All @@ -72,7 +72,7 @@ class BoardClient extends Board implements ResourceRPCClient {
..pin = pin
..dutyCyclePct = dutyCyclePct
..extra = extra?.toStruct() ?? Struct();
await client.setPWM(request);
await client.setPWM(request, options: callOptions);
}

@override
Expand All @@ -81,7 +81,7 @@ class BoardClient extends Board implements ResourceRPCClient {
..name = name
..pin = pin
..extra = extra?.toStruct() ?? Struct();
final response = await client.pWMFrequency(request);
final response = await client.pWMFrequency(request, options: callOptions);
return response.frequencyHz.toInt();
}

Expand All @@ -92,7 +92,7 @@ class BoardClient extends Board implements ResourceRPCClient {
..pin = pin
..frequencyHz = Int64(frequencyHz)
..extra = extra?.toStruct() ?? Struct();
await client.setPWMFrequency(request);
await client.setPWMFrequency(request, options: callOptions);
}

@override
Expand All @@ -101,7 +101,7 @@ class BoardClient extends Board implements ResourceRPCClient {
..boardName = name
..analogReaderName = analogReaderName
..extra = extra?.toStruct() ?? Struct();
final response = await client.readAnalogReader(request);
final response = await client.readAnalogReader(request, options: callOptions);
return response;
}

Expand All @@ -111,7 +111,7 @@ class BoardClient extends Board implements ResourceRPCClient {
..boardName = name
..digitalInterruptName = digitalInterruptName
..extra = extra?.toStruct() ?? Struct();
final response = await client.getDigitalInterruptValue(request);
final response = await client.getDigitalInterruptValue(request, options: callOptions);
return response.value.toInt();
}

Expand All @@ -123,10 +123,12 @@ class BoardClient extends Board implements ResourceRPCClient {

@override
Stream<Tick> streamTicks(List<String> interrupts, {Map<String, dynamic>? extra}) {
final response = client.streamTicks(StreamTicksRequest()
..name = name
..pinNames.addAll(interrupts)
..extra = extra?.toStruct() ?? Struct());
final response = client.streamTicks(
StreamTicksRequest()
..name = name
..pinNames.addAll(interrupts)
..extra = extra?.toStruct() ?? Struct(),
options: callOptions);

final stream = response.map((resp) => Tick(pinName: resp.pinName, high: resp.high, time: resp.time));
return stream.asBroadcastStream(onCancel: (_) => response.cancel());
Expand All @@ -142,7 +144,7 @@ class BoardClient extends Board implements ResourceRPCClient {
..powerMode = powerMode
..duration = duration
..extra = extra?.toStruct() ?? Struct();
await client.setPowerMode(request);
await client.setPowerMode(request, options: callOptions);
}

@override
Expand All @@ -152,6 +154,6 @@ class BoardClient extends Board implements ResourceRPCClient {
..pin = pin
..value = value
..extra = extra?.toStruct() ?? Struct();
await client.writeAnalog(request);
await client.writeAnalog(request, options: callOptions);
}
}
6 changes: 3 additions & 3 deletions lib/src/components/button/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'button.dart';

/// {@category Components}
/// gRPC client for the [Button] component.
class ButtonClient extends Button implements ResourceRPCClient {
class ButtonClient extends Button with RPCDebugLoggerMixin implements ResourceRPCClient {
@override
final String name;

Expand All @@ -26,15 +26,15 @@ class ButtonClient extends Button implements ResourceRPCClient {
final request = PushRequest()
..name = name
..extra = extra?.toStruct() ?? Struct();
await client.push(request);
await client.push(request, options: callOptions);
}

@override
Future<Map<String, dynamic>> doCommand(Map<String, dynamic> command) async {
final request = DoCommandRequest()
..name = name
..command = command.toStruct();
final response = await client.doCommand(request);
final response = await client.doCommand(request, options: callOptions);
return response.result.toMap();
}
}
10 changes: 5 additions & 5 deletions lib/src/components/camera/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'camera.dart';

/// {@category Components}
/// gRPC client for the [Camera] component
class CameraClient extends Camera implements ResourceRPCClient {
class CameraClient extends Camera with RPCDebugLoggerMixin implements ResourceRPCClient {
@override
final String name;

Expand All @@ -28,7 +28,7 @@ class CameraClient extends Camera implements ResourceRPCClient {
..name = name
..mimeType = mimeType?.name ?? ''
..extra = extra?.toStruct() ?? Struct();
final response = await client.getImage(request);
final response = await client.getImage(request, options: callOptions);
final actualMimeType = MimeType.fromString(response.mimeType);
return ViamImage(response.image, actualMimeType);
}
Expand All @@ -39,23 +39,23 @@ class CameraClient extends Camera implements ResourceRPCClient {
..name = name
..mimeType = MimeType.pcd.name
..extra = extra?.toStruct() ?? Struct();
final response = await client.getPointCloud(request);
final response = await client.getPointCloud(request, options: callOptions);
final actualMimeType = MimeType.fromString(response.mimeType);
return ViamImage(response.pointCloud, actualMimeType);
}

@override
Future<CameraProperties> properties() async {
final request = GetPropertiesRequest()..name = name;
return await client.getProperties(request);
return await client.getProperties(request, options: callOptions);
}

@override
Future<Map<String, dynamic>> doCommand(Map<String, dynamic> command) async {
final request = DoCommandRequest()
..name = name
..command = command.toStruct();
final response = await client.doCommand(request);
final response = await client.doCommand(request, options: callOptions);
return response.result.toMap();
}
}
Loading