Skip to content

Commit 6c69ce5

Browse files
author
Noah Gleason
committed
Cache field-oriented OI
1 parent d900242 commit 6c69ce5

File tree

58 files changed

+268
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+268
-293
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ public void robotInit() {
9292
try {
9393
//Read the yaml file with SnakeYaml so we can use anchors and merge syntax.
9494
// Map<?, ?> normalized = (Map<?, ?>) yaml.load(new FileReader(RESOURCES_PATH+"ballbasaur_map.yml"));
95-
Map<?, ?> normalized = (Map<?, ?>) yaml.load(new FileReader(RESOURCES_PATH + "naveen_map.yml"));
95+
// Map<?, ?> normalized = (Map<?, ?>) yaml.load(new FileReader(RESOURCES_PATH + "naveen_map.yml"));
9696
// Map<?, ?> normalized = (Map<?, ?>) yaml.load(new FileReader(RESOURCES_PATH + "nate_map.yml"));
97-
// Map<?, ?> normalized = (Map<?, ?>) yaml.load(new FileReader(RESOURCES_PATH + "calcifer_outreach_map.yml"));
97+
Map<?, ?> normalized = (Map<?, ?>) yaml.load(new FileReader(RESOURCES_PATH + "calcifer_outreach_map.yml"));
9898
YAMLMapper mapper = new YAMLMapper();
9999
//Turn the Map read by SnakeYaml into a String so Jackson can read it.
100100
String fixed = mapper.writeValueAsString(normalized);

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/commands/multiInterface/drive/FieldOrientedUnidirectionalDriveCommand.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import org.usfirst.frc.team449.robot.jacksonWrappers.YamlSubsystem;
99
import org.usfirst.frc.team449.robot.oi.fieldoriented.OIFieldOriented;
1010
import org.usfirst.frc.team449.robot.other.Logger;
11-
import org.usfirst.frc.team449.robot.subsystem.interfaces.navX.SubsystemAHRS;
12-
import org.usfirst.frc.team449.robot.subsystem.interfaces.navX.commands.PIDAngleCommand;
11+
import org.usfirst.frc.team449.robot.subsystem.interfaces.AHRS.SubsystemAHRS;
12+
import org.usfirst.frc.team449.robot.subsystem.interfaces.AHRS.commands.PIDAngleCommand;
1313

1414
import java.util.ArrayList;
1515
import java.util.List;
@@ -105,11 +105,7 @@ protected void initialize() {
105105
*/
106106
@Override
107107
protected void execute() {
108-
SmartDashboard.putBoolean("enabled",this.getPIDController().isEnabled());
109-
SmartDashboard.putNumber("NavX Error",this.getPIDController().getError());
110-
SmartDashboard.putNumber("kP",this.getPIDController().getP());
111-
//Do nothing
112-
theta = oi.getTheta();
108+
theta = oi.getThetaCached();
113109
if (theta != null) {
114110
for (AngularSnapPoint snapPoint : snapPoints) {
115111
//See if we should snap
@@ -164,7 +160,7 @@ protected void usePIDOutput(double output) {
164160
SmartDashboard.putNumber("PID loop output", output);
165161

166162
//Adjust the heading according to the PID output, it'll be positive if we want to go right.
167-
subsystem.setOutput(oi.getVel() - output, oi.getVel() + output);
163+
subsystem.setOutput(oi.getVelCached() - output, oi.getVelCached() + output);
168164
}
169165

170166
/**

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/commands/multiInterface/drive/FieldOrientedUnidirectionalDriveCommandShifting.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.usfirst.frc.team449.robot.jacksonWrappers.YamlSubsystem;
1111
import org.usfirst.frc.team449.robot.oi.fieldoriented.OIFieldOriented;
1212
import org.usfirst.frc.team449.robot.other.Logger;
13-
import org.usfirst.frc.team449.robot.subsystem.interfaces.navX.SubsystemAHRS;
13+
import org.usfirst.frc.team449.robot.subsystem.interfaces.AHRS.SubsystemAHRS;
1414

1515
import java.util.List;
1616

@@ -87,7 +87,7 @@ public FieldOrientedUnidirectionalDriveCommandShifting(@JsonProperty(required =
8787
@Override
8888
protected void execute() {
8989
if (!subsystem.getOverrideAutoshift()) {
90-
autoshiftComponent.autoshift(oi.getVel(), subsystem.getLeftVel(), subsystem.getRightVel(), gear -> subsystem.setGear(gear));
90+
autoshiftComponent.autoshift(oi.getVelCached(), subsystem.getLeftVelCached(), subsystem.getRightVelCached(), gear -> subsystem.setGear(gear));
9191
}
9292
super.execute();
9393
}

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/commands/multiInterface/drive/JiggleRobot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.usfirst.frc.team449.robot.drive.unidirectional.DriveUnidirectional;
1010
import org.usfirst.frc.team449.robot.jacksonWrappers.YamlCommandGroupWrapper;
1111
import org.usfirst.frc.team449.robot.jacksonWrappers.YamlSubsystem;
12-
import org.usfirst.frc.team449.robot.subsystem.interfaces.navX.SubsystemAHRS;
12+
import org.usfirst.frc.team449.robot.subsystem.interfaces.AHRS.SubsystemAHRS;
1313

1414
/**
1515
* Rotates the robot back and forth in order to dislodge any stuck balls.

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/commands/multiInterface/drive/NavXDriveStraight.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import org.usfirst.frc.team449.robot.jacksonWrappers.YamlSubsystem;
1111
import org.usfirst.frc.team449.robot.oi.unidirectional.tank.OITank;
1212
import org.usfirst.frc.team449.robot.other.Logger;
13-
import org.usfirst.frc.team449.robot.subsystem.interfaces.navX.SubsystemAHRS;
14-
import org.usfirst.frc.team449.robot.subsystem.interfaces.navX.commands.PIDAngleCommand;
13+
import org.usfirst.frc.team449.robot.subsystem.interfaces.AHRS.SubsystemAHRS;
14+
import org.usfirst.frc.team449.robot.subsystem.interfaces.AHRS.commands.PIDAngleCommand;
1515

1616
/**
1717
* Drives straight using the NavX gyro to keep a constant alignment.

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/commands/multiInterface/drive/NavXTurnToAngle.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
import org.usfirst.frc.team449.robot.jacksonWrappers.YamlSubsystem;
1212
import org.usfirst.frc.team449.robot.other.Clock;
1313
import org.usfirst.frc.team449.robot.other.Logger;
14-
import org.usfirst.frc.team449.robot.subsystem.interfaces.navX.SubsystemAHRS;
15-
import org.usfirst.frc.team449.robot.subsystem.interfaces.navX.commands.PIDAngleCommand;
14+
import org.usfirst.frc.team449.robot.subsystem.interfaces.AHRS.SubsystemAHRS;
15+
import org.usfirst.frc.team449.robot.subsystem.interfaces.AHRS.commands.PIDAngleCommand;
1616

1717
/**
18-
* Turns to a specified angle, relative to the angle the navX was at when the robot was turned on.
18+
* Turns to a specified angle, relative to the angle the AHRS was at when the robot was turned on.
1919
*/
2020
@JsonIdentityInfo(generator = ObjectIdGenerators.StringIdGenerator.class)
2121
public class NavXTurnToAngle <T extends YamlSubsystem & DriveUnidirectional & SubsystemAHRS> extends PIDAngleCommand {

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/commands/multiInterface/drive/NavXTurnToAngleRelative.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.usfirst.frc.team449.robot.jacksonWrappers.YamlSubsystem;
1111
import org.usfirst.frc.team449.robot.other.Clock;
1212
import org.usfirst.frc.team449.robot.other.Logger;
13-
import org.usfirst.frc.team449.robot.subsystem.interfaces.navX.SubsystemAHRS;
13+
import org.usfirst.frc.team449.robot.subsystem.interfaces.AHRS.SubsystemAHRS;
1414

1515
/**
1616
* Turn a certain number of degrees from the current heading.

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.usfirst.frc.team449.robot.oi.unidirectional.OIUnidirectional;
1010
import org.usfirst.frc.team449.robot.other.BufferTimer;
1111
import org.usfirst.frc.team449.robot.other.Logger;
12-
import org.usfirst.frc.team449.robot.subsystem.interfaces.navX.SubsystemAHRS;
13-
import org.usfirst.frc.team449.robot.subsystem.interfaces.navX.commands.PIDAngleCommand;
12+
import org.usfirst.frc.team449.robot.subsystem.interfaces.AHRS.SubsystemAHRS;
13+
import org.usfirst.frc.team449.robot.subsystem.interfaces.AHRS.commands.PIDAngleCommand;
1414

1515
/**
1616
* Drive with arcade drive setup, and when the driver isn't turning, use a NavX to stabilize the robot's alignment.
@@ -118,17 +118,17 @@ protected void initialize() {
118118
@Override
119119
protected void execute() {
120120
SmartDashboard.putBoolean("Override",subsystem.getOverrideGyro());
121-
//If we're driving straight but the driver tries to turn or overrides the navX:
122-
if (drivingStraight && (!oi.commandingStraightCached() || subsystem.getOverrideGyro())) {
121+
//If we're driving straight but the driver tries to turn or overrides the AHRS:
122+
if (drivingStraight && (!oi.commandingStraight() || subsystem.getOverrideGyro())) {
123123
//Switch to free drive
124124
drivingStraight = false;
125125
}
126126
//If we're free driving and the driver stops turning:
127127
else if (driveStraightLoopEntryTimer.get(!(subsystem.getOverrideGyro()) && !(drivingStraight) &&
128-
oi.commandingStraightCached() && Math.abs(subsystem.getAngularVelCached()) <= maxAngularVelToEnterLoop)) {
128+
oi.commandingStraight() && Math.abs(subsystem.getAngularVelCached()) <= maxAngularVelToEnterLoop)) {
129129
//Switch to driving straight
130130
drivingStraight = true;
131-
//Set the setpoint to the current heading and reset the navX
131+
//Set the setpoint to the current heading and reset the AHRS
132132
this.getPIDController().reset();
133133
this.getPIDController().setSetpoint(subsystem.getHeadingCached());
134134
this.getPIDController().enable();

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/commands/multiInterface/drive/UnidirectionalNavXShiftingDefaultDrive.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.usfirst.frc.team449.robot.oi.unidirectional.OIUnidirectional;
1212
import org.usfirst.frc.team449.robot.other.BufferTimer;
1313
import org.usfirst.frc.team449.robot.other.Logger;
14-
import org.usfirst.frc.team449.robot.subsystem.interfaces.navX.SubsystemAHRS;
14+
import org.usfirst.frc.team449.robot.subsystem.interfaces.AHRS.SubsystemAHRS;
1515

1616
/**
1717
* Drive with arcade drive setup, autoshift, and when the driver isn't turning, use a NavX to stabilize the robot's

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/drive/unidirectional/DriveTalonCluster.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.usfirst.frc.team449.robot.other.Logger;
1414
import org.usfirst.frc.team449.robot.other.MotionProfileData;
1515
import org.usfirst.frc.team449.robot.subsystem.interfaces.motionProfile.TwoSideMPSubsystem.SubsystemMPTwoSides;
16-
import org.usfirst.frc.team449.robot.subsystem.interfaces.navX.SubsystemAHRS;
16+
import org.usfirst.frc.team449.robot.subsystem.interfaces.AHRS.SubsystemAHRS;
1717

1818

1919
/**
@@ -218,7 +218,7 @@ public void setDefaultCommandManual(Command defaultCommand) {
218218
}
219219

220220
/**
221-
* Get the robot's heading using the navX
221+
* Get the robot's heading using the AHRS
222222
*
223223
* @return robot heading, in degrees, on [-180, 180]
224224
*/

0 commit comments

Comments
 (0)