From 1651f6d3cce14a2376573ee0512110c25ee1cef5 Mon Sep 17 00:00:00 2001 From: Levi Lesches Date: Wed, 20 Sep 2023 11:15:02 -0400 Subject: [PATCH] Removed MARS and video2 sockets --- lib/models.dart | 1 - lib/pages.dart | 1 - lib/src/data/metrics/position.dart | 5 +- lib/src/models/data/sockets.dart | 20 +--- lib/src/models/data/views.dart | 3 +- lib/src/models/rover/settings.dart | 1 - .../models/view/builders/mars_command.dart | 35 ------ lib/src/pages/mars.dart | 101 ------------------ lib/src/widgets/atomic/video_feed.dart | 4 +- pubspec.yaml | 14 +-- 10 files changed, 9 insertions(+), 176 deletions(-) delete mode 100644 lib/src/models/view/builders/mars_command.dart delete mode 100644 lib/src/pages/mars.dart diff --git a/lib/models.dart b/lib/models.dart index 54c8de5b3..54a46c456 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -46,7 +46,6 @@ export "src/models/view/timer.dart"; export "src/models/view/builders/autonomy_command.dart"; export "src/models/view/builders/gps.dart"; export "src/models/view/builders/science_command.dart"; -export "src/models/view/builders/mars_command.dart"; export "src/models/view/builders/builder.dart"; export "src/models/view/builders/color_builder.dart"; export "src/models/view/builders/settings_builder.dart"; diff --git a/lib/pages.dart b/lib/pages.dart index 3b964c0ef..1a236dd11 100644 --- a/lib/pages.dart +++ b/lib/pages.dart @@ -8,7 +8,6 @@ library pages; export "src/pages/autonomy.dart"; export "src/pages/home.dart"; -export "src/pages/mars.dart"; export "src/pages/science.dart"; export "src/pages/settings.dart"; export "src/pages/splash.dart"; diff --git a/lib/src/data/metrics/position.dart b/lib/src/data/metrics/position.dart index 8111e5809..88160787a 100644 --- a/lib/src/data/metrics/position.dart +++ b/lib/src/data/metrics/position.dart @@ -1,5 +1,4 @@ import "package:rover_dashboard/data.dart"; -import "package:rover_dashboard/models.dart"; /// Metrics about the rover's position and orientation. /// @@ -51,9 +50,7 @@ class PositionMetrics extends Metrics { if(data.orientation.z > 360 || data.orientation.z < -360){ data.orientation.z = oldOrientation.z; notifyListeners(); - } - models.sockets.mars.sendMessage(MarsCommand(rover: value.gps)); - + } } /// The angle to orient the rover on the top-down map. diff --git a/lib/src/models/data/sockets.dart b/lib/src/models/data/sockets.dart index 0d1e42645..88e4d16ff 100644 --- a/lib/src/models/data/sockets.dart +++ b/lib/src/models/data/sockets.dart @@ -22,14 +22,6 @@ class Sockets extends Model { messageHandler: models.messages.onMessage, ); - /// A UDP socket for receiving video. - late final video2 = DashboardSocket( - device: Device.VIDEO, - onConnect: onConnect, - onDisconnect: onDisconnect, - messageHandler: models.messages.onMessage, - ); - /// A UDP socket for controlling autonomy. late final autonomy = DashboardSocket( device: Device.AUTONOMY, @@ -38,16 +30,8 @@ class Sockets extends Model { messageHandler: models.messages.onMessage, ); - /// A UDP socket for controlling the MARS subsystem. - late final mars = DashboardSocket( - device: Device.MARS_SERVER, - onConnect: onConnect, - onDisconnect: onDisconnect, - messageHandler: models.messages.onMessage, - ); - /// A list of all the sockets this model manages. - List get sockets => [data, video, video2, autonomy, mars]; + List get sockets => [data, video, autonomy]; /// The rover-like system currently in use. RoverType rover = RoverType.rover; @@ -106,9 +90,7 @@ class Sockets extends Model { final settings = models.settings.network; data.destination = settings.subsystemsSocket.copyWith(address: addressOverride); video.destination = settings.videoSocket.copyWith(address: addressOverride); - video2.destination = SocketInfo(address: InternetAddress("192.168.1.30"), port: 8007); autonomy.destination = settings.autonomySocket.copyWith(address: addressOverride); - mars.destination = settings.marsSocket.copyWith(address: addressOverride); await reset(); } diff --git a/lib/src/models/data/views.dart b/lib/src/models/data/views.dart index 0419e04b8..1f461063f 100644 --- a/lib/src/models/data/views.dart +++ b/lib/src/models/data/views.dart @@ -42,7 +42,7 @@ class ViewsSelector extends StatelessWidget { for (final view in DashboardView.cameraViews) PopupMenuItem( value: view, child: Row(children: [ - if (models.sockets.video.isConnected || models.sockets.video2.isConnected) ...[getCameraStatus(view), const SizedBox(width: 8)], + if (models.sockets.video.isConnected) ...[getCameraStatus(view), const SizedBox(width: 8)], Text(view.name), ],), ), @@ -83,7 +83,6 @@ class DashboardView { static final List uiViews = [ DashboardView(name: Routes.science, builder: (context) => SciencePage()), DashboardView(name: Routes.autonomy, builder: (context) => MapPage()), - DashboardView(name: Routes.mars, builder: (context) => MarsPage()), ]; /// A blank view. diff --git a/lib/src/models/rover/settings.dart b/lib/src/models/rover/settings.dart index f028a62d5..2d5a503c2 100644 --- a/lib/src/models/rover/settings.dart +++ b/lib/src/models/rover/settings.dart @@ -51,7 +51,6 @@ class RoverSettings extends Model { final message = UpdateSetting(status: value); models.sockets.video.sendMessage(message); models.sockets.autonomy.sendMessage(message); - models.sockets.mars.sendMessage(message); if (!await tryChangeSettings(message)) return; models.home.setMessage(severity: Severity.info, text: "Set mode to ${value.humanName}"); diff --git a/lib/src/models/view/builders/mars_command.dart b/lib/src/models/view/builders/mars_command.dart deleted file mode 100644 index 09661dd4d..000000000 --- a/lib/src/models/view/builders/mars_command.dart +++ /dev/null @@ -1,35 +0,0 @@ -import "package:rover_dashboard/data.dart"; -import "package:rover_dashboard/models.dart"; - -/// A [ValueBuilder] to modify a [MarsCommand]. -class MarsCommandBuilder extends ValueBuilder { - /// The base station's latitude. - final baseLatitude = NumberBuilder(0); - /// The base station's longitude. - final baseLongitude = NumberBuilder(0); - /// The base station's altitude. - final baseAltitude = NumberBuilder(0); - /// The rover's latitude. - final roverLatitude = NumberBuilder(0); - /// The rover's longitude. - final roverLongitude = NumberBuilder(0); - /// The rover's altitude. - final roverAltitude = NumberBuilder(0); - - @override - bool get isValid => - baseLatitude.isValid && baseLongitude.isValid && baseAltitude.isValid - && roverLatitude.isValid && roverLongitude.isValid && roverAltitude.isValid; - - @override - MarsCommand get value => MarsCommand( - baseStationOverride: GpsCoordinates(latitude: baseLatitude.value, longitude: baseLongitude.value, altitude: baseAltitude.value), - rover: GpsCoordinates(latitude: roverLatitude.value, longitude: roverLongitude.value, altitude: roverAltitude.value), - ); - - /// Sends a [MarsCommand] with the values in this model. - Future send() async { - models.sockets.mars.sendMessage(value); - models.home.setMessage(severity: Severity.info, text: "Message sent"); - } -} diff --git a/lib/src/pages/mars.dart b/lib/src/pages/mars.dart deleted file mode 100644 index 60b89bc67..000000000 --- a/lib/src/pages/mars.dart +++ /dev/null @@ -1,101 +0,0 @@ -import "package:flutter/material.dart"; - -import "package:rover_dashboard/models.dart"; -import "package:rover_dashboard/pages.dart"; -import "package:rover_dashboard/widgets.dart"; - -/// The MARS page. -/// -/// Visualizes the orientation of the antenna relative to the rover and allows the user to manually -/// override the MARS's memory of the base station and rover's position. -class MarsPage extends StatelessWidget { - @override - Widget build(BuildContext context) => Column(children: [ - Container( // The header at the top - color: context.colorScheme.surface, - height: 48, - child: Row(children: [ - const SizedBox(width: 8), - Text("MARS", style: context.textTheme.headlineMedium), - const Spacer(), - const ViewsSelector(currentView: Routes.mars), - ],), - ), - Expanded(child: ProviderConsumer( - create: MarsModel.new, - builder: (model) => Stack(children: [ - const Center(child: Divider()), - const Center(child: VerticalDivider()), - SizedBox.expand( - child: CustomPaint( - painter: LinePainter(position: model.roverOffset, color: context.colorScheme.secondary), - ), - ), - SizedBox.expand( - child: CustomPaint( - painter: LinePainter(position: model.actualOffset, color: Colors.yellow), - ), - ), - const Center(child: Icon(Icons.home, size: 36)), // The base station - AnimatedAlign( // The rover - duration: const Duration(milliseconds: 200), - alignment: Alignment(model.roverOffset.dx, model.roverOffset.dy), - child: const Icon(Icons.location_on, size: 36), - ), - ],), - ), - ), - const Divider(), - ProviderConsumer( - create: MarsCommandBuilder.new, - builder: (command) => Column(children: [ - Row(children: [ - const SizedBox(width: 4), - Text("Base station", style: context.textTheme.titleLarge), - const Spacer(flex: 2), - SizedBox(width: 175, child: NumberEditor(width: 4, titleFlex: 2, name: "Latitude", model: command.baseLatitude)), - SizedBox(width: 175, child: NumberEditor(width: 4, titleFlex: 2, name: "Longitude", model: command.baseLongitude)), - SizedBox(width: 175, child: NumberEditor(width: 4, titleFlex: 2, name: "Altitude", model: command.baseAltitude)), - ElevatedButton(onPressed: command.send, child: const Text("Send")), - const SizedBox(width: 4), - ],), - Row(children: [ - const SizedBox(width: 4), - Text("Rover", style: context.textTheme.titleLarge), - const Spacer(flex: 2), - SizedBox(width: 175, child: NumberEditor(width: 4, titleFlex: 2, name: "Latitude", model: command.roverLatitude)), - SizedBox(width: 175, child: NumberEditor(width: 4, titleFlex: 2, name: "Longitude", model: command.roverLongitude)), - SizedBox(width: 175, child: NumberEditor(width: 4, titleFlex: 2, name: "Altitude", model: command.roverAltitude)), - ElevatedButton(onPressed: command.send, child: const Text("Send")), - const SizedBox(width: 4), - ],), - ],), - ), - ],); -} - -/// Paints a line from the origin to the given [position] on-screen. -class LinePainter extends CustomPainter { - /// The position to draw to, from -1 to +1. - final Offset position; - /// The color line to draw. - final Color color; - /// Draws a line to the given position. - const LinePainter({required this.position, required this.color}); - - Paint get _paint => Paint() - ..color = color - ..strokeCap = StrokeCap.butt - ..strokeWidth = 8.0; - - @override - void paint(Canvas canvas, Size size) { - final newPosition = (position + const Offset(1, 1)) / 2; - final endpoint = Offset(size.width * newPosition.dx, size.height * newPosition.dy); - final origin = Offset(size.width / 2, size.height / 2); - canvas.drawLine(origin, endpoint, _paint); - } - - @override - bool shouldRepaint(LinePainter oldDelegate) => oldDelegate.position != position; -} diff --git a/lib/src/widgets/atomic/video_feed.dart b/lib/src/widgets/atomic/video_feed.dart index 194345f5f..ee8bfa4b4 100644 --- a/lib/src/widgets/atomic/video_feed.dart +++ b/lib/src/widgets/atomic/video_feed.dart @@ -110,7 +110,7 @@ class VideoFeedState extends State { width: double.infinity, padding: const EdgeInsets.all(4), alignment: Alignment.center, - child: (models.sockets.video.isConnected || models.sockets.video2.isConnected) && imageLoader.hasImage && data.details.status == CameraStatus.CAMERA_ENABLED + child: models.sockets.video.isConnected && imageLoader.hasImage && data.details.status == CameraStatus.CAMERA_ENABLED ? Row(children: [ Expanded(child: RawImage(image: imageLoader.image, fit: BoxFit.contain)), ],) @@ -140,7 +140,7 @@ class VideoFeedState extends State { /// Displays an error message describing why `image == null`. String get errorMessage { - if (!models.sockets.video.isConnected && !models.sockets.video2.isConnected) return "The video program is not connected"; + if (!models.sockets.video.isConnected) return "The video program is not connected"; switch (data.details.status) { case CameraStatus.CAMERA_LOADING: return "Camera is loading..."; case CameraStatus.CAMERA_STATUS_UNDEFINED: return "Unknown error"; diff --git a/pubspec.yaml b/pubspec.yaml index 50a7d213a..b05bab818 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: rover_dashboard description: Graphical application for remotely operating the rover. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 2023.9.20+2 +version: 2023.9.20+3 environment: sdk: "^3.0.0" @@ -35,11 +35,8 @@ dev_dependencies: very_good_analysis: ^5.0.0+1 # Do not modify this section unless you know what it does and why you need it. +# If you do need to override any dependencies, document which ones, which versions, and why. # dependency_overrides: - # win32_gamepad needs win32 ^4.0.0 - # path_provider_windows needs win32 <4.0.0 - # So, this is the latest version of win32 before 4.0.0 - # win32: 3.1.4 # Generates icons for the given platforms # Run: flutter pub run icons_launcher:create @@ -47,9 +44,6 @@ icons_launcher: image_path: "assets/logo.png" platforms: android: - # adaptive_foreground_image: "assets/logo.png" - # adaptive_background_color: "#000000" - # adaptive_monochrome_image: "assets/logo.png" enable: true windows: enable: true @@ -61,9 +55,9 @@ flutter_launcher_icons: generate: true # Builds a Windows .msix App Installer file for the Dashboard. -# Run: flutter pub run msix:create +# Command: dart run msix:create msix_config: - msix_version: 2023.9.20.2 + msix_version: 2023.9.20.3 display_name: Dashboard publisher_display_name: Binghamton University Rover Team identity_name: edu.binghamton.rover