Skip to content

Commit

Permalink
Merge branch 'main' into map-rework
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 authored Feb 3, 2025
2 parents 3a22ef1 + 63f2aa8 commit 1d1cccd
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 42 deletions.
28 changes: 14 additions & 14 deletions bin/science.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import "dart:convert";
import "dart:io";

import "package:protobuf/protobuf.dart" as proto;
import "package:burt_network/generated.dart";
import "package:burt_network/protobuf.dart";

/// A cleaner name for any message generated by Protobuf.
typedef Message = proto.GeneratedMessage;

/// Return true to keep this data in the dataset, or false to remove it.
///
///
/// Not only are the sensors on the rover wonky, but the CAN bus can corrupt data along the way.
/// This function can be used to remove any unwanted bad data.
bool shouldKeepData(Timestamp timestamp, ScienceData data) {
Expand All @@ -21,25 +21,25 @@ bool shouldKeepData(Timestamp timestamp, ScienceData data) {
if (data.humidity.isOutOfBounds(min: 0, max: 50)) return false;
if (data.temperature.isOutOfBounds(min: 0, max: 100)) return false;

// Any other conditions should go here:
// Any other conditions should go here:
if (elapsed >= 30 * 60) return false;

return true; // if none of the above rules are broken, then keep this data
}

/// Returns new data based on this one. To remove data, use [shouldKeepData] instead.
///
/// Returns new data based on this one. To remove data, use [shouldKeepData] instead.
///
/// You shouldn't need this unless you specifically need to change the *values* of the data. For example,
/// if the CO2 sensor was consistently 100ppm off, you could use this function to add 100ppm to each data.
///
/// NOTE: Do not modify fields that are zero, because they are likely sent in another "packet". For
///
/// NOTE: Do not modify fields that are zero, because they are likely sent in another "packet". For
/// example, if you want to modify CO2 but `data.co2 == 0`, this packet could be, eg, a methane packet
/// and isn't meant to have any CO2 data.
WrappedMessage modifyData(Timestamp timestamp, ScienceData data) { // ignore: prefer_expression_function_bodies
// Example 1: Add 100 ppm to all CO2:
// Example 1: Add 100 ppm to all CO2:
// if (data.co2 != 0) data.co2 += 100;
//
// Example 2: Add one second to all the timestamps:
//
// Example 2: Add one second to all the timestamps:
// timestamp += Duration(seconds: 1)

// Wrap the data and return it. Do not delete.
Expand All @@ -50,17 +50,17 @@ WrappedMessage modifyData(Timestamp timestamp, ScienceData data) { // ignore: p
/// Use this to add new data to your dataset.
List<WrappedMessage> newData = [
// Adds methane=1 for every second from t=1 to t=100 seconds
for (int t = 0; t < 100; t++)
for (int t = 0; t < 100; t++)
ScienceData(methane: 1).wrap(DateTime.now().add(Duration(seconds: t))),
// Adds some random methane in an increasing line between t=100 and t=200 seconds
for (int t = 100; t < 200; t++)
for (int t = 100; t < 200; t++)
ScienceData(methane: t + random.nextDouble() * 20).wrap(DateTime.now().add(Duration(seconds: t))),
// Adds completely random data for t=0 to t=20 seconds, for all three samples
for (int s = 0; s < 3; s++)
for (int s = 0; s < 3; s++)
for (int t = 0; t < 20; t++) ScienceData(
// sample: s,
// sample: s,
temperature: t + s + (random.nextInt(10).toDouble()),
methane: t + s + (random.nextInt(7).toDouble()),
co2: t + s + (random.nextInt(5).toDouble()),
Expand Down
2 changes: 1 addition & 1 deletion lib/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/// library should import any other library.
library data;

export "package:burt_network/generated.dart";
export "package:burt_network/protobuf.dart";

export "src/data/metrics/arm.dart";
export "src/data/metrics/drive.dart";
Expand Down
1 change: 1 addition & 0 deletions lib/src/data/protobuf.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ extension DeviceUtils on Device {
case Device.DRIVE: return "Drive";
case Device.BASE_STATION: return "Base Station";
case Device.ANTENNA: return "Antenna";
case Device.RELAY: return "Relays";
}
// Do not use default or else you'll lose exhaustiveness checking.
throw ArgumentError("Unrecognized device: $this");
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/rover/controls/tank_drive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DriveControls extends RoverControls {
List<Message> parseInputs(GamepadState state) => [
DriveCommand(throttle: throttle, setThrottle: true),
DriveCommand(setLeft: true, left: state.normalLeftY),
DriveCommand(setRight: true, right: -1*state.normalRightJoystickY),
DriveCommand(setRight: true, right: -1*state.normalRightY),
];

@override
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 @@ -24,7 +24,7 @@ class DashboardSocket extends BurtSocket {
double get frequency => models.settings.network.connectionTimeout;

/// Listens for incoming messages on a UDP socket and sends heartbeats to the [device].
DashboardSocket({required super.device}) : super(port: null, quiet: true);
DashboardSocket({required super.device}) : super(port: null, quiet: true, keepDestination: true);

@override
Duration get heartbeatInterval => Duration(milliseconds: 1000 ~/ frequency);
Expand Down
48 changes: 25 additions & 23 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ packages:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
url: "https://pub.dev"
source: hosted
version: "2.11.0"
version: "2.12.0"
audio_session:
dependency: transitive
description:
Expand All @@ -37,17 +37,19 @@ packages:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
burt_network:
dependency: "direct main"
description:
path: "../SubsystemsPi/Networking"
relative: true
source: path
version: "2.3.1"
path: burt_network
ref: "2.5.0"
resolved-ref: a52c8a984fcc4f6b022fa540c0ea13b55168ac22
url: "https://github.com/BinghamtonRover/Rover-Code.git"
source: git
version: "2.4.0"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -76,10 +78,10 @@ packages:
dependency: transitive
description:
name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
url: "https://pub.dev"
source: hosted
version: "1.1.1"
version: "1.1.2"
collection:
dependency: "direct main"
description:
Expand Down Expand Up @@ -132,10 +134,10 @@ packages:
dependency: transitive
description:
name: fake_async
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
url: "https://pub.dev"
source: hosted
version: "1.3.1"
version: "1.3.2"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -307,18 +309,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
url: "https://pub.dev"
source: hosted
version: "10.0.7"
version: "10.0.8"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
url: "https://pub.dev"
source: hosted
version: "3.0.8"
version: "3.0.9"
leak_tracker_testing:
dependency: transitive
description:
Expand Down Expand Up @@ -403,10 +405,10 @@ packages:
dependency: transitive
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
version: "1.9.1"
path_provider:
dependency: "direct main"
description:
Expand Down Expand Up @@ -560,10 +562,10 @@ packages:
dependency: transitive
description:
name: string_scanner
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
sha256: "0bd04f5bb74fcd6ff0606a888a30e917af9bd52820b178eaa464beb11dca84b6"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.4.0"
term_glyph:
dependency: transitive
description:
Expand Down Expand Up @@ -688,10 +690,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
url: "https://pub.dev"
source: hosted
version: "14.3.0"
version: "14.3.1"
web:
dependency: transitive
description:
Expand Down Expand Up @@ -733,5 +735,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.5.3 <4.0.0"
dart: ">=3.6.0 <4.0.0"
flutter: ">=3.24.0"
5 changes: 3 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ dependencies:
sdk: flutter
burt_network:
git:
url: https://github.com/BinghamtonRover/Networking.git
ref: 2.2.0
url: https://github.com/BinghamtonRover/Rover-Code.git
path: burt_network
ref: 2.5.0
file_picker: ^8.0.0+1
fl_chart: ^0.69.0
flutter_libserialport: ^0.4.0
Expand Down

0 comments on commit 1d1cccd

Please sign in to comment.