Skip to content

Commit

Permalink
Merge branch 'main' into mini-dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 authored Jan 9, 2025
2 parents ca745db + 73697b1 commit dced295
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 35 deletions.
2 changes: 1 addition & 1 deletion lib/src/data/metrics/arm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ArmMetrics extends Metrics<ArmData> {
MetricLine(" Limit? ${motor.isLimitSwitchPressed.displayName}", severity: motor.isLimitSwitchPressed.toBool() ? Severity.warning : null),
MetricLine(" Direction: ${motor.direction.humanName}"),
MetricLine(" Steps: ${motor.currentStep} --> ${motor.targetStep}"),
MetricLine(" Angle: ${motor.angle.toDegrees()} degrees"),
MetricLine(" Angle: ${motor.currentAngle.toDegrees()} degrees"),
];

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/src/data/metrics/gripper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GripperMetrics extends Metrics<GripperData> {
MetricLine(" Limit? ${motor.isLimitSwitchPressed.displayName}", severity: motor.isLimitSwitchPressed.toBool() ? Severity.warning : null),
MetricLine(" Direction: ${motor.direction.humanName}"),
MetricLine(" Steps: ${motor.currentStep} --> ${motor.targetStep}"),
MetricLine(" Angle: ${motor.angle.toDegrees() % 360} degrees"),
MetricLine(" Angle: ${motor.currentAngle.toDegrees() % 360} degrees"),
];

@override
Expand Down
13 changes: 2 additions & 11 deletions lib/src/data/protobuf.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import "dart:math";

import "package:protobuf/protobuf.dart";
import "package:rover_dashboard/data.dart";

export "package:protobuf/protobuf.dart" show GeneratedMessageGenericExtensions;
Expand Down Expand Up @@ -28,16 +27,6 @@ String getDataName(Device device) => switch (device) {
_ => "Unknown",
};

/// Utilities for a list of Protobuf enums.
extension UndefinedFilter<T extends ProtobufEnum> on List<T> {
/// Filters out `_UNDEFINED` values from the list.
List<T> get filtered => [
for (final value in this)
if (value.value != 0)
value,
];
}

