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

Commit 619bf9b

Browse files
committed
Begin writing AutoMoveTo
1 parent aa0924c commit 619bf9b

3 files changed

Lines changed: 76 additions & 30 deletions

File tree

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

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import java.util.Map;
66

77
public class AutoUtils {
8-
8+
private static double currX;
9+
private static double currY;
10+
private static double currRotation;
911
/**
1012
* Parses the inputted script file into a map of scripts
1113
*
@@ -74,6 +76,36 @@ public static Map<String, ArrayList<String[]>> parseScriptFile(String scriptFile
7476
return autoScripts;
7577
}
7678

79+
/*
80+
* All of these are getters and setters for the robot's position and orientation
81+
*/
82+
public static double getX() {
83+
return currX;
84+
}
85+
public static double getY() {
86+
return currY;
87+
}
88+
public static double getRot() {
89+
return currRotation;
90+
}
91+
public static void setX(double x) {
92+
currX = x;
93+
}
94+
public static void setY(double y) {
95+
currY = y;
96+
}
97+
public static void setRot(double rot) {
98+
currRotation = rot;
99+
}
100+
public static void changeX(double x) {
101+
currX += x;
102+
}
103+
public static void changeY(double y) {
104+
currY += y;
105+
}
106+
public static void changeRot(double rot) {
107+
currRotation += rot;
108+
}
77109

78110
/**
79111
* Validates the command inputted to see if it's AAA compliant
@@ -210,7 +242,7 @@ private static boolean isPoint (String s) {
210242
* @param s the argument
211243
* @return if the argument is a double
212244
*/
213-
private static boolean isDouble (String s) {
245+
public static boolean isDouble (String s) {
214246
try {
215247
Double.parseDouble(s);
216248
} catch (Exception e) {
Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,43 @@
11
package org.usfirst.frc.team199.Robot2018.commands;
22

3-
import edu.wpi.first.wpilibj.command.Command;
3+
import org.usfirst.frc.team199.Robot2018.autonomous.AutoUtils;
4+
5+
//import org.usfirst.frc.team199.Robot2018.subsystems.Drivetrain;
6+
7+
import edu.wpi.first.wpilibj.command.CommandGroup;
48

59
/**
610
*
711
*/
8-
public class AutoMoveTo extends Command {
9-
10-
public AutoMoveTo(String[] points) {
11-
// Use requires() here to declare subsystem dependencies
12-
// eg. requires(chassis);
13-
}
14-
15-
// Called just before this Command runs the first time
16-
protected void initialize() {
17-
}
18-
19-
// Called repeatedly when this Command is scheduled to run
20-
protected void execute() {
21-
}
22-
23-
// Make this return true when this Command no longer needs to run execute()
24-
protected boolean isFinished() {
25-
return false;
26-
}
27-
28-
// Called once after isFinished returns true
29-
protected void end() {
30-
}
31-
32-
// Called when another command which requires one or more of the same
33-
// subsystems is scheduled to run
34-
protected void interrupted() {
12+
public class AutoMoveTo extends CommandGroup {
13+
14+
public AutoMoveTo(String[] args) {
15+
//requires(Drivetrain);
16+
double rotation;
17+
double[] point;
18+
for (String arg : args) {
19+
if (AutoUtils.isDouble(arg)) {
20+
rotation = Double.valueOf(arg);
21+
}
22+
}
23+
24+
25+
26+
// Add Commands here:
27+
// e.g. addSequential(new Command1());
28+
// addSequential(new Command2());
29+
// these will run in order.
30+
31+
// To run multiple commands at the same time,
32+
// use addParallel()
33+
// e.g. addParallel(new Command1());
34+
// addSequential(new Command2());
35+
// Command1 and Command2 will run in parallel.
36+
37+
// A command group will require all of the subsystems that each member
38+
// would require.
39+
// e.g. if Command1 requires chassis, and Command2 requires arm,
40+
// a CommandGroup containing them would require both the chassis and the
41+
// arm.
3542
}
3643
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/subsystems/Drivetrain.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,11 @@ public void shiftGears(boolean highGear) {
231231
public void shiftGearSolenoidOff() {
232232
dtGear.set(DoubleSolenoid.Value.kOff);
233233
}
234+
/**
235+
* Returns the gyroscope
236+
* @return the gyroscope
237+
*/
238+
public AHRS getGyro() {
239+
return fancyGyro;
240+
}
234241
}

0 commit comments

Comments
 (0)