[wpilib] Remove GyroBase

This commit is contained in:
Peter Johnson
2021-03-12 15:52:02 -08:00
parent 6b168ab0c8
commit 687066af3d
12 changed files with 78 additions and 73 deletions

View File

@@ -9,6 +9,8 @@ import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.SimBoolean;
import edu.wpi.first.hal.SimDevice;
import edu.wpi.first.hal.SimDouble;
import edu.wpi.first.wpilibj.interfaces.Gyro;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -24,7 +26,7 @@ import java.nio.ByteOrder;
* an ADXRS Gyro is supported.
*/
@SuppressWarnings({"TypeName", "AbbreviationAsWordInName", "PMD.UnusedPrivateField"})
public class ADXRS450_Gyro extends GyroBase {
public class ADXRS450_Gyro implements Gyro, Sendable {
private static final double kSamplePeriod = 0.0005;
private static final double kCalibrationSampleTime = 5.0;
private static final double kDegreePerSecondPerLSB = 0.0125;
@@ -206,4 +208,10 @@ public class ADXRS450_Gyro extends GyroBase {
}
return m_spi.getAccumulatorLastValue() * kDegreePerSecondPerLSB;
}
@Override
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("Gyro");
builder.addDoubleProperty("Value", this::getAngle, null);
}
}

View File

@@ -9,6 +9,8 @@ import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam;
import edu.wpi.first.hal.AnalogGyroJNI;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.interfaces.Gyro;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
/**
@@ -20,7 +22,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
*
* <p>This class is for gyro sensors that connect to an analog input.
*/
public class AnalogGyro extends GyroBase {
public class AnalogGyro implements Gyro, Sendable {
private static final double kDefaultVoltsPerDegreePerSecond = 0.007;
protected AnalogInput m_analog;
private boolean m_channelAllocated;
@@ -188,4 +190,10 @@ public class AnalogGyro extends GyroBase {
public AnalogInput getAnalogInput() {
return m_analog;
}
@Override
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("Gyro");
builder.addDoubleProperty("Value", this::getAngle, null);
}
}

View File

@@ -1,17 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
import edu.wpi.first.wpilibj.interfaces.Gyro;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
/** GyroBase is the common base class for Gyro implementations such as AnalogGyro. */
public abstract class GyroBase implements Gyro, Sendable {
@Override
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("Gyro");
builder.addDoubleProperty("Value", this::getAngle, null);
}
}

View File

@@ -7,9 +7,11 @@ package edu.wpi.first.wpilibj.romi;
import edu.wpi.first.hal.SimDevice;
import edu.wpi.first.hal.SimDevice.Direction;
import edu.wpi.first.hal.SimDouble;
import edu.wpi.first.wpilibj.GyroBase;
import edu.wpi.first.wpilibj.Sendable;
import edu.wpi.first.wpilibj.interfaces.Gyro;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
public class RomiGyro extends GyroBase {
public class RomiGyro implements Gyro, Sendable {
private final SimDevice m_simDevice;
private SimDouble m_simRateX;
private SimDouble m_simRateY;
@@ -146,4 +148,10 @@ public class RomiGyro extends GyroBase {
m_simDevice.close();
}
}
@Override
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("Gyro");
builder.addDoubleProperty("Value", this::getAngle, null);
}
}