Skip to content

Commit 3c44f07

Browse files
viambotgithub-actions[bot]
authored andcommitted
[WORKFLOW] AI update based on proto changes from commit c9b203b
1 parent 978ef57 commit 3c44f07

File tree

4 files changed

+63
-3
lines changed

4 files changed

+63
-3
lines changed

lib/src/components/gantry/client.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,13 @@ class GantryClient extends Gantry with RPCDebugLoggerMixin implements ResourceRP
8181
final response = await client.doCommand(request, options: callOptions);
8282
return response.result.toMap();
8383
}
84-
}
84+
85+
@override
86+
Future<KinematicsFile> kinematics({Map<String, dynamic>? extra}) async {
87+
final request = GetKinematicsRequest()
88+
..name = name
89+
..extra = extra?.toStruct() ?? Struct();
90+
final response = await client.getKinematics(request, options: callOptions);
91+
return response.kinematicsFile;
92+
}
93+
}

lib/src/components/gantry/gantry.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import '../../gen/common/v1/common.pb.dart';
22
import '../../resource/base.dart';
33
import '../../robot/client.dart';
4+
import '../../gen/component/gantry/v1/gantry.pb.dart';
45

56
/// {@category Components}
67
/// Gantry represents a physical Gantry and can be used for controlling gantries of N axes.
@@ -63,6 +64,15 @@ abstract class Gantry extends Resource {
6364
/// For more information, see [Gantry component](https://docs.viam.com/dev/reference/apis/components/gantry/#ismoving).
6465
Future<bool> isMoving();
6566

67+
/// Get the [KinematicsFile] of the gantry.
68+
///
69+
/// ```
70+
/// var kinematics = await myGantry.kinematics();
71+
/// ```
72+
///
73+
/// For more information, see [Gantry component](https://docs.viam.com/dev/reference/apis/components/gantry/#getkinematics).
74+
Future<KinematicsFile> kinematics({Map<String, dynamic>? extra});
75+
6676
/// Get the [ResourceName] for this [Gantry] with the given [name]
6777
///
6878
/// ```
@@ -84,4 +94,4 @@ abstract class Gantry extends Resource {
8494
static Gantry fromRobot(RobotClient robot, String name) {
8595
return robot.getResource(Gantry.getResourceName(name));
8696
}
87-
}
97+
}

lib/src/components/gantry/service.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,11 @@ class GantryService extends GantryServiceBase {
7575
// TODO: implement getGeometries
7676
throw UnimplementedError();
7777
}
78-
}
78+
79+
@override
80+
Future<GetKinematicsResponse> getKinematics(ServiceCall call, GetKinematicsRequest request) async {
81+
final gantry = _fromManager(request.name);
82+
final response = await gantry.kinematics(extra: request.extra.toMap());
83+
return GetKinematicsResponse()..kinematicsFile = response;
84+
}
85+
}

test/unit_test/components/gantry_test.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ class FakeGantry extends Gantry {
5757
Future<List<double>> position({Map<String, dynamic>? extra}) async {
5858
return positions;
5959
}
60+
61+
@override
62+
Future<KinematicsFile> kinematics({Map<String, dynamic>? extra}) async {
63+
this.extra = extra;
64+
return KinematicsFile()..kinematicsData = 'fake kinematics data';
65+
}
6066
}
6167

6268
void main() {
@@ -233,6 +239,21 @@ void main() {
233239
..extra = {'foo': 'bar'}.toStruct());
234240
expect(gantry.extra, {'foo': 'bar'});
235241
});
242+
243+
test('kinematics', () async {
244+
final client = GantryServiceClient(channel);
245+
final response = await client.getKinematics(GetKinematicsRequest()..name = name);
246+
expect(response.kinematicsFile.kinematicsData, 'fake kinematics data');
247+
});
248+
249+
test('kinematics with extra', () async {
250+
expect(gantry.extra, null);
251+
final client = GantryServiceClient(channel);
252+
await client.getKinematics(GetKinematicsRequest()
253+
..name = name
254+
..extra = {'foo': 'bar'}.toStruct());
255+
expect(gantry.extra, {'foo': 'bar'});
256+
});
236257
});
237258
group('Gantry Client Tests', () {
238259
test('position', () async {
@@ -292,6 +313,19 @@ void main() {
292313
await client.stop(extra: {'foo': 'bar'});
293314
expect(gantry.extra, {'foo': 'bar'});
294315
});
316+
317+
test('kinematics', () async {
318+
final client = GantryClient(name, channel);
319+
final response = await client.kinematics();
320+
expect(response.kinematicsData, 'fake kinematics data');
321+
});
322+
323+
test('kinematics with extra', () async {
324+
expect(gantry.extra, null);
325+
final client = GantryClient(name, channel);
326+
await client.kinematics(extra: {'foo': 'bar'});
327+
expect(gantry.extra, {'foo': 'bar'});
328+
});
295329
});
296330
});
297331
}

0 commit comments

Comments
 (0)