Skip to content

Commit

Permalink
Automated Protos Update (#217)
Browse files Browse the repository at this point in the history
* [WORKFLOW] Updating protos from viamrobotics/api, commit: b135219f13de8df7474c320bcacac38cc20390af

* add SetRPM to flutter SDK (#220)

---------

Co-authored-by: viambot <viambot@users.noreply.github.com>
Co-authored-by: martha-johnston <106617924+martha-johnston@users.noreply.github.com>
  • Loading branch information
3 people authored May 31, 2024
1 parent de27a90 commit cab7297
Show file tree
Hide file tree
Showing 17 changed files with 821 additions and 76 deletions.
9 changes: 9 additions & 0 deletions lib/src/components/motor/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ class MotorClient extends Motor implements ResourceRPCClient {
await client.goTo(request);
}

@override
Future<void> setRPM(double rpm, {Map<String, dynamic>? extra}) async {
final request = SetRPMRequest()
..name = name
..rpm = rpm
..extra = extra?.toStruct() ?? Struct();
await client.setRPM(request);
}

@override
Future<void> resetZeroPosition(double offset, {Map<String, dynamic>? extra}) async {
final request = ResetZeroPositionRequest()
Expand Down
4 changes: 4 additions & 0 deletions lib/src/components/motor/motor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ abstract class Motor extends Resource {
/// the [Motor] towards the specified position.
Future<void> goTo(double rpm, double positionRevolutions, {Map<String, dynamic>? extra});

/// Spin the [Motor] indefinitely at the specified speed, in revolutions per minute.
/// If [rpm] is positive, the motor will spin forwards, and if [rpm] is negative, the motor will spin backwards.
Future<void> setRPM(double rpm, {Map<String, dynamic>? extra});

/// Set the current position (modified by [offset]) to be the new zero (home) position.
Future<void> resetZeroPosition(double offset, {Map<String, dynamic>? extra});

Expand Down
7 changes: 7 additions & 0 deletions lib/src/components/motor/service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ class MotorService extends MotorServiceBase {
return GoToResponse();
}

@override
Future<SetRPMResponse> setRPM(ServiceCall call, SetRPMRequest request) async {
final motor = _fromManager(request.name);
await motor.setRPM(request.rpm, extra: request.extra.toMap());
return SetRPMResponse();
}

@override
Future<IsPoweredResponse> isPowered(ServiceCall call, IsPoweredRequest request) async {
final motor = _fromManager(request.name);
Expand Down
Loading

0 comments on commit cab7297

Please sign in to comment.