|
| 1 | +import "package:collection/collection.dart"; |
| 2 | + |
1 | 3 | import "package:rover_dashboard/data.dart"; |
| 4 | +import "package:rover_dashboard/models.dart"; |
2 | 5 | import "package:rover_dashboard/services.dart"; |
3 | 6 |
|
4 | 7 | /// Metrics reported by the drive subsystem. |
5 | | -/// |
6 | | -/// In the future, the drive Teensy will have a GPS and IMU to read [RoverPosition] data. For now, |
7 | | -/// this information is sent separately and is represented by its own [RoverPosition] object because |
8 | | -/// they are collected on the Pi. In the future, when they are moved to the Drive subsystem, this |
9 | | -/// data should still be kept separate so as to make it easier to show in the UI and send to MARS. |
10 | 8 | class DriveMetrics extends Metrics<DriveData> { |
11 | 9 | /// A collection of metrics relevant for monitoring the rover's electrical status. |
12 | 10 | DriveMetrics() : super(DriveData()); |
@@ -45,19 +43,38 @@ class DriveMetrics extends Metrics<DriveData> { |
45 | 43 | MetricLine("Left: ${data.left.toStringAsFixed(2)}"), |
46 | 44 | MetricLine("Right: ${data.right.toStringAsFixed(2)}"), |
47 | 45 | MetricLine("Battery: ${data.batteryVoltage.toStringAsFixed(2)}V,${data.batteryCurrent.toStringAsFixed(2)}A, ${data.batteryTemperature.toStringAsFixed(2)}°F", severity: electricalSeverity), |
48 | | - ]; |
| 46 | + MetricLine("Left Side: ${data.frontLeft.toStringAsFixed(1)}, ${data.middleLeft.toStringAsFixed(1)}, ${data.backLeft.toStringAsFixed(1)}"), |
| 47 | + MetricLine("Right Side: ${data.frontRight.toStringAsFixed(1)}, ${data.middleRight.toStringAsFixed(1)}, ${data.backRight.toStringAsFixed(1)}"), |
| 48 | + ]; |
49 | 49 |
|
50 | 50 | @override |
51 | 51 | void update(DriveData value) { |
52 | 52 | // Since the newValues are often zero, [Metrics.merge] won't work. |
53 | 53 | if (!checkVersion(value)) return; |
54 | 54 | services.files.logData(value); |
| 55 | + final oldThrottle = data.throttle; |
55 | 56 | if (value.setLeft) data.left = value.left; |
56 | 57 | if (value.setRight) data.right = value.right; |
57 | 58 | if (value.setThrottle) data.throttle = value.throttle; |
58 | 59 | if (value.hasBatteryCurrent()) data.batteryCurrent = value.batteryCurrent; |
59 | 60 | if (value.hasBatteryVoltage()) data.batteryVoltage = value.batteryVoltage; |
60 | 61 | if (value.hasBatteryTemperature()) data.batteryTemperature = value.batteryTemperature; |
| 62 | + if(value.hasFrontLeft()) data.frontLeft = value.frontLeft; |
| 63 | + if(value.hasMiddleLeft()) data.middleLeft = value.middleLeft; |
| 64 | + if(value.hasBackLeft()) data.backLeft = value.backLeft; |
| 65 | + if(value.hasFrontRight()) data.frontRight = value.frontRight; |
| 66 | + if(value.hasMiddleRight()) data.middleRight = value.middleRight; |
| 67 | + if(value.hasBackRight()) data.backRight = value.backRight; |
| 68 | + if (value.color != ProtoColor.PROTO_COLOR_UNDEFINED) data.color = value.color; |
| 69 | + |
| 70 | + if ( |
| 71 | + (data.throttle > 0.05 && oldThrottle < 0.05) || |
| 72 | + (data.throttle < 0.05 && oldThrottle > 0.05) |
| 73 | + ) { |
| 74 | + models.rover.controllers.firstWhereOrNull( |
| 75 | + (controller) => controller.mode == OperatingMode.drive || controller.mode == OperatingMode.modernDrive, |
| 76 | + )?.gamepad.pulse(); |
| 77 | + } |
61 | 78 | notifyListeners(); |
62 | 79 | } |
63 | 80 |
|
|
0 commit comments