Skip to content

Commit 6091789

Browse files
authored
Merge branch 'main' into addlinks
2 parents 76dda12 + 1fe01eb commit 6091789

31 files changed

+2160
-736
lines changed

.github/workflows/linkcheck.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Test HTML
2828
# https://github.com/wjdp/htmltest-action/
2929
# Don't fail the build on broken links
30-
continue-on-error: false
30+
continue-on-error: true
3131
uses: wjdp/htmltest-action@master
3232
with:
3333
config: .htmltest.yml

CHANGELOG.md

+31-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
11
# Changelog
22

3-
## [v0.0.15](https://github.com/viamrobotics/viam-flutter-sdk/tree/v0.0.15) (2024-05-28)
3+
## [v0.0.17](https://github.com/viamrobotics/viam-flutter-sdk/tree/v0.0.17) (2024-07-01)
44

5-
[Full Changelog](https://github.com/viamrobotics/viam-flutter-sdk/compare/v0.0.14...v0.0.15)
5+
[Full Changelog](https://github.com/viamrobotics/viam-flutter-sdk/compare/v0.0.16...v0.0.17)
66

77
**Merged pull requests:**
88

9+
- Automated Protos Update [\#242](https://github.com/viamrobotics/viam-flutter-sdk/pull/242) ([github-actions[bot]](https://github.com/apps/github-actions))
10+
- v0.0.16 [\#238](https://github.com/viamrobotics/viam-flutter-sdk/pull/238) ([github-actions[bot]](https://github.com/apps/github-actions))
11+
- Automated Protos Update [\#237](https://github.com/viamrobotics/viam-flutter-sdk/pull/237) ([github-actions[bot]](https://github.com/apps/github-actions))
12+
- Automated Protos Update [\#236](https://github.com/viamrobotics/viam-flutter-sdk/pull/236) ([github-actions[bot]](https://github.com/apps/github-actions))
13+
- Create linkcheck.yml [\#234](https://github.com/viamrobotics/viam-flutter-sdk/pull/234) ([npentrel](https://github.com/npentrel))
14+
- RSDK-7769, RSDK-7770 Add AppRobotClient and LogOutput dial option [\#233](https://github.com/viamrobotics/viam-flutter-sdk/pull/233) ([benjirewis](https://github.com/benjirewis))
15+
- DOCS-2036: Add vision service example snippets [\#232](https://github.com/viamrobotics/viam-flutter-sdk/pull/232) ([JessamyT](https://github.com/JessamyT))
16+
- DOCS-2400: Add snippets for resource base methods [\#231](https://github.com/viamrobotics/viam-flutter-sdk/pull/231) ([JessamyT](https://github.com/JessamyT))
17+
- DOCS-2035: Add example snippets to movement sensor, power sensor, sensor [\#230](https://github.com/viamrobotics/viam-flutter-sdk/pull/230) ([JessamyT](https://github.com/JessamyT))
18+
- Automated Protos Update [\#229](https://github.com/viamrobotics/viam-flutter-sdk/pull/229) ([github-actions[bot]](https://github.com/apps/github-actions))
19+
- Automated Protos Update [\#228](https://github.com/viamrobotics/viam-flutter-sdk/pull/228) ([github-actions[bot]](https://github.com/apps/github-actions))
20+
- DOCS-2033: Add gripper example snippets [\#227](https://github.com/viamrobotics/viam-flutter-sdk/pull/227) ([JessamyT](https://github.com/JessamyT))
21+
- DOCS-2032: Add camera and gantry example snippets [\#226](https://github.com/viamrobotics/viam-flutter-sdk/pull/226) ([JessamyT](https://github.com/JessamyT))
22+
- Fix 3rd Party License Auditor [\#225](https://github.com/viamrobotics/viam-flutter-sdk/pull/225) ([njooma](https://github.com/njooma))
23+
- `viam_example_app` has syntax's errors [\#224](https://github.com/viamrobotics/viam-flutter-sdk/pull/224) ([g0rdan](https://github.com/g0rdan))
24+
- Fix pwmFrequency and setPowerMode examples [\#223](https://github.com/viamrobotics/viam-flutter-sdk/pull/223) ([JessamyT](https://github.com/JessamyT))
25+
- DOCS-2382: Update readme [\#222](https://github.com/viamrobotics/viam-flutter-sdk/pull/222) ([JessamyT](https://github.com/JessamyT))
26+
- Automated Protos Update [\#221](https://github.com/viamrobotics/viam-flutter-sdk/pull/221) ([github-actions[bot]](https://github.com/apps/github-actions))
27+
- v0.0.15 [\#219](https://github.com/viamrobotics/viam-flutter-sdk/pull/219) ([github-actions[bot]](https://github.com/apps/github-actions))
28+
- DOCS-2031: Add arm, base, board example snippets [\#218](https://github.com/viamrobotics/viam-flutter-sdk/pull/218) ([JessamyT](https://github.com/JessamyT))
29+
- Automated Protos Update [\#217](https://github.com/viamrobotics/viam-flutter-sdk/pull/217) ([github-actions[bot]](https://github.com/apps/github-actions))
930
- Automated Protos Update [\#216](https://github.com/viamrobotics/viam-flutter-sdk/pull/216) ([github-actions[bot]](https://github.com/apps/github-actions))
1031
- Add license auditing [\#214](https://github.com/viamrobotics/viam-flutter-sdk/pull/214) ([njooma](https://github.com/njooma))
1132
- RSDK-7445: paginate data by filter methods [\#213](https://github.com/viamrobotics/viam-flutter-sdk/pull/213) ([purplenicole730](https://github.com/purplenicole730))
@@ -118,6 +139,14 @@
118139
- RSDK-4580: Flutter SDK Base Properties [\#100](https://github.com/viamrobotics/viam-flutter-sdk/pull/100) ([martha-johnston](https://github.com/martha-johnston))
119140
- Automated Protos Update [\#97](https://github.com/viamrobotics/viam-flutter-sdk/pull/97) ([github-actions[bot]](https://github.com/apps/github-actions))
120141

142+
## [v0.0.16](https://github.com/viamrobotics/viam-flutter-sdk/tree/v0.0.16) (2024-06-25)
143+
144+
[Full Changelog](https://github.com/viamrobotics/viam-flutter-sdk/compare/v0.0.15...v0.0.16)
145+
146+
## [v0.0.15](https://github.com/viamrobotics/viam-flutter-sdk/tree/v0.0.15) (2024-05-28)
147+
148+
[Full Changelog](https://github.com/viamrobotics/viam-flutter-sdk/compare/v0.0.14...v0.0.15)
149+
121150
## [v0.0.14](https://github.com/viamrobotics/viam-flutter-sdk/tree/v0.0.14) (2024-05-14)
122151

123152
[Full Changelog](https://github.com/viamrobotics/viam-flutter-sdk/compare/v0.0.13...v0.0.14)

lib/src/app/robot.dart

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import 'dart:async';
2+
3+
import 'package:logger/logger.dart';
4+
import 'package:viam_sdk/src/gen/google/protobuf/timestamp.pb.dart';
5+
6+
import '../gen/app/v1/robot.pbgrpc.dart';
7+
import '../gen/common/v1/common.pb.dart';
8+
9+
/// gRPC client for connecting to app's RobotService.
10+
///
11+
/// All calls must be authenticated.
12+
class AppRobotClient {
13+
final RobotServiceClient _client;
14+
15+
AppRobotClient(this._client);
16+
17+
/// Log the OutputEvent to app with the given partId.
18+
Future<void> log(String partId, host, loggerName, OutputEvent event) async {
19+
late String level;
20+
switch (event.level) {
21+
case Level.debug:
22+
level = 'debug';
23+
case Level.warning:
24+
level = 'warning';
25+
case Level.error:
26+
level = 'error';
27+
default:
28+
// Assume info level if none of the above.
29+
level = 'info';
30+
}
31+
32+
// Assume log was just output (OutputEvent has no timestamp field).
33+
final Timestamp protoTs = Timestamp.fromDateTime(DateTime.now());
34+
35+
// Join lines with '\n' and suffix with '\n'.
36+
final String message = '${event.lines.join('\n')}\n';
37+
38+
final LogEntry entry = LogEntry(host: host, level: level, time: protoTs, loggerName: loggerName, message: message);
39+
final request = LogRequest(id: partId, logs: [entry]);
40+
await _client.log(request);
41+
}
42+
}

lib/src/components/gripper/gripper.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import '../../robot/client.dart';
88
abstract class Gripper extends Resource {
99
static const Subtype subtype = Subtype(resourceNamespaceRDK, resourceTypeComponent, 'gripper');
1010

11-
/// Open the [Gripper]
11+
/// Open the [Gripper].
1212
///
1313
/// ```
1414
/// await myGripper.open();
@@ -26,7 +26,7 @@ abstract class Gripper extends Resource {
2626
/// For more information, see [Gripper component](https://docs.viam.com/components/gripper/).
2727
Future<void> grab({Map<String, dynamic>? extra});
2828

29-
/// Stop all motion of the [Gripper]. It is assumed the [Gripper] stops immediately
29+
/// Stop all motion of the [Gripper]. It is assumed the [Gripper] stops immediately.
3030
///
3131
/// ```
3232
/// await myGripper.stop();
@@ -35,7 +35,7 @@ abstract class Gripper extends Resource {
3535
/// For more information, see [Gripper component](https://docs.viam.com/components/gripper/).
3636
Future<void> stop({Map<String, dynamic>? extra});
3737

38-
/// If the [Gripper] is currently moving
38+
/// Whether the [Gripper] is currently moving.
3939
///
4040
/// ```
4141
/// var isItMoving = await myGripper.isMoving();

lib/src/components/motor/motor.dart

+65-3
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,23 @@ abstract class Motor extends Resource {
2626
/// When [powerPct] is negative, the rotation will be in the backward direction.
2727
///
2828
/// For more information, see [Motor component](https://docs.viam.com/components/motor/).
29+
///
30+
/// ```
31+
/// // Set the power to 40% forwards.
32+
/// await myMotor.setPower(0.4);
33+
/// ```
2934
Future<void> setPower(double powerPct, {Map<String, dynamic>? extra});
3035

3136
/// Spin the [Motor] the specified number of [revolutions] at specified [rpm].
3237
/// When [rpm] or [revolutions] is a negative value, the rotation will be in the backward direction.
3338
/// Note: if both [rpm] and [revolutions] are negative, the motor will spin in the forward direction.
3439
///
3540
/// For more information, see [Motor component](https://docs.viam.com/components/motor/).
41+
///
42+
/// ```
43+
/// // Turn the motor 7.2 revolutions forward at 60 RPM.
44+
/// await myMotor.goFor(60, 7.2);
45+
/// ```
3646
Future<void> goFor(double rpm, double revolutions, {Map<String, dynamic>? extra});
3747

3848
/// Spin the [Motor] to the specified position (provided in revolutions from home/zero),
@@ -41,51 +51,103 @@ abstract class Motor extends Resource {
4151
/// the [Motor] towards the specified position.
4252
///
4353
/// For more information, see [Motor component](https://docs.viam.com/components/motor/).
54+
///
55+
/// ```
56+
/// // Turn the motor to 8.3 revolutions from home at 75 RPM.
57+
/// await myMotor.goTo(75, 8.3);
58+
/// ```
4459
Future<void> goTo(double rpm, double positionRevolutions, {Map<String, dynamic>? extra});
4560

4661
/// Spin the [Motor] indefinitely at the specified speed, in revolutions per minute.
4762
/// If [rpm] is positive, the motor will spin forwards, and if [rpm] is negative, the motor will spin backwards.
4863
///
4964
/// For more information, see [Motor component](https://docs.viam.com/components/motor/).
65+
///
66+
/// ```
67+
/// // Set the motor to turn backwards at 120.5 RPM.
68+
/// await myMotor.setRPM(-120.5);
69+
/// ```
5070
Future<void> setRPM(double rpm, {Map<String, dynamic>? extra});
5171

5272
/// Set the current position (modified by [offset]) to be the new zero (home) position.
5373
///
5474
/// For more information, see [Motor component](https://docs.viam.com/components/motor/).
75+
///
76+
/// ```
77+
/// // Set the current position as the new home position with no offset.
78+
/// await myMotor.resetZeroPosition(0.0);
79+
/// ```
5580
Future<void> resetZeroPosition(double offset, {Map<String, dynamic>? extra});
5681

5782
/// Report the position of the motor based on its encoder.
5883
/// The value returned is the number of revolutions relative to its zero position.
5984
/// This method will raise an exception if position reporting is not supported by the motor.
6085
///
6186
/// For more information, see [Motor component](https://docs.viam.com/components/motor/).
87+
///
88+
/// ```
89+
/// // Get the current position of an encoded motor.
90+
/// var position = await myMotor.position();
91+
/// ```
6292
Future<double> position({Map<String, dynamic>? extra});
6393

64-
/// Report a dictionary mapping optional properties to
94+
/// Report a dictionary mapping each optional property to
6595
/// whether it is supported by this motor.
6696
///
6797
/// For more information, see [Motor component](https://docs.viam.com/components/motor/).
98+
///
99+
/// ```
100+
/// // Return whether the motor supports certain optional features
101+
/// var properties = await myMotor.properties();
102+
/// ```
68103
Future<MotorProperties> properties({Map<String, dynamic>? extra});
69104

70105
/// Stop the motor immediately, without any gradual step down.
71106
///
72107
/// For more information, see [Motor component](https://docs.viam.com/components/motor/).
73108
Future<void> stop({Map<String, dynamic>? extra});
109+
///
110+
/// ```
111+
/// // Stop the motor.
112+
/// await myMotor.stop();
113+
/// ```
114+
Future<void> stop({Map<String, dynamic>? extra});
74115

75-
/// Returns whether or not the motor is currently running.
116+
/// Returns whether or not the motor is currently powered, and the portion
117+
/// of max power (between 0 and 1; 0 indicates that power is off). Stepper
118+
/// motors report `true` if they are being powered while holding a position,
119+
/// as well as when they are turning themselves.
76120
///
77121
/// For more information, see [Motor component](https://docs.viam.com/components/motor/).
78-
122+
///
123+
/// ```
124+
/// // Check whether the motor is currently powered and
125+
/// // check the percentage of max power to the motor.
126+
/// var powerState = await myMotor.powerState();
127+
/// var powered = powerState.isOn;
128+
/// var pct = powerState.powerPct;
129+
/// ```
79130
Future<PowerState> powerState({Map<String, dynamic>? extra});
80131

81132
/// Get if the [Motor] is currently moving.
82133
///
83134
/// For more information, see [Motor component](https://docs.viam.com/components/motor/).
135+
///
136+
/// ```
137+
/// // Check whether the motor is moving.
138+
/// var moving = await myMotor.isMoving();
139+
/// ```
84140
Future<bool> isMoving({Map<String, dynamic>? extra});
85141

86142
/// Get the [ResourceName] for this [Motor] with the given [name]
87143
///
88144
/// For more information, see [Motor component](https://docs.viam.com/components/motor/).
145+
///
146+
/// ```
147+
/// var name = Motor.getResourceName('myMotor');
148+
/// ```
149+
///
150+
Future<bool> isMoving({Map<String, dynamic>? extra});
89151
static ResourceName getResourceName(String name) {
90152
return Motor.subtype.getResourceName(name);
91153
}

lib/src/components/power_sensor/power_sensor.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ abstract class PowerSensor extends Resource {
2727
/// AC (true) or DC (false).
2828
///
2929
/// ```
30-
/// var voltageObject = await myPowerSensor.readings();
31-
/// double voltageInVolts = voltageObject['volts'];
32-
/// bool isItAC = voltageObject['isAc'];
30+
/// var voltageObject = await myPowerSensor.voltage();
31+
/// double voltageInVolts = voltageObject.volts;
32+
/// bool isItAC = voltageObject.isAc;
3333
/// ```
3434
///
3535
/// For more information, see [Power Sensor component](https://docs.viam.com/components/power-sensor/).
@@ -39,9 +39,9 @@ abstract class PowerSensor extends Resource {
3939
/// is AC (true) or DC (false).
4040
///
4141
/// ```
42-
/// var currentObject = await myPowerSensor.readings();
43-
/// double amps = voltageObject['amperes'];
44-
/// bool isItAC = voltageObject['isAc'];
42+
/// var currentObject = await myPowerSensor.current();
43+
/// double amps = currentObject.amperes;
44+
/// bool isItAC = currentObject.isAc;
4545
/// ```
4646
///
4747
/// For more information, see [Power Sensor component](https://docs.viam.com/components/power-sensor/).

lib/src/components/servo/servo.dart

+29
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ abstract class Servo extends Resource {
1616
/// Get the current angle (degrees) of the [Servo].
1717
///
1818
/// For more information, see [Servo component](https://docs.viam.com/components/servo/).
19+
///
20+
/// ```
21+
/// var angle = await myServo.position();
22+
/// ```
1923
Future<int> position({Map<String, dynamic>? extra});
2024

2125
/// Stop the [Servo]. It is assumed that the servo stops immediately.
2226
///
2327
/// For more information, see [Servo component](https://docs.viam.com/components/servo/).
28+
///
2429
Future<void> stop({Map<String, dynamic>? extra});
2530

2631
/// Get if the [Servo] is currently moving.
@@ -31,13 +36,37 @@ abstract class Servo extends Resource {
3136
/// Get the [ResourceName] for this [Servo] with the given [name]
3237
///
3338
/// For more information, see [Servo component](https://docs.viam.com/components/servo/).
39+
///
40+
/// ```
41+
/// await myServo.stop();
42+
/// ```
43+
Future<void> stop({Map<String, dynamic>? extra});
44+
45+
/// Whether the [Servo] is currently moving.
46+
///
47+
/// For more information, see [Servo component](https://docs.viam.com/components/servo/).
48+
///
49+
/// ```
50+
/// var isItMoving = await myServo.isMoving();
51+
/// ```
52+
Future<bool> isMoving();
53+
54+
/// Get the [ResourceName] for this [Servo] with the given [name].
55+
///
56+
/// For more information, see [Servo component](https://docs.viam.com/components/servo/).
57+
///
58+
/// ```
59+
/// // Example:
60+
/// var name = Servo.getResourceName('myServo');
61+
/// ```
3462
static ResourceName getResourceName(String name) {
3563
return Servo.subtype.getResourceName(name);
3664
}
3765

3866
/// Get the [Servo] named [name] from the provided robot.
3967
///
4068
/// For more information, see [Servo component](https://docs.viam.com/components/servo/).
69+
///
4170
static Servo fromRobot(RobotClient robot, String name) {
4271
return robot.getResource(Servo.getResourceName(name));
4372
}

lib/src/gen/app/data/v1/data.pb.dart

+6-3
Original file line numberDiff line numberDiff line change
@@ -1934,9 +1934,12 @@ class BinaryMetadata extends $pb.GeneratedMessage {
19341934
$core.List<$core.String> get datasetIds => $_getList(8);
19351935
}
19361936

1937-
/// DeleteTabularDataRequest deletes the data from the organization that is older than `delete_older_than_days`.
1938-
/// For example if `delete_older_than_days` is 10, this deletes any data that was captured up to 10 days ago.
1939-
/// If it is 0, all existing data is deleted.
1937+
/// DeleteTabularDataRequest deletes the data from the organization that is older than `delete_older_than_days`
1938+
/// in UTC time. For example, if delete_older_than_days=1 and the request is made at 1AM EST on March 11
1939+
/// (March 11 5AM UTC), this deletes all data captured through March 10 11:59:59PM UTC.
1940+
/// If the request is at 10PM EST on March 11 (March 12 2AM UTC), this deletes all data captured
1941+
/// through March 11 11:59:59PM UTC.
1942+
/// If delete_older_than_days is 0, all existing data is deleted.
19401943
class DeleteTabularDataRequest extends $pb.GeneratedMessage {
19411944
factory DeleteTabularDataRequest({
19421945
$core.String? organizationId,

0 commit comments

Comments
 (0)