Skip to content

Commit

Permalink
Add bulk input read null check (acmerobotics#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrott committed Nov 27, 2018
1 parent 1df4b41 commit 696df83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public void setPIDCoefficients(DcMotor.RunMode runMode, PIDCoefficients coeffici
@Override
public List<Double> getWheelPositions() {
RevBulkData bulkData = hub.getBulkInputData();

if (bulkData == null) {
return Arrays.asList(0.0, 0.0, 0.0, 0.0);
}

List<Double> wheelPositions = new ArrayList<>();
for (ExpansionHubMotor motor : motors) {
wheelPositions.add(DriveConstants.encoderTicksToInches(bulkData.getMotorCurrentPosition(motor)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public void setPIDCoefficients(DcMotor.RunMode runMode, PIDCoefficients coeffici
public List<Double> getWheelPositions() {
double leftSum = 0, rightSum = 0;
RevBulkData bulkData = hub.getBulkInputData();

if (bulkData == null) {
return Arrays.asList(0.0, 0.0);
}

for (DcMotorEx leftMotor : leftMotors) {
leftSum += DriveConstants.encoderTicksToInches(bulkData.getMotorCurrentPosition(leftMotor));
}
Expand Down

0 comments on commit 696df83

Please sign in to comment.