Skip to content

Commit

Permalink
fixes for field orientation, lints
Browse files Browse the repository at this point in the history
  • Loading branch information
mootw committed Feb 21, 2024
1 parent 3337e8d commit 18eeaaa
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 25 deletions.
6 changes: 1 addition & 5 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:provider/provider.dart';
import 'package:snout_db/config/eventconfig.dart';
import 'package:snout_db/config/matcheventconfig.dart';
import 'package:snout_db/patch.dart';
import 'package:snout_db/snout_db.dart';
import 'package:url_launcher/url_launcher_string.dart';
Expand Down Expand Up @@ -151,7 +150,7 @@ class _MyHomePageState extends State<MyHomePage> {
NavigationRailDestination(
selectedIcon: Icon(Icons.analytics),
icon: Icon(Icons.analytics_outlined),
label: Text('Analyssis'),
label: Text('Analysis'),
),
NavigationRailDestination(
selectedIcon: Icon(Icons.book),
Expand Down Expand Up @@ -270,7 +269,6 @@ class _MyHomePageState extends State<MyHomePage> {

if (result != null) {
final modAsConfig = EventConfig.fromJson(jsonDecode(result));
print("hi");
final reAppendedConfig = EventConfig(
name: modAsConfig.name,
team: modAsConfig.team,
Expand All @@ -281,7 +279,6 @@ class _MyHomePageState extends State<MyHomePage> {
pitscouting: modAsConfig.pitscouting,
tbaEventId: modAsConfig.tbaEventId,
tbaSecretKey: modAsConfig.tbaSecretKey);
print("hi2");

Patch patch = Patch(
identity: identity,
Expand All @@ -290,7 +287,6 @@ class _MyHomePageState extends State<MyHomePage> {
value: reAppendedConfig.toJson());
//Save the scouting results to the server!!

print("hi3");
await data.submitPatch(patch);
}
},
Expand Down
2 changes: 1 addition & 1 deletion app/lib/screens/analysis/events_heatmaps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AnalysisEventsHeatmap extends StatelessWidget {
(previousValue, element) => [
...previousValue,
...element
.timelineRedNormalized(
.timelineBlueNormalized(
data.event.config.fieldStyle)
.where(
(event) => event.id == eventType.id)
Expand Down
2 changes: 1 addition & 1 deletion app/lib/screens/analysis/heatmap_event_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class _AnalysisHeatMapByEventTypeState
(previousValue, element) => [
...previousValue,
...element
.timelineRedNormalized(data
.timelineBlueNormalized(data
.event.config.fieldStyle)
.where((event) =>
event.id ==
Expand Down
6 changes: 3 additions & 3 deletions app/lib/screens/analysis/match_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class _AnalysisMatchPreviewState extends State<AnalysisMatchPreview> {
(
label: match.value.description,
path: match.value.robot[team.toString()]!
.timelineInterpolatedRedNormalized(
.timelineInterpolatedBlueNormalized(
data.event.config.fieldStyle)
.where((element) => element.isInAuto)
.toList()
Expand All @@ -233,7 +233,7 @@ class _AnalysisMatchPreviewState extends State<AnalysisMatchPreview> {
...previousValue,
...?element.value
.robot[team.toString()]
?.timelineRedNormalized(data
?.timelineBlueNormalized(data
.event
.config
.fieldStyle)
Expand All @@ -256,7 +256,7 @@ class _AnalysisMatchPreviewState extends State<AnalysisMatchPreview> {
...previousValue,
...?element.value
.robot[team.toString()]
?.timelineInterpolatedRedNormalized(
?.timelineInterpolatedBlueNormalized(
data.event.config
.fieldStyle)
.where((event) =>
Expand Down
5 changes: 2 additions & 3 deletions app/lib/screens/match_recorder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:app/providers/data_provider.dart';
import 'package:app/widgets/fieldwidget.dart';
import 'package:app/style.dart';
import 'package:app/scouting_tools/scouting_tool.dart';
import 'package:app/widgets/image_view.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -309,8 +308,8 @@ class _MatchRecorderPageState extends State<MatchRecorderPage> {
coverAlignment: _mode != MatchMode.setup
? null
: widget.teamAlliance == Alliance.red
? 1
: -1,
? -1
: 1,
alliance: widget.teamAlliance,
robotPosition: _robotPosition,
onTap: (robotPosition) {
Expand Down
6 changes: 3 additions & 3 deletions app/lib/screens/view_team_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class _TeamViewPageState extends State<TeamViewPage> {
label: match.value.description,
path: match
.value.robot[widget.teamNumber.toString()]!
.timelineInterpolatedRedNormalized(
.timelineInterpolatedBlueNormalized(
data.event.config.fieldStyle)
.where((element) => element.isInAuto)
.toList()
Expand Down Expand Up @@ -291,7 +291,7 @@ class _TeamViewPageState extends State<TeamViewPage> {
...previousValue,
...?element.value
.robot[widget.teamNumber.toString()]
?.timelineRedNormalized(
?.timelineBlueNormalized(
data.event.config.fieldStyle)
.where((event) =>
event.id == eventType.id)
Expand All @@ -311,7 +311,7 @@ class _TeamViewPageState extends State<TeamViewPage> {
...previousValue,
...?element.value
.robot[widget.teamNumber.toString()]
?.timelineInterpolatedRedNormalized(
?.timelineInterpolatedBlueNormalized(
data.event.config.fieldStyle)
.where(
(event) => event.isPositionEvent)
Expand Down
13 changes: 7 additions & 6 deletions snout_db/lib/event/robotmatchresults.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ class RobotMatchResults {
_$RobotMatchResultsFromJson(json);
Map<String, dynamic> toJson() => _$RobotMatchResultsToJson(this);

List<MatchEvent> timelineRedNormalized(FieldStyle fieldStyle) =>
_normalizeRed(timeline, fieldStyle);
List<MatchEvent> timelineInterpolatedRedNormalized(FieldStyle fieldStyle) =>
_normalizeRed(timelineInterpolated, fieldStyle);
//TODO this is bad code
List<MatchEvent> timelineBlueNormalized(FieldStyle fieldStyle) =>
_normalizeBlue(timeline, fieldStyle);
List<MatchEvent> timelineInterpolatedBlueNormalized(FieldStyle fieldStyle) =>
_normalizeBlue(timelineInterpolated, fieldStyle);

//internal function to normalize the timeline as red.
List<MatchEvent> _normalizeRed(
List<MatchEvent> _normalizeBlue(
List<MatchEvent> events,
FieldStyle fieldStyle,
) {
if (alliance == Alliance.blue) {
if (alliance == Alliance.red) {
return List.generate(events.length, (index) {
final MatchEvent event = events[index];
final FieldPosition position = fieldStyle == FieldStyle.rotated
Expand Down
6 changes: 3 additions & 3 deletions snout_db/lib/fieldposition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import 'package:meta/meta.dart';
/// Positive X is towards the opposing alliance.
/// Positive Y is along the alliance wall
/// Map is the field boundry.
/// Position is relative to red alliance unless otherwise specified
/// Position is relative to blue alliance unless otherwise specified
/// in this situation -1, -1 is the bottom left corner where the field is between
/// the viewer and the admin. -1, 0 is about where red 2 drivers station is.
/// and 1,0 is where blue 2 is
/// the viewer and the admin. -1, 0 is about where blue 2 drivers station is.
/// and 1,0 is where red 2 driver station is
/// the values are rounded to a realistic accuracy
@immutable
class FieldPosition {
Expand Down

0 comments on commit 18eeaaa

Please sign in to comment.