Skip to content
This repository was archived by the owner on Sep 14, 2019. It is now read-only.

Commit 4c09946

Browse files
committed
rename Position class to State
1 parent 6f11de6 commit 4c09946

6 files changed

Lines changed: 29 additions & 29 deletions

File tree

Robot2018/src/org/usfirst/frc/team199/Robot2018/Robot.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.util.Map;
1313

1414
import org.usfirst.frc.team199.Robot2018.autonomous.AutoUtils;
15-
import org.usfirst.frc.team199.Robot2018.autonomous.Position;
15+
import org.usfirst.frc.team199.Robot2018.autonomous.State;
1616
import org.usfirst.frc.team199.Robot2018.commands.Autonomous;
1717
import org.usfirst.frc.team199.Robot2018.commands.Autonomous.Strategy;
1818
import org.usfirst.frc.team199.Robot2018.commands.ShiftLowGear;
@@ -166,7 +166,7 @@ public void disabledPeriodic() {
166166
@Override
167167
public void autonomousInit() {
168168
dt.resetAHRS();
169-
AutoUtils.position = new Position(0, 0, 0);
169+
AutoUtils.state = new State(0, 0, 0);
170170
Scheduler.getInstance().add(new ShiftLowGear());
171171
String fmsInput = DriverStation.getInstance().getGameSpecificMessage();
172172
Autonomous.Position startPos = posChooser.getSelected();

Robot2018/src/org/usfirst/frc/team199/Robot2018/autonomous/AutoUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public class AutoUtils {
88

9-
public static Position position;
9+
public static State state;
1010

1111
/**
1212
* Parses the inputted script file into a map of scripts

Robot2018/src/org/usfirst/frc/team199/Robot2018/autonomous/Position.java renamed to Robot2018/src/org/usfirst/frc/team199/Robot2018/autonomous/State.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package org.usfirst.frc.team199.Robot2018.autonomous;
22

3-
public class Position {
3+
public class State {
44
private double currX;
55
private double currY;
66
private double currRotation;
77

8-
public Position(double x, double y, double rot) {
8+
public State(double x, double y, double rot) {
99
currX = x;
1010
currY = y;
1111
currRotation = rot;

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/PIDMove.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ public PIDMove(double[] point, DrivetrainInterface dt, SmartDashboardInterface s
9494
*/
9595
@Override
9696
public void initialize() {
97-
double dx = pointX - AutoUtils.position.getX();
98-
double dy = pointY - AutoUtils.position.getY();
97+
double dx = pointX - AutoUtils.state.getX();
98+
double dy = pointY - AutoUtils.state.getY();
9999

100100
double dist = Math.sqrt(dx * dx + dy * dy); // pythagorean theorem to find distance
101101
this.target = dist;
@@ -151,15 +151,15 @@ protected void end() {
151151
System.out.println("End");
152152
// moveController.free();
153153

154-
double angle = Math.toRadians(AutoUtils.position.getRot());
154+
double angle = Math.toRadians(AutoUtils.state.getRot());
155155
double dist = avg.pidGet();
156156
// x and y are switched because we are using bearings
157157
double y = Math.cos(angle) * dist;
158158
double x = Math.sin(angle) * dist;
159-
AutoUtils.position.changeX(x);
160-
AutoUtils.position.changeY(y);
159+
AutoUtils.state.changeX(x);
160+
AutoUtils.state.changeY(y);
161161

162-
AutoUtils.position.setRot(dt.getAHRSAngle());
162+
AutoUtils.state.setRot(dt.getAHRSAngle());
163163
}
164164

165165
/**

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/PIDTurn.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,18 @@ protected void initialize() {
144144

145145
if (!turnToPoint) {
146146
if (absoluteRotation) {
147-
target -= AutoUtils.position.getRot();
147+
target -= AutoUtils.state.getRot();
148148
}
149149
} else {
150-
double dx = pointX - AutoUtils.position.getX();
151-
double dy = pointY - AutoUtils.position.getY();
150+
double dx = pointX - AutoUtils.state.getX();
151+
double dy = pointY - AutoUtils.state.getY();
152152

153153
System.out.println("x = " + dx + ", y = " + dy);
154154

155155
// x and y are switched because we are using bearings
156156
double absTurn = Math.toDegrees(Math.atan2(dx, dy));
157-
target = absTurn - AutoUtils.position.getRot();
158-
System.out.println("current bearing = " + AutoUtils.position.getRot());
157+
target = absTurn - AutoUtils.state.getRot();
158+
System.out.println("current bearing = " + AutoUtils.state.getRot());
159159
System.out.println("target bearing = " + target);
160160
}
161161

@@ -232,7 +232,7 @@ protected void end() {
232232
sd.putNumber("Turn PID Error", turnController.getError());
233233
// turnController.free();
234234

235-
AutoUtils.position.setRot(dt.getAHRSAngle());
235+
AutoUtils.state.setRot(dt.getAHRSAngle());
236236
}
237237

238238
/**

Robot2018/test/org/usfirst/frc/team199/Robot2018/AutoMoveToTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ protected boolean isFinished() {
9191
void testForwardAndRight() {
9292
String[] args = { "(0,12)", "(12,12)" };
9393

94-
AutoUtils.position.setRot(0);
95-
AutoUtils.position.setX(0);
96-
AutoUtils.position.setY(0);
94+
AutoUtils.state.setRot(0);
95+
AutoUtils.state.setX(0);
96+
AutoUtils.state.setY(0);
9797

9898
PIDSource pidGyroSrc = mock(PIDSource.class);
9999
when(pidGyroSrc.getPIDSourceType()).thenReturn(PIDSourceType.kDisplacement);
@@ -104,18 +104,18 @@ void testForwardAndRight() {
104104

105105
AutoMoveTo testAMT = new AutoMoveTo(args, dt, sd, pidMoveSrc, pidGyroSrc);
106106

107-
assertEquals(90, AutoUtils.position.getRot());
108-
assertEquals(12, AutoUtils.position.getX());
109-
assertEquals(12, AutoUtils.position.getY());
107+
assertEquals(90, AutoUtils.state.getRot());
108+
assertEquals(12, AutoUtils.state.getX());
109+
assertEquals(12, AutoUtils.state.getY());
110110
}
111111

112112
@Test
113113
void testForward() {
114114
String[] args = { "(0,12)" };
115115

116-
AutoUtils.position.setRot(0);
117-
AutoUtils.position.setX(0);
118-
AutoUtils.position.setY(0);
116+
AutoUtils.state.setRot(0);
117+
AutoUtils.state.setX(0);
118+
AutoUtils.state.setY(0);
119119

120120
PIDSource pidGyroSrc = mock(PIDSource.class);
121121
when(pidGyroSrc.getPIDSourceType()).thenReturn(PIDSourceType.kDisplacement);
@@ -126,8 +126,8 @@ void testForward() {
126126

127127
AutoMoveTo testAMT = new AutoMoveTo(args, dt, sd, pidMoveSrc, pidGyroSrc);
128128

129-
assertEquals(0, AutoUtils.position.getRot());
130-
assertEquals(0, AutoUtils.position.getX());
131-
assertEquals(12, AutoUtils.position.getY());
129+
assertEquals(0, AutoUtils.state.getRot());
130+
assertEquals(0, AutoUtils.state.getX());
131+
assertEquals(12, AutoUtils.state.getY());
132132
}
133133
}

0 commit comments

Comments
 (0)