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

Commit e9db79e

Browse files
committed
Add autonomous interfaces to implement
Added: - commands/Autonomous.java - commands/RunAuto.java - commands/TestAuto.java - and their respective interfaces now we can assign trello cards to people to implement the interfaces
1 parent c9ceaa3 commit e9db79e

7 files changed

Lines changed: 290 additions & 0 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
*
3+
*/
4+
package org.usfirst.frc.team199.Robot2018;
5+
6+
import edu.wpi.first.wpilibj.Sendable;
7+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
8+
9+
/**
10+
*
11+
* Will be able to: - display a value on smartdashboard with particular key and
12+
* object value, - modify key so that it can be used by dashboard widget - get a
13+
* value of particular type, accessing SmartDashboard as would be expected
14+
* except with a different key - two methods for each kind of getting, with and
15+
* without default values
16+
*
17+
*/
18+
19+
public interface DashboardInterface {
20+
21+
/**
22+
* Puts all desired data on SmartDashboard
23+
*/
24+
public default void displayData() {
25+
26+
}
27+
28+
/*
29+
* Methods for displaying values with modified keys
30+
*/
31+
default void putNumber(String key, double value) {
32+
SmartDashboard.putNumber(getKey(key), value);
33+
}
34+
35+
default void putBoolean(String key, boolean value) {
36+
SmartDashboard.putBoolean(getKey(key), value);
37+
}
38+
39+
default void putString(String key, String value) {
40+
SmartDashboard.putString(getKey(key), value);
41+
}
42+
43+
default void putSendable(String key, Sendable value) {
44+
SmartDashboard.putData(getKey(key), value);
45+
}
46+
47+
/*
48+
* Methods for reading numbers, without specifying the modified key
49+
*/
50+
default double getNumber(String key, double defaultValue) {
51+
return SmartDashboard.getNumber(getKey(key), defaultValue);
52+
}
53+
54+
default boolean getBoolean(String key, boolean defaultValue) {
55+
return SmartDashboard.getBoolean(getKey(key), defaultValue);
56+
}
57+
58+
default String getString(String key, String defaultValue) {
59+
return SmartDashboard.getString(getKey(key), defaultValue);
60+
}
61+
62+
default double[] getNumArray(String key, double[] defaultValue) {
63+
return SmartDashboard.getNumberArray(getKey(key), defaultValue);
64+
}
65+
66+
/**
67+
* Converts the specified display key into one with its subsystem name
68+
* appended as a prefix, to be compatible with the Subsystem widget on
69+
* SmartDashboard for organizational purposes
70+
*
71+
* @param key - The name of the original key
72+
* @return A modified key with prefix subsystem name
73+
*/
74+
default String getKey(String key) {
75+
return getClass().getSimpleName() + "/" + key;
76+
}
77+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package org.usfirst.frc.team199.Robot2018.commands;
2+
3+
import edu.wpi.first.wpilibj.command.CommandGroup;
4+
5+
/**
6+
* Initially run during Auto. Responsible for getting input from SmartDashboard
7+
* and the FMS, and then calling RunAuto with the specified script.
8+
*/
9+
public class Autonomous extends CommandGroup implements AutonomousInterface {
10+
11+
public Autonomous() {
12+
// TODO
13+
14+
// Add Commands here:
15+
// e.g. addSequential(new Command1());
16+
// addSequential(new Command2());
17+
// these will run in order.
18+
19+
// To run multiple commands at the same time,
20+
// use addParallel()
21+
// e.g. addParallel(new Command1());
22+
// addSequential(new Command2());
23+
// Command1 and Command2 will run in parallel.
24+
25+
// A command group will require all of the subsystems that each member
26+
// would require.
27+
// e.g. if Command1 requires chassis, and Command2 requires arm,
28+
// a CommandGroup containing them would require both the chassis and the
29+
// arm.
30+
}
31+
32+
@Override
33+
/**
34+
* {@inheritDoc}
35+
*/
36+
public Position getStartingPos() {
37+
// TODO
38+
return null;
39+
}
40+
41+
@Override
42+
/**
43+
* {@inheritDoc}
44+
*/
45+
public Strategy[] getStrategies() {
46+
// TODO
47+
return null;
48+
}
49+
50+
@Override
51+
/**
52+
* {@inheritDoc}
53+
*/
54+
public double getDelay() {
55+
// TODO
56+
return 0;
57+
}
58+
59+
@Override
60+
/**
61+
* {@inheritDoc}
62+
*/
63+
public String pickScript() {
64+
// TODO
65+
return null;
66+
}
67+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package org.usfirst.frc.team199.Robot2018.commands;
2+
3+
import org.usfirst.frc.team199.Robot2018.DashboardInterface;
4+
5+
import edu.wpi.first.wpilibj.DriverStation;
6+
7+
public interface AutonomousInterface extends DashboardInterface{
8+
public enum Position {
9+
LEFT,
10+
CENTER,
11+
RIGHT
12+
}
13+
14+
public enum Strategy {
15+
AUTO_LINE,
16+
SWITCH,
17+
SCALE,
18+
EXCHANGE,
19+
SWITCH_SCALE,
20+
SWITCH_EXCHANGE,
21+
NOTHING
22+
}
23+
24+
/**
25+
* Gets the starting position set in SmartDashboard
26+
*
27+
* @return an enum for the starting position
28+
*/
29+
public Position getStartingPos();
30+
31+
/**
32+
* Gets the four strategies set in SmartDashboard
33+
*
34+
* @return 4 strategies, in the order of (Switch + Scale ): LL, LR, RR, RL
35+
*/
36+
public Strategy[] getStrategies();
37+
38+
/**
39+
* Gets delay before running the specified script set in SmartDashboard
40+
*
41+
* @return delay in seconds
42+
*/
43+
public double getDelay();
44+
45+
/**
46+
* Directly gets the string from FMS
47+
*
48+
* @return FMS data
49+
*/
50+
default String getFMS() {
51+
return DriverStation.getInstance().getGameSpecificMessage();
52+
}
53+
54+
/**
55+
* Pick the script to run for Autonomous
56+
*
57+
* @return A String representing the name of the script
58+
*/
59+
public String pickScript();
60+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.usfirst.frc.team199.Robot2018.commands;
2+
3+
import edu.wpi.first.wpilibj.command.CommandGroup;
4+
5+
/**
6+
* Gets the script name and runs the script.
7+
*/
8+
public class RunAuto extends CommandGroup implements RunAutoInterface {
9+
10+
public RunAuto(String scriptName) {
11+
// TODO
12+
13+
// Add Commands here:
14+
// e.g. addSequential(new Command1());
15+
// addSequential(new Command2());
16+
// these will run in order.
17+
18+
// To run multiple commands at the same time,
19+
// use addParallel()
20+
// e.g. addParallel(new Command1());
21+
// addSequential(new Command2());
22+
// Command1 and Command2 will run in parallel.
23+
24+
// A command group will require all of the subsystems that each member
25+
// would require.
26+
// e.g. if Command1 requires chassis, and Command2 requires arm,
27+
// a CommandGroup containing them would require both the chassis and the
28+
// arm.
29+
}
30+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.usfirst.frc.team199.Robot2018.commands;
2+
3+
public interface RunAutoInterface {
4+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.usfirst.frc.team199.Robot2018.commands;
2+
3+
import edu.wpi.first.wpilibj.command.CommandGroup;
4+
5+
/**
6+
* Used for testing the autonomous interfaces. Runs the script specified in
7+
* SmartDashboard
8+
*/
9+
public class TestAuto extends CommandGroup implements TestAutoInterface {
10+
11+
public TestAuto() {
12+
// TODO
13+
14+
// Add Commands here:
15+
// e.g. addSequential(new Command1());
16+
// addSequential(new Command2());
17+
// these will run in order.
18+
19+
// To run multiple commands at the same time,
20+
// use addParallel()
21+
// e.g. addParallel(new Command1());
22+
// addSequential(new Command2());
23+
// Command1 and Command2 will run in parallel.
24+
25+
// A command group will require all of the subsystems that each member
26+
// would require.
27+
// e.g. if Command1 requires chassis, and Command2 requires arm,
28+
// a CommandGroup containing them would require both the chassis and the
29+
// arm.
30+
}
31+
32+
@Override
33+
/**
34+
* {@inheritDoc}
35+
*/
36+
public String getScriptToTest() {
37+
// TODO
38+
return null;
39+
}
40+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.usfirst.frc.team199.Robot2018.commands;
2+
3+
import org.usfirst.frc.team199.Robot2018.DashboardInterface;
4+
5+
public interface TestAutoInterface extends DashboardInterface {
6+
/**
7+
* gets the script name that we want to run from SmartDashboard
8+
*
9+
* @return the script name
10+
*/
11+
public String getScriptToTest();
12+
}

0 commit comments

Comments
 (0)