Skip to content

Commit 0357b72

Browse files
author
Noah Gleason
authored
Merge pull request #72 from blair-robot-project/oneline_defaults
Oneline defaults
2 parents 1a52c46 + 39768d2 commit 0357b72

File tree

15 files changed

+63
-86
lines changed

15 files changed

+63
-86
lines changed

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/Robot.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ public void robotInit() {
230230
robotMap.getRightProfiles().get(allianceString + "_" + position));
231231
//Set the autonomousCommand to be the correct command for the current position and alliance.
232232
if (position.equals("center")) {
233-
autonomousCommand = robotMap.getCenterAuto().getCommand();
233+
autonomousCommand = robotMap.getCenterAuto();
234234
} else if ((position.equals("right") && redAlliance) || (position.equals("left") && !redAlliance)) {
235-
autonomousCommand = robotMap.getBoilerAuto().getCommand();
235+
autonomousCommand = robotMap.getBoilerAuto();
236236
} else {
237-
autonomousCommand = robotMap.getFeederAuto().getCommand();
237+
autonomousCommand = robotMap.getFeederAuto();
238238
}
239239
}
240240
} else {

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/RobotMap.java

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class RobotMap {
3535
private final TalonClusterDrive drive;
3636

3737
@NotNull
38-
private final UnidirectionalNavXDefaultDrive defaultDriveCommand;
38+
private final Command defaultDriveCommand;
3939

4040
@Nullable
4141
private final ClimberSubsystem climber;
@@ -71,13 +71,13 @@ public class RobotMap {
7171
private final MappedDigitalInput locationDial;
7272

7373
@Nullable
74-
private final YamlCommand boilerAuto;
74+
private final Command boilerAuto;
7575

7676
@Nullable
77-
private final YamlCommand centerAuto;
77+
private final Command centerAuto;
7878

7979
@Nullable
80-
private final YamlCommand feederAuto;
80+
private final Command feederAuto;
8181

8282
@Nullable
8383
private final MotionProfileData leftTestProfile;
@@ -116,37 +116,21 @@ public class RobotMap {
116116
* @param gearHandler The gear handler on this robot. Can be null.
117117
* @param RIOduinoPort The I2C port of the RIOduino plugged into this robot. Can be null.
118118
* @param allianceSwitch The switch for selecting which alliance we're on. Can be null if doMP is false or
119-
* testMP
120-
* is true, but otherwise must have a value.
121-
* @param dropGearSwitch The switch for deciding whether or not to drop the gear. Can be null if doMP is false
122-
* or
123119
* testMP is true, but otherwise must have a value.
124-
* @param locationDial The dial for selecting which side of the field the robot is on. Can be null if doMP
125-
* is
126-
* false or testMP is true, but otherwise must have a value.
127-
* @param boilerAuto The command to run in autonomous on the boiler side of the field. Can be null if doMP
128-
* is
129-
* false or testMP is true, but otherwise must have a value.
130-
* @param centerAuto The command to run in autonomous on the center of the field. Can be null if doMP is
131-
* false
120+
* @param dropGearSwitch The switch for deciding whether or not to drop the gear. Can be null if doMP is false
132121
* or testMP is true, but otherwise must have a value.
133-
* @param feederAuto The command to run in autonomous on the feeding station side of the field. Can be
134-
* null
135-
* if
136-
* doMP is false or testMP is true, but otherwise must have a value.
122+
* @param locationDial The dial for selecting which side of the field the robot is on. Can be null if doMP is false or testMP is true, but otherwise must have a value.
123+
* @param boilerAuto The command to run in autonomous on the boiler side of the field. Can be null if doMP is false or testMP is true, but otherwise must have a value.
124+
* @param centerAuto The command to run in autonomous on the center of the field. Can be null if doMP is
125+
* false or testMP is true, but otherwise must have a value.
126+
* @param feederAuto The command to run in autonomous on the feeding station side of the field. Can be null if doMP is false or testMP is true, but otherwise must have a value.
137127
* @param leftTestProfile The profile for the left side of the drive to run in test mode. Can be null if either
138128
* testMP or doMP are false, but otherwise must have a value.
139-
* @param rightTestProfile The profile for the right side of the drive to run in test mode. Can be null if
140-
* either
141-
* testMP or doMP are false, but otherwise must have a value.
129+
* @param rightTestProfile The profile for the right side of the drive to run in test mode. Can be null if either testMP or doMP are false, but otherwise must have a value.
142130
* @param leftProfiles The starting position to peg profiles for the left side. Should have options for
143-
* "red_right", "red_center", "red_left", "blue_right", "blue_center", and "blue_left".
144-
* Can
145-
* be null if doMP is false or testMP is true, but otherwise must have a value.
131+
* "red_right", "red_center", "red_left", "blue_right", "blue_center", and "blue_left". Can be null if doMP is false or testMP is true, but otherwise must have a value.
146132
* @param rightProfiles The starting position to peg profiles for the right side. Should have options for
147-
* "red_right", "red_center", "red_left", "blue_right", "blue_center", and "blue_left".
148-
* Can
149-
* be null if doMP is false or testMP is true, but otherwise must have a value.
133+
* "red_right", "red_center", "red_left", "blue_right", "blue_center", and "blue_left". Can be null if doMP is false or testMP is true, but otherwise must have a value.
150134
* @param nonMPAutoCommand The command to run during autonomous if doMP is false. Can be null, and if it is, no
151135
* command is run during autonomous.
152136
* @param testMP Whether to run the test or real motion profile during autonomous. Defaults to false.
@@ -157,7 +141,7 @@ public RobotMap(@NotNull @JsonProperty(required = true) List<CommandButton> butt
157141
@NotNull @JsonProperty(required = true) ArcadeOIWithDPad arcadeOI,
158142
@NotNull @JsonProperty(required = true) Logger logger,
159143
@NotNull @JsonProperty(required = true) TalonClusterDrive drive,
160-
@NotNull @JsonProperty(required = true) UnidirectionalNavXDefaultDrive defaultDriveCommand,
144+
@NotNull @JsonProperty(required = true) YamlCommand defaultDriveCommand,
161145
@Nullable ClimberSubsystem climber,
162146
@Nullable SingleFlywheelShooter shooter,
163147
@Nullable CameraSubsystem camera,
@@ -190,14 +174,14 @@ public RobotMap(@NotNull @JsonProperty(required = true) List<CommandButton> butt
190174
this.allianceSwitch = allianceSwitch;
191175
this.dropGearSwitch = dropGearSwitch;
192176
this.locationDial = locationDial;
193-
this.boilerAuto = boilerAuto;
194-
this.centerAuto = centerAuto;
195-
this.feederAuto = feederAuto;
177+
this.boilerAuto = boilerAuto != null ? boilerAuto.getCommand() : null;
178+
this.centerAuto = centerAuto != null ? centerAuto.getCommand() : null;
179+
this.feederAuto = feederAuto != null ? feederAuto.getCommand() : null;
196180
this.leftTestProfile = leftTestProfile;
197181
this.rightTestProfile = rightTestProfile;
198182
this.leftProfiles = leftProfiles;
199183
this.rightProfiles = rightProfiles;
200-
this.defaultDriveCommand = defaultDriveCommand;
184+
this.defaultDriveCommand = defaultDriveCommand.getCommand();
201185
if (nonMPAutoCommand != null) {
202186
this.nonMPAutoCommand = nonMPAutoCommand.getCommand();
203187
} else {
@@ -299,17 +283,17 @@ public Map<String, MotionProfileData> getRightProfiles() {
299283
}
300284

301285
@Nullable
302-
public YamlCommand getBoilerAuto() {
286+
public Command getBoilerAuto() {
303287
return boilerAuto;
304288
}
305289

306290
@Nullable
307-
public YamlCommand getCenterAuto() {
291+
public Command getCenterAuto() {
308292
return centerAuto;
309293
}
310294

311295
@Nullable
312-
public YamlCommand getFeederAuto() {
296+
public Command getFeederAuto() {
313297
return feederAuto;
314298
}
315299

@@ -319,7 +303,7 @@ public Command getNonMPAutoCommand() {
319303
}
320304

321305
@NotNull
322-
public UnidirectionalNavXDefaultDrive getDefaultDriveCommand() {
306+
public Command getDefaultDriveCommand() {
323307
return defaultDriveCommand;
324308
}
325309

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/components/MappedSmoothedThrottle.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,25 @@
1111
@JsonIdentityInfo(generator = ObjectIdGenerators.StringIdGenerator.class)
1212
public class MappedSmoothedThrottle extends MappedThrottle {
1313

14+
/**
15+
* The value below which the joystick input is considered 0.
16+
*/
1417
protected final double deadband;
1518

19+
/**
20+
* The smoothing filter for the joystick input.
21+
*/
22+
@NotNull
1623
private final LinearDigitalFilter filter;
1724

25+
/**
26+
* The input from the joystick. Declared outside of getValue to avoid garbage collection.
27+
*/
1828
private double input;
1929

30+
/**
31+
* The sign of the input from the joystick. Declared outside of getValue to avoid garbage collection.
32+
*/
2033
private double sign;
2134

2235
/**

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/components/RotPerSecCANTalonSRX.java

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -213,20 +213,12 @@ public RotPerSecCANTalonSRX(@JsonProperty(required = true) int port,
213213
//Set high/only gear nominal voltages
214214
this.highGearFwdNominalOutputVoltage = highGearFwdNominalOutputVoltage;
215215
//If no reverse nominal voltage is given, assume symmetry.
216-
if (highGearRevNominalOutputVoltage == null) {
217-
this.highGearRevNominalOutputVoltage = highGearFwdNominalOutputVoltage;
218-
} else {
219-
this.highGearRevNominalOutputVoltage = highGearRevNominalOutputVoltage;
220-
}
216+
this.highGearRevNominalOutputVoltage = highGearRevNominalOutputVoltage != null ? highGearRevNominalOutputVoltage : highGearFwdNominalOutputVoltage;
221217

222218
//Set low gear nominal voltages
223219
this.lowGearFwdNominalOutputVoltage = lowGearFwdNominalOutputVoltage;
224220
//If no reverse nominal voltage is given, assume symmetry.
225-
if (lowGearRevNominalOutputVoltage == null) {
226-
this.lowGearRevNominalOutputVoltage = lowGearFwdNominalOutputVoltage;
227-
} else {
228-
this.lowGearRevNominalOutputVoltage = lowGearRevNominalOutputVoltage;
229-
}
221+
this.lowGearRevNominalOutputVoltage = lowGearRevNominalOutputVoltage != null ? lowGearRevNominalOutputVoltage : lowGearFwdNominalOutputVoltage;
230222

231223
//Set to high gear by default.
232224
canTalon.configNominalOutputVoltage(this.highGearFwdNominalOutputVoltage, -this.highGearRevNominalOutputVoltage);
@@ -269,17 +261,10 @@ public RotPerSecCANTalonSRX(@JsonProperty(required = true) int port,
269261
}
270262

271263
//postEncoderGearing defaults to 1
272-
if (postEncoderGearing == null) {
273-
this.postEncoderGearing = 1.;
274-
} else {
275-
this.postEncoderGearing = postEncoderGearing;
276-
}
264+
this.postEncoderGearing = postEncoderGearing != null ? postEncoderGearing : 1.;
277265

278266
//Configure the maximum output voltage. If only forward voltage was given, use it for both forward and reverse.
279-
if (revPeakOutputVoltage == null) {
280-
revPeakOutputVoltage = fwdPeakOutputVoltage;
281-
}
282-
canTalon.configPeakOutputVoltage(fwdPeakOutputVoltage, -revPeakOutputVoltage);
267+
canTalon.configPeakOutputVoltage(fwdPeakOutputVoltage, revPeakOutputVoltage != null ? -revPeakOutputVoltage : -fwdPeakOutputVoltage);
283268

284269
//Set the current limit if it was given
285270
if (currentLimit != null) {

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/drive/talonCluster/ShiftingTalonClusterDrive.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ public ShiftingTalonClusterDrive(@NotNull @JsonProperty(required = true) RotPerS
6767
this.shifter = shifter;
6868

6969
//Default to low
70-
if (startingGear == null) {
71-
this.startingGear = gear.LOW;
72-
} else {
73-
this.startingGear = startingGear;
74-
}
70+
this.startingGear = startingGear != null ? startingGear : gear.LOW;
7571
currentGear = this.startingGear;
7672

7773
// Initialize shifting constants, assuming robot is stationary.

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/drive/talonCluster/TalonClusterDrive.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ public TalonClusterDrive(@NotNull @JsonProperty(required = true) RotPerSecCANTal
7575
@Nullable Double PIDScale) {
7676
super();
7777
//Initialize stuff
78-
if (PIDScale == null) {
79-
PIDScale = 1.;
80-
}
81-
PID_SCALE = PIDScale;
78+
this.PID_SCALE = PIDScale != null ? PIDScale : 1.;
8279
this.rightMaster = rightMaster;
8380
this.leftMaster = leftMaster;
8481
this.mpHandler = MPHandler;

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/drive/talonCluster/commands/UnidirectionalNavXDefaultDrive.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ public UnidirectionalNavXDefaultDrive(@JsonProperty(required = true) double abso
9090
this.subsystem = subsystem;
9191

9292
driveStraightLoopEntryTimer = new BufferTimer(loopEntryDelay);
93-
if (maxAngularVelToEnterLoop == null) {
94-
maxAngularVelToEnterLoop = 180.;
95-
}
96-
this.maxAngularVelToEnterLoop = maxAngularVelToEnterLoop;
93+
this.maxAngularVelToEnterLoop = maxAngularVelToEnterLoop != null ? maxAngularVelToEnterLoop : 180;
9794

9895
//Needs a requires because it's a default command.
9996
requires(this.subsystem);

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/interfaces/subsystem/NavX/commands/PIDAngleCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public PIDAngleCommand(@JsonProperty(required = true) double absoluteTolerance,
8989
//This caps the output we can give. One way to set up closed-loop is to make P large and then use this to
9090
// prevent overshoot.
9191
if (maximumOutput != null) {
92-
this.getPIDController().setOutputRange(-minimumOutput, maximumOutput);
92+
this.getPIDController().setOutputRange(-maximumOutput, maximumOutput);
9393
}
9494

9595
//Set a deadband around the setpoint, in degrees, within which don't move, to avoid "dancing"

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/mechanism/climber/commands/RunMotorWhileConditonMet.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class RunMotorWhileConditonMet <T extends YamlSubsystem & BinaryMotorSubs
3232
public RunMotorWhileConditonMet(@NotNull @JsonProperty(required = true) T subsystem) {
3333
requires(subsystem);
3434
this.subsystem = subsystem;
35-
Logger.addEvent("RunMotorWhileConditonMet constructed", this.getClass());
3635
}
3736

3837
/**

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/mechanism/pneumatics/PneumaticsSubsystem.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public class PneumaticsSubsystem extends YamlSubsystem implements Loggable {
3838
@JsonCreator
3939
public PneumaticsSubsystem(@JsonProperty(required = true) int nodeID,
4040
@Nullable PressureSensor pressureSensor) {
41-
super();
4241
compressor = new Compressor(nodeID);
4342
this.pressureSensor = pressureSensor;
4443
}

0 commit comments

Comments
 (0)