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

Commit 99b6970

Browse files
committed
Implement Autonomous command
also removed unneccesary functions in AutonomousInterface, and moved SmartDashboard input to autoInit (not written yet)
1 parent 0acd631 commit 99b6970

2 files changed

Lines changed: 34 additions & 113 deletions

File tree

Lines changed: 34 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,47 @@
11
package org.usfirst.frc.team199.Robot2018.commands;
22

3+
import java.util.Map;
4+
35
import edu.wpi.first.wpilibj.DriverStation;
46
import edu.wpi.first.wpilibj.command.CommandGroup;
7+
import edu.wpi.first.wpilibj.command.WaitCommand;
58

69
/**
710
* Initially run during Auto. Responsible for getting input from SmartDashboard
811
* and the FMS, and then calling RunAuto with the specified script.
912
*/
1013
public class Autonomous extends CommandGroup implements AutonomousInterface {
1114

12-
public Autonomous() {
13-
// TODO
14-
15-
// Add Commands here:
16-
// e.g. addSequential(new Command1());
17-
// addSequential(new Command2());
18-
// these will run in order.
19-
20-
// To run multiple commands at the same time,
21-
// use addParallel()
22-
// e.g. addParallel(new Command1());
23-
// addSequential(new Command2());
24-
// Command1 and Command2 will run in parallel.
25-
26-
// A command group will require all of the subsystems that each member
27-
// would require.
28-
// e.g. if Command1 requires chassis, and Command2 requires arm,
29-
// a CommandGroup containing them would require both the chassis and the
30-
// arm.
15+
public Autonomous(String startPos, Map<String, String> strategies, double delay) {
16+
String scriptName = "";
17+
18+
scriptName += startPos.substring(0, 1);
19+
20+
String fmsInput = DriverStation.getInstance().getGameSpecificMessage();
21+
22+
String chosenStrat = strategies.get(fmsInput.substring(0, 2));
23+
24+
// skip the next steps if robot is chosen to do nothing
25+
if (chosenStrat.equals("Do nothing"))
26+
return;
27+
28+
// add switch, switch, and exchange location if going for them, "x" if not
29+
if (chosenStrat.contains("Switch"))
30+
scriptName += fmsInput.substring(0, 1);
31+
else
32+
scriptName += "x";
33+
34+
if (chosenStrat.contains("Scale"))
35+
scriptName += fmsInput.substring(1, 2);
36+
else
37+
scriptName += "x";
38+
39+
if (chosenStrat.contains("Exchange"))
40+
scriptName += "E";
41+
else
42+
scriptName += "x";
43+
44+
addSequential(new WaitCommand(delay));
45+
addSequential(new RunScript(scriptName));
3146
}
32-
33-
/**
34-
* {@inheritDoc}
35-
*/
36-
@Override
37-
public Position getStartingPos() {
38-
// TODO
39-
return null;
40-
}
41-
42-
/**
43-
* {@inheritDoc}
44-
*/
45-
@Override
46-
public Strategy[] getStrategies() {
47-
// TODO
48-
return null;
49-
}
50-
51-
/**
52-
* {@inheritDoc}
53-
*/
54-
@Override
55-
public double getDelay() {
56-
// TODO
57-
return 0;
58-
}
59-
60-
/**
61-
* {@inheritDoc}
62-
*/
63-
@Override
64-
public String getFMS() {
65-
return DriverStation.getInstance().getGameSpecificMessage();
66-
}
67-
68-
/**
69-
* {@inheritDoc}
70-
*/
71-
@Override
72-
public String pickScript() {
73-
// TODO
74-
return null;
75-
}
7647
}

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

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,4 @@
22

33

44
public interface AutonomousInterface {
5-
public enum Position {
6-
LEFT,
7-
CENTER,
8-
RIGHT
9-
}
10-
11-
public enum Strategy {
12-
AUTO_LINE,
13-
SWITCH,
14-
SCALE,
15-
EXCHANGE,
16-
SWITCH_SCALE,
17-
SWITCH_EXCHANGE,
18-
NOTHING
19-
}
20-
21-
/**
22-
* Gets the starting position set in SmartDashboard
23-
*
24-
* @return an enum for the starting position
25-
*/
26-
public Position getStartingPos();
27-
28-
/**
29-
* Gets the four strategies set in SmartDashboard
30-
*
31-
* @return 4 strategies, in the order of (Switch + Scale ): LL, LR, RR, RL
32-
*/
33-
public Strategy[] getStrategies();
34-
35-
/**
36-
* Gets delay before running the specified script set in SmartDashboard
37-
*
38-
* @return delay in seconds
39-
*/
40-
public double getDelay();
41-
42-
/**
43-
* Directly gets the string from FMS
44-
*
45-
* @return FMS data
46-
*/
47-
public String getFMS();
48-
49-
/**
50-
* Pick the script to run for Autonomous
51-
*
52-
* @return A String representing the name of the script
53-
*/
54-
public String pickScript();
555
}

0 commit comments

Comments
 (0)