/// Utilities for [Timestamp]s.
extension TimestampUtils on Timestamp {
/// The [Timestamp] version of [DateTime.now].
Expand Down Expand Up @@ -145,6 +134,8 @@ extension DeviceUtils on Device {
case Device.GRIPPER: return "Gripper";
case Device.SCIENCE: return "Science";
case Device.DRIVE: return "Drive";
case Device.BASE_STATION: return "Base Station";
case Device.ANTENNA: return "Antenna";
}
// Do not use default or else you'll lose exhaustiveness checking.
throw ArgumentError("Unrecognized device: $this");
Expand Down
6 changes: 3 additions & 3 deletions lib/src/models/view/arm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class ArmModel with ChangeNotifier {

/// The angles of the arm.
ArmAngles get angles => (
shoulder: arm.shoulder.angle,
elbow: arm.elbow.angle,
lift: gripper.lift.angle,
shoulder: arm.shoulder.currentAngle,
elbow: arm.elbow.currentAngle,
lift: gripper.lift.currentAngle,
);

/// The position of the mouse, if it's in the box.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/view/builders/preset_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class PresetBuilder extends ValueBuilder<void> {
@override
void get value { /* Use [save] instead */ }

/// Calls [models.views.saveAsPreset] in views.dart
/// Calls `models.views.saveAsPreset` in views.dart
void save() => models.views.saveAsPreset(nameController.text);
}
8 changes: 4 additions & 4 deletions lib/src/pages/arm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,23 +188,23 @@ class ArmPainterSide extends CustomPainter {
];

final firstCirclePaint = Paint()
..color = lineColors[0].withOpacity(opacity)
..color = lineColors[0].withValues(alpha: opacity)
..style = PaintingStyle.fill;

canvas.drawCircle(points[0], screen / 40, firstCirclePaint);

// Draw lines based off joint position
for (var i = 0; i < points.length - 1; i++) {
final paint = Paint()
..color = lineColors[i].withOpacity(opacity)
..color = lineColors[i].withValues(alpha: opacity)
..strokeWidth = screen / 50;
canvas.drawLine(points[i], points[i + 1], paint);
}

// Draw circles on each joint
for (var i = 0; i < points.length - 1; i++) {
final circlePaint = Paint()
..color = lineColors[i].withOpacity(opacity)
..color = lineColors[i].withValues(alpha: opacity)
..style = PaintingStyle.fill;
canvas.drawCircle(points[i + 1], screen / 50, circlePaint);
}
Expand Down Expand Up @@ -304,7 +304,7 @@ class ArmPage extends ReactiveWidget<ArmModel> {
elevation: 16,
color: context.colorScheme.surfaceContainerHighest,
child: CustomPaint(
painter: ArmPainterTop(swivelAngle: model.arm.base.angle),
painter: ArmPainterTop(swivelAngle: model.arm.base.currentAngle),
),
),
),
Expand Down
16 changes: 8 additions & 8 deletions lib/src/pages/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class DashboardView {
/// An icon to indicate the status of the given camera.
static Widget getCameraStatus(CameraName name) {
if (!models.sockets.video.isConnected) {
return Icon(Icons.signal_wifi_off, color: Colors.black.withOpacity(0.5));
return Icon(Icons.signal_wifi_off, color: Colors.black.withValues(alpha: 0.5));
}
final status = models.video.feeds[name]!.details.status;
const size = 12.0;
Expand Down Expand Up @@ -93,37 +93,37 @@ class DashboardView {
static final List<DashboardView> uiViews = [
DashboardView(
name: Routes.science,
iconFunc: () => Icon(Icons.science, color: Colors.black.withOpacity(0.5)),
iconFunc: () => Icon(Icons.science, color: Colors.black.withValues(alpha: 0.5)),
builder: (context, index) => SciencePage(index: index),
),
DashboardView(
name: Routes.autonomy,
iconFunc: () => Icon(Icons.map, color: Colors.black.withOpacity(0.5)),
iconFunc: () => Icon(Icons.map, color: Colors.black.withValues(alpha: 0.5)),
builder: (context, index) => MapPage(index: index),
),
DashboardView(
name: Routes.electrical,
iconFunc: () => Icon(Icons.bolt, color: Colors.black.withOpacity(0.5)),
iconFunc: () => Icon(Icons.bolt, color: Colors.black.withValues(alpha: 0.5)),
builder: (context, index) => ElectricalPage(index: index),
),
DashboardView(
name: Routes.arm,
iconFunc: () => Icon(Icons.precision_manufacturing_outlined, color: Colors.black.withOpacity(0.5)),
iconFunc: () => Icon(Icons.precision_manufacturing_outlined, color: Colors.black.withValues(alpha: 0.5)),
builder: (context, index) => ArmPage(index: index),
),
DashboardView(
name: Routes.drive,
iconFunc: () => Icon(Icons.drive_eta, color: Colors.black.withOpacity(0.5)),
iconFunc: () => Icon(Icons.drive_eta, color: Colors.black.withValues(alpha: 0.5)),
builder: (context, index) => DrivePage(index: index),
),
DashboardView(
name: Routes.rocks,
iconFunc: () => Icon(Icons.landslide, color: Colors.black.withOpacity(0.5)),
iconFunc: () => Icon(Icons.landslide, color: Colors.black.withValues(alpha: 0.5)),
builder: (context, index) => RocksPage(index: index),
),
DashboardView(
name: Routes.controllers,
iconFunc: () => Icon(Icons.sports_esports, color: Colors.black.withOpacity(0.5)),
iconFunc: () => Icon(Icons.sports_esports, color: Colors.black.withValues(alpha: 0.5)),
builder: (context, index) => ControllersPage(index: index),
),
];
Expand Down
2 changes: 1 addition & 1 deletion lib/src/services/socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DashboardSocket extends BurtSocket {
/// Notifier for when the socket connects or disconnects
final ValueNotifier<bool> connectionStatus = ValueNotifier(false);

/// Number of times to check heart beat per seconds based on [settings.network.connectionTimeout].
/// Number of times to check heart beat per seconds based on `models.settings.network.connectionTimeout`.
double get frequency => models.settings.network.connectionTimeout;

/// Listens for incoming messages on a UDP socket and sends heartbeats to the [device].
Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ packages:
dependency: "direct main"
description:
path: "."
ref: HEAD
resolved-ref: ceeb9602a332d612bd9392d2b865403eea76b465
ref: "2.1.0"
resolved-ref: "61c1952afe2210099ccde59220356db647dc79ae"
url: "https://github.com/BinghamtonRover/Networking.git"
source: git
version: "2.0.0"
version: "2.1.0"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -205,7 +205,7 @@ packages:
description:
path: "."
ref: set-children-public
resolved-ref: ee68851d5db330a47451dccff601ba4d0feb4896
resolved-ref: cf2f237653a48389a99081dbb5086c1acce03f7f
url: "https://github.com/Levi-Lesches/flutter_resizable_container"
source: git
version: "3.0.0"
Expand Down
4 changes: 3 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ dependencies:
flutter:
sdk: flutter
burt_network:
git: https://github.com/BinghamtonRover/Networking.git
git:
url: https://github.com/BinghamtonRover/Networking.git
ref: 2.1.0
file_picker: ^8.0.0+1
fl_chart: ^0.69.0
flutter_libserialport: ^0.4.0
Expand Down

0 comments on commit dced295

Please sign in to comment.