[docs] Add missing JavaDocs (#6125)

This commit is contained in:
Tyler Veness
2024-01-01 22:56:23 -08:00
committed by GitHub
parent 5579219716
commit ad0859a8c9
137 changed files with 1202 additions and 204 deletions

View File

@@ -94,18 +94,31 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
private static final int PROD_ID = 0x56; // Product identifier
private static final int SERIAL_NUM = 0x58; // Lot-specific serial number
/** ADIS16448 calibration times. */
public enum CalibrationTime {
/** 32 ms calibration time */
_32ms(0),
/** 64 ms calibration time */
_64ms(1),
/** 128 ms calibration time */
_128ms(2),
/** 256 ms calibration time */
_256ms(3),
/** 512 ms calibration time */
_512ms(4),
/** 1 s calibration time */
_1s(5),
/** 2 s calibration time */
_2s(6),
/** 4 s calibration time */
_4s(7),
/** 8 s calibration time */
_8s(8),
/** 16 s calibration time */
_16s(9),
/** 32 s calibration time */
_32s(10),
/** 64 s calibration time */
_64s(11);
private final int value;
@@ -115,9 +128,13 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
}
/** IMU axes. */
public enum IMUAxis {
/** The IMU's X axis. */
kX,
/** The IMU's Y axis. */
kY,
/** The IMU's Z axis. */
kZ
}
@@ -248,11 +265,14 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
}
/** Creates a new ADIS16448_IMU object. */
public ADIS16448_IMU() {
this(IMUAxis.kZ, SPI.Port.kMXP, CalibrationTime._512ms);
}
/**
* Creates a new ADIS16448_IMU object.
*
* @param yaw_axis The axis that measures the yaw
* @param port The SPI Port the gyro is plugged into
* @param cal_time Calibration time
@@ -332,6 +352,11 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
m_connected = true;
}
/**
* Checks the connection status of the IMU.
*
* @return True if the IMU is connected, false otherwise.
*/
public boolean isConnected() {
if (m_simConnected != null) {
return m_simConnected.get();
@@ -339,7 +364,6 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
return m_connected;
}
/** */
private static int toUShort(byte[] buf) {
return (((buf[0] & 0xFF) << 8) + ((buf[1] & 0xFF) << 0));
}
@@ -348,7 +372,7 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
return (buf[0] & 0xFF);
}
public static int toUShort(int... buf) {
private static int toUShort(int... buf) {
return (((buf[0] & 0xFF) << 8) + (buf[1] & 0xFF));
}
@@ -481,7 +505,18 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
return true;
}
public int configDecRate(int m_decRate) {
/**
* Configures the decimation rate of the IMU.
*
* @param decimationRate The new decimation value.
* @return 0 if success, 1 if no change, 2 if error.
*/
public int configDecRate(int decimationRate) {
// Switches the active SPI port to standard SPI mode, writes a new value to
// the DECIMATE register in the IMU, and re-enables auto SPI.
//
// This function enters standard SPI mode, writes a new DECIMATE setting to
// the IMU, adjusts the sample scale factor, and re-enters auto SPI mode.
int writeValue;
int readbackValue;
if (!switchToStandardSPI()) {
@@ -490,19 +525,19 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/* Check max */
if (m_decRate > 9) {
if (decimationRate > 9) {
DriverStation.reportError(
"Attempted to write an invalid decimation value. Capping at 9", false);
m_decRate = 9;
decimationRate = 9;
}
if (m_decRate < 0) {
if (decimationRate < 0) {
DriverStation.reportError(
"Attempted to write an invalid decimation value. Capping at 0", false);
m_decRate = 0;
decimationRate = 0;
}
/* Shift decimation setting to correct position and select internal sync */
writeValue = (m_decRate << 8) | 0x1;
writeValue = (decimationRate << 8) | 0x1;
/* Apply to IMU */
writeRegister(SMPL_PRD, writeValue);
@@ -624,6 +659,12 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
m_spi.write(buf, 2);
}
/**
* Reset the gyro.
*
* <p>Resets the gyro accumulations to a heading of zero. This can be used if there is significant
* drift in the gyro and it needs to be recalibrated after running.
*/
public void reset() {
synchronized (this) {
m_integ_gyro_angle_x = 0.0;
@@ -957,7 +998,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return Yaw axis angle in degrees (CCW positive)
* Returns the yaw axis angle in degrees (CCW positive).
*
* @return Yaw axis angle in degrees (CCW positive).
*/
public synchronized double getAngle() {
switch (m_yaw_axis) {
@@ -973,7 +1016,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return Yaw axis angular rate in degrees per second (CCW positive)
* Returns the yaw axis angular rate in degrees per second (CCW positive).
*
* @return Yaw axis angular rate in degrees per second (CCW positive).
*/
public synchronized double getRate() {
switch (m_yaw_axis) {
@@ -989,14 +1034,18 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return Yaw Axis
* Returns which axis, kX, kY, or kZ, is set to the yaw axis.
*
* @return IMUAxis Yaw Axis
*/
public IMUAxis getYawAxis() {
return m_yaw_axis;
}
/**
* @return accumulated gyro angle in the X axis in degrees
* Returns the accumulated gyro angle in the X axis in degrees.
*
* @return The accumulated gyro angle in the X axis in degrees.
*/
public synchronized double getGyroAngleX() {
if (m_simGyroAngleX != null) {
@@ -1006,7 +1055,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return accumulated gyro angle in the Y axis in degrees
* Returns the accumulated gyro angle in the Y axis in degrees.
*
* @return The accumulated gyro angle in the Y axis in degrees.
*/
public synchronized double getGyroAngleY() {
if (m_simGyroAngleY != null) {
@@ -1016,7 +1067,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return accumulated gyro angle in the Z axis in degrees
* Returns the accumulated gyro angle in the Z axis in degrees.
*
* @return The accumulated gyro angle in the Z axis in degrees.
*/
public synchronized double getGyroAngleZ() {
if (m_simGyroAngleZ != null) {
@@ -1026,7 +1079,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return gyro angular rate in the X axis in degrees per second
* Returns the gyro angular rate in the X axis in degrees per second.
*
* @return The gyro angular rate in the X axis in degrees per second.
*/
public synchronized double getGyroRateX() {
if (m_simGyroRateX != null) {
@@ -1036,7 +1091,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return gyro angular rate in the Y axis in degrees per second
* Returns the gyro angular rate in the Y axis in degrees per second.
*
* @return The gyro angular rate in the Y axis in degrees per second.
*/
public synchronized double getGyroRateY() {
if (m_simGyroRateY != null) {
@@ -1046,7 +1103,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return gyro angular rate in the Z axis in degrees per second
* Returns the gyro angular rate in the Z axis in degrees per second.
*
* @return The gyro angular rate in the Z axis in degrees per second.
*/
public synchronized double getGyroRateZ() {
if (m_simGyroRateZ != null) {
@@ -1056,7 +1115,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return urrent acceleration in the X axis in meters per second squared
* Returns the acceleration in the X axis in meters per second squared.
*
* @return The acceleration in the X axis in meters per second squared.
*/
public synchronized double getAccelX() {
if (m_simAccelX != null) {
@@ -1066,7 +1127,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return current acceleration in the Y axis in meters per second squared
* Returns the acceleration in the Y axis in meters per second squared.
*
* @return The acceleration in the Y axis in meters per second squared.
*/
public synchronized double getAccelY() {
if (m_simAccelY != null) {
@@ -1076,7 +1139,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return current acceleration in the Z axis in meters per second squared
* Returns the acceleration in the Z axis in meters per second squared.
*
* @return The acceleration in the Z axis in meters per second squared.
*/
public synchronized double getAccelZ() {
if (m_simAccelZ != null) {
@@ -1086,7 +1151,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return Magnetic field strength in the X axis in Tesla
* Returns the magnetic field strength in the X axis in Tesla.
*
* @return The magnetic field strength in the X axis in Tesla.
*/
public synchronized double getMagneticFieldX() {
// mG to T
@@ -1094,7 +1161,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return Magnetic field strength in the Y axis in Tesla
* Returns the magnetic field strength in the Y axis in Tesla.
*
* @return The magnetic field strength in the Y axis in Tesla.
*/
public synchronized double getMagneticFieldY() {
// mG to T
@@ -1102,7 +1171,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return Magnetic field strength in the Z axis in Tesla
* Returns the magnetic field strength in the Z axis in Tesla.
*
* @return The magnetic field strength in the Z axis in Tesla.
*/
public synchronized double getMagneticFieldZ() {
// mG to T
@@ -1110,35 +1181,47 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return X-axis complementary angle in degrees
* Returns the complementary angle around the X axis computed from accelerometer and gyro rate
* measurements.
*
* @return The X-axis complementary angle in degrees.
*/
public synchronized double getXComplementaryAngle() {
return m_compAngleX;
}
/**
* @return Y-axis complementary angle in degrees
* Returns the complementary angle around the Y axis computed from accelerometer and gyro rate
* measurements.
*
* @return The Y-axis complementary angle in degrees.
*/
public synchronized double getYComplementaryAngle() {
return m_compAngleY;
}
/**
* @return X-axis filtered acceleration angle in degrees
* Returns the X-axis filtered acceleration angle in degrees.
*
* @return The X-axis filtered acceleration angle in degrees.
*/
public synchronized double getXFilteredAccelAngle() {
return m_accelAngleX;
}
/**
* @return Y-axis filtered acceleration angle in degrees
* Returns the Y-axis filtered acceleration angle in degrees.
*
* @return The Y-axis filtered acceleration angle in degrees.
*/
public synchronized double getYFilteredAccelAngle() {
return m_accelAngleY;
}
/**
* @return Barometric Pressure in PSI
* Returns the barometric pressure in PSI.
*
* @return The barometric pressure in PSI.
*/
public synchronized double getBarometricPressure() {
// mbar to PSI conversion
@@ -1146,7 +1229,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
}
/**
* @return Temperature in degrees Celsius
* Returns the temperature in degrees Celsius.
*
* @return The temperature in degrees Celsius.
*/
public synchronized double getTemperature() {
return m_temp;

View File

@@ -155,31 +155,31 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
FLASH_CNT
};
/** Calibration times for the ADIS16470. */
/** ADIS16470 calibration times. */
public enum CalibrationTime {
/** 32ms calibration */
/** 32 ms calibration time */
_32ms(0),
/** 64ms calibration */
/** 64 ms calibration time */
_64ms(1),
/** 128ms calibration */
/** 128 ms calibration time */
_128ms(2),
/** 256ms calibration */
/** 256 ms calibration time */
_256ms(3),
/** 512ms calibration */
/** 512 ms calibration time */
_512ms(4),
/** 1 second calibration */
/** 1 s calibration time */
_1s(5),
/** 2 second calibration */
/** 2 s calibration time */
_2s(6),
/** 4 second calibration */
/** 4 s calibration time */
_4s(7),
/** 8 second calibration */
/** 8 s calibration time */
_8s(8),
/** 16 second calibration */
/** 16 s calibration time */
_16s(9),
/** 32 second calibration */
/** 32 s calibration time */
_32s(10),
/** 64 second calibration */
/** 64 s calibration time */
_64s(11);
private final int value;
@@ -202,11 +202,11 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
kY,
/** The IMU's Z axis */
kZ,
/** The user configured yaw axis */
/** The user-configured yaw axis */
kYaw,
/** The user configured pitch axis */
/** The user-configured pitch axis */
kPitch,
/** The user configured roll axis */
/** The user-configured roll axis */
kRoll,
}
@@ -290,19 +290,22 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
}
/**
* Creates a new ADIS16740 IMU object. The default setup is the onboard SPI port with a
* calibration time of 4 seconds. Yaw, pitch, and roll are kZ, kX, and kY respectively.
* Creates a new ADIS16740 IMU object.
*
* <p>The default setup is the onboard SPI port with a calibration time of 4 seconds. Yaw, pitch,
* and roll are kZ, kX, and kY respectively.
*/
public ADIS16470_IMU() {
this(IMUAxis.kZ, IMUAxis.kX, IMUAxis.kY, SPI.Port.kOnboardCS0, CalibrationTime._4s);
}
/**
* Creates a new ADIS16740 IMU object. The default setup is the onboard SPI port with a
* calibration time of 4 seconds.
* Creates a new ADIS16740 IMU object.
*
* <p>The default setup is the onboard SPI port with a calibration time of 4 seconds.
*
* <p><b><i>Input axes limited to kX, kY and kZ. Specifying kYaw, kPitch,or kRoll will result in
* an error. </i></b>
* an error.</i></b>
*
* @param yaw_axis The axis that measures the yaw
* @param pitch_axis The axis that measures the pitch
@@ -315,8 +318,8 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
/**
* Creates a new ADIS16740 IMU object.
*
* <p><b><i> Input axes limited to kX, kY and kZ. Specifying kYaw, kPitch,or kRoll will result in
* an error. </i></b>
* <p><b><i>Input axes limited to kX, kY and kZ. Specifying kYaw, kPitch,or kRoll will result in
* an error.</i></b>
*
* @param yaw_axis The axis that measures the yaw
* @param pitch_axis The axis that measures the pitch
@@ -625,21 +628,25 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
/**
* Configures the decimation rate of the IMU.
*
* @param reg The new decimation value.
* @return 0 if OK, 2 if error
* @param decimationRate The new decimation value.
* @return 0 if success, 1 if no change, 2 if error.
*/
public int configDecRate(int reg) {
int m_reg = reg;
public int configDecRate(int decimationRate) {
// Switches the active SPI port to standard SPI mode, writes a new value to
// the DECIMATE register in the IMU, and re-enables auto SPI.
//
// This function enters standard SPI mode, writes a new DECIMATE setting to
// the IMU, adjusts the sample scale factor, and re-enters auto SPI mode.
if (!switchToStandardSPI()) {
DriverStation.reportError("Failed to configure/reconfigure standard SPI.", false);
return 2;
}
if (m_reg > 1999) {
if (decimationRate > 1999) {
DriverStation.reportError("Attempted to write an invalid decimation value.", false);
m_reg = 1999;
decimationRate = 1999;
}
m_scaled_sample_rate = (((m_reg + 1.0) / 2000.0) * 1000000.0);
writeRegister(DEC_RATE, m_reg);
m_scaled_sample_rate = (((decimationRate + 1.0) / 2000.0) * 1000000.0);
writeRegister(DEC_RATE, decimationRate);
System.out.println("Decimation register: " + readRegister(DEC_RATE));
if (!switchToAutoSPI()) {
DriverStation.reportError("Failed to configure/reconfigure auto SPI.", false);
@@ -1003,8 +1010,10 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
}
/**
* Resets the gyro accumulations to a heading of zero. This can be used if the "zero" orientation
* of the sensor needs to be changed in runtime.
* Reset the gyro.
*
* <p>Resets the gyro accumulations to a heading of zero. This can be used if there is significant
* drift in the gyro and it needs to be recalibrated after running.
*/
public void reset() {
synchronized (this) {
@@ -1086,8 +1095,10 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
}
/**
* @param axis The IMUAxis whose angle to return
* @return The axis angle in degrees (CCW positive)
* Returns the axis angle in degrees (CCW positive).
*
* @param axis The IMUAxis whose angle to return.
* @return The axis angle in degrees (CCW positive).
*/
public synchronized double getAngle(IMUAxis axis) {
switch (axis) {
@@ -1126,8 +1137,10 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
}
/**
* @param axis The IMUAxis whose rate to return
* @return Axis angular rate in degrees per second (CCW positive)
* Returns the axis angular rate in degrees per second (CCW positive).
*
* @param axis The IMUAxis whose rate to return.
* @return Axis angular rate in degrees per second (CCW positive).
*/
public synchronized double getRate(IMUAxis axis) {
switch (axis) {
@@ -1192,49 +1205,65 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
}
/**
* @return The acceleration in the X axis
* Returns the acceleration in the X axis in meters per second squared.
*
* @return The acceleration in the X axis in meters per second squared.
*/
public synchronized double getAccelX() {
return m_accel_x * 9.81;
}
/**
* @return The acceleration in the Y axis
* Returns the acceleration in the Y axis in meters per second squared.
*
* @return The acceleration in the Y axis in meters per second squared.
*/
public synchronized double getAccelY() {
return m_accel_y * 9.81;
}
/**
* @return The acceleration in the Z axis
* Returns the acceleration in the Z axis in meters per second squared.
*
* @return The acceleration in the Z axis in meters per second squared.
*/
public synchronized double getAccelZ() {
return m_accel_z * 9.81;
}
/**
* @return The X-axis complementary angle
* Returns the complementary angle around the X axis computed from accelerometer and gyro rate
* measurements.
*
* @return The X-axis complementary angle in degrees.
*/
public synchronized double getXComplementaryAngle() {
return m_compAngleX;
}
/**
* @return The Y-axis complementary angle
* Returns the complementary angle around the Y axis computed from accelerometer and gyro rate
* measurements.
*
* @return The Y-axis complementary angle in degrees.
*/
public synchronized double getYComplementaryAngle() {
return m_compAngleY;
}
/**
* @return The X-axis filtered acceleration angle
* Returns the X-axis filtered acceleration angle in degrees.
*
* @return The X-axis filtered acceleration angle in degrees.
*/
public synchronized double getXFilteredAccelAngle() {
return m_accelAngleX;
}
/**
* @return The Y-axis filtered acceleration angle
* Returns the Y-axis filtered acceleration angle in degrees.
*
* @return The Y-axis filtered acceleration angle in degrees.
*/
public synchronized double getYFilteredAccelAngle() {
return m_accelAngleY;

View File

@@ -43,16 +43,25 @@ public class ADXL345_I2C implements NTSendable, AutoCloseable {
private static final byte kDataFormat_FullRes = 0x08;
private static final byte kDataFormat_Justify = 0x04;
/** Accelerometer range. */
public enum Range {
/** 2 Gs max. */
k2G,
/** 4 Gs max. */
k4G,
/** 8 Gs max. */
k8G,
/** 16 Gs max. */
k16G
}
/** Accelerometer axes. */
public enum Axes {
/** X axis. */
kX((byte) 0x00),
/** Y axis. */
kY((byte) 0x02),
/** Z axis. */
kZ((byte) 0x04);
/** The integer value representing this enumeration. */
@@ -63,11 +72,20 @@ public class ADXL345_I2C implements NTSendable, AutoCloseable {
}
}
/** Container type for accelerations from all axes. */
@SuppressWarnings("MemberName")
public static class AllAxes {
/** Acceleration along the X axis in g-forces. */
public double XAxis;
/** Acceleration along the Y axis in g-forces. */
public double YAxis;
/** Acceleration along the Z axis in g-forces. */
public double ZAxis;
/** Default constructor. */
public AllAxes() {}
}
private I2C m_i2c;
@@ -123,10 +141,20 @@ public class ADXL345_I2C implements NTSendable, AutoCloseable {
SendableRegistry.addLW(this, "ADXL345_I2C", port.value);
}
/**
* Returns the I2C port.
*
* @return The I2C port.
*/
public int getPort() {
return m_i2c.getPort();
}
/**
* Returns the I2C device address.
*
* @return The I2C device address.
*/
public int getDeviceAddress() {
return m_i2c.getDeviceAddress();
}

View File

@@ -40,16 +40,25 @@ public class ADXL345_SPI implements NTSendable, AutoCloseable {
private static final int kDataFormat_FullRes = 0x08;
private static final int kDataFormat_Justify = 0x04;
/** Accelerometer range. */
public enum Range {
/** 2 Gs max. */
k2G,
/** 4 Gs max. */
k4G,
/** 8 Gs max. */
k8G,
/** 16 Gs max. */
k16G
}
/** Accelerometer axes. */
public enum Axes {
/** X axis. */
kX((byte) 0x00),
/** Y axis. */
kY((byte) 0x02),
/** Z axis. */
kZ((byte) 0x04);
/** The integer value representing this enumeration. */
@@ -60,11 +69,20 @@ public class ADXL345_SPI implements NTSendable, AutoCloseable {
}
}
/** Container type for accelerations from all axes. */
@SuppressWarnings("MemberName")
public static class AllAxes {
/** Acceleration along the X axis in g-forces. */
public double XAxis;
/** Acceleration along the Y axis in g-forces. */
public double YAxis;
/** Acceleration along the Z axis in g-forces. */
public double ZAxis;
/** Default constructor. */
public AllAxes() {}
}
private SPI m_spi;
@@ -102,6 +120,11 @@ public class ADXL345_SPI implements NTSendable, AutoCloseable {
SendableRegistry.addLW(this, "ADXL345_SPI", port.value);
}
/**
* Returns the SPI port.
*
* @return The SPI port.
*/
public int getPort() {
return m_spi.getPort();
}

View File

@@ -43,17 +43,26 @@ public class ADXL362 implements NTSendable, AutoCloseable {
private static final byte kPowerCtl_Measure = 0x02;
/** Accelerometer range. */
public enum Range {
/** 2 Gs max. */
k2G,
/** 4 Gs max. */
k4G,
/** 8 Gs max. */
k8G
}
/** Accelerometer axes. */
public enum Axes {
/** X axis. */
kX((byte) 0x00),
/** Y axis. */
kY((byte) 0x02),
/** Z axis. */
kZ((byte) 0x04);
/** Axis value. */
public final byte value;
Axes(byte value) {
@@ -61,11 +70,20 @@ public class ADXL362 implements NTSendable, AutoCloseable {
}
}
/** Container type for accelerations from all axes. */
@SuppressWarnings("MemberName")
public static class AllAxes {
/** Acceleration along the X axis in g-forces. */
public double XAxis;
/** Acceleration along the Y axis in g-forces. */
public double YAxis;
/** Acceleration along the Z axis in g-forces. */
public double ZAxis;
/** Default constructor. */
public AllAxes() {}
}
private SPI m_spi;
@@ -142,6 +160,11 @@ public class ADXL362 implements NTSendable, AutoCloseable {
SendableRegistry.addLW(this, "ADXL362", port.value);
}
/**
* Returns the SPI port.
*
* @return The SPI port.
*/
public int getPort() {
return m_spi.getPort();
}

View File

@@ -22,9 +22,9 @@ public class AnalogEncoder implements Sendable, AutoCloseable {
private double m_distancePerRotation = 1.0;
private double m_lastPosition;
protected SimDevice m_simDevice;
protected SimDouble m_simPosition;
protected SimDouble m_simAbsolutePosition;
private SimDevice m_simDevice;
private SimDouble m_simPosition;
private SimDouble m_simAbsolutePosition;
/**
* Construct a new AnalogEncoder attached to a specific AnalogIn channel.

View File

@@ -50,10 +50,20 @@ public class AnalogOutput implements Sendable, AutoCloseable {
return m_channel;
}
/**
* Set the value of the analog output.
*
* @param voltage The output value in Volts, from 0.0 to +5.0.
*/
public void setVoltage(double voltage) {
AnalogJNI.setAnalogOutput(m_port, voltage);
}
/**
* Get the voltage of the analog output.
*
* @return The value in Volts, from 0.0 to +5.0.
*/
public double getVoltage() {
return AnalogJNI.getAnalogOutput(m_port);
}

View File

@@ -30,9 +30,12 @@ public class AnalogTrigger implements Sendable, AutoCloseable {
/** Where the analog trigger is attached. */
protected int m_port;
protected AnalogInput m_analogInput;
protected DutyCycle m_dutyCycle;
protected boolean m_ownsAnalog;
private AnalogInput m_analogInput;
@SuppressWarnings({"PMD.SingularField", "PMD.UnusedPrivateField"})
private DutyCycle m_dutyCycle;
private boolean m_ownsAnalog;
/**
* Constructor for an analog trigger given a channel number.

View File

@@ -106,9 +106,13 @@ public class AnalogTriggerOutput extends DigitalSource implements Sendable {
/** Defines the state in which the AnalogTrigger triggers. */
public enum AnalogTriggerType {
/** In window. */
kInWindow(AnalogJNI.AnalogTriggerType.kInWindow),
/** State. */
kState(AnalogJNI.AnalogTriggerType.kState),
/** Rising pulse. */
kRisingPulse(AnalogJNI.AnalogTriggerType.kRisingPulse),
/** Falling pulse. */
kFallingPulse(AnalogJNI.AnalogTriggerType.kFallingPulse);
private final int value;

View File

@@ -17,9 +17,13 @@ import edu.wpi.first.util.sendable.SendableRegistry;
* <p>This class allows access to the roboRIO's internal accelerometer.
*/
public class BuiltInAccelerometer implements Sendable, AutoCloseable {
/** Accelerometer range. */
public enum Range {
/** 2 Gs max. */
k2G,
/** 4 Gs max. */
k4G,
/** 8 Gs max. */
k8G
}

View File

@@ -11,8 +11,18 @@ package edu.wpi.first.wpilibj;
* source. The source can either be a digital input or analog trigger but not both.
*/
public abstract class DigitalSource implements AutoCloseable {
/**
* Returns true if this DigitalSource is an AnalogTrigger.
*
* @return True if this DigitalSource is an AnalogTrigger.
*/
public abstract boolean isAnalogTrigger();
/**
* The DigitalSource channel.
*
* @return The DigitalSource channel.
*/
public abstract int getChannel();
/**

View File

@@ -23,17 +23,28 @@ import edu.wpi.first.wpilibj.event.EventLoop;
public class XboxController extends GenericHID {
/** Represents a digital button on an XboxController. */
public enum Button {
/** Left bumper. */
kLeftBumper(5),
/** Right bumper. */
kRightBumper(6),
/** Left stick. */
kLeftStick(9),
/** Right stick. */
kRightStick(10),
/** A. */
kA(1),
/** B. */
kB(2),
/** X. */
kX(3),
/** Y. */
kY(4),
/** Back. */
kBack(7),
/** Start. */
kStart(8);
/** Button value. */
public final int value;
Button(int value) {
@@ -60,13 +71,20 @@ public class XboxController extends GenericHID {
/** Represents an axis on an XboxController. */
public enum Axis {
/** Left X. */
kLeftX(0),
/** Right X. */
kRightX(4),
/** Left Y. */
kLeftY(1),
/** Right Y. */
kRightY(5),
/** Left trigger. */
kLeftTrigger(2),
/** Right trigger. */
kRightTrigger(3);
/** Axis value. */
public final int value;
Axis(int value) {

View File

@@ -11,10 +11,15 @@ package edu.wpi.first.wpilibj.interfaces;
*/
@Deprecated(since = "2024", forRemoval = true)
public interface Accelerometer {
/** Accelerometer range. */
enum Range {
/** 2 Gs max. */
k2G,
/** 4 Gs max. */
k4G,
/** 8 Gs max. */
k8G,
/** 16 Gs max. */
k16G
}

View File

@@ -9,10 +9,11 @@ import edu.wpi.first.wpilibj.ADXL345_I2C;
import edu.wpi.first.wpilibj.ADXL345_SPI;
import java.util.Objects;
/** Class to control a simulated ADXL345. */
public class ADXL345Sim {
protected SimDouble m_simX;
protected SimDouble m_simY;
protected SimDouble m_simZ;
private SimDouble m_simX;
private SimDouble m_simY;
private SimDouble m_simZ;
/**
* Constructor.
@@ -48,15 +49,30 @@ public class ADXL345Sim {
Objects.requireNonNull(m_simZ);
}
public void setX(double x) {
m_simX.set(x);
/**
* Sets the X acceleration.
*
* @param accel The X acceleration.
*/
public void setX(double accel) {
m_simX.set(accel);
}
public void setY(double y) {
m_simY.set(y);
/**
* Sets the Y acceleration.
*
* @param accel The Y acceleration.
*/
public void setY(double accel) {
m_simY.set(accel);
}
public void setZ(double z) {
m_simZ.set(z);
/**
* Sets the Z acceleration.
*
* @param accel The Z acceleration.
*/
public void setZ(double accel) {
m_simZ.set(accel);
}
}

View File

@@ -8,10 +8,11 @@ import edu.wpi.first.hal.SimDouble;
import edu.wpi.first.wpilibj.ADXL362;
import java.util.Objects;
/** Class to control a simulated ADXL362. */
public class ADXL362Sim {
protected SimDouble m_simX;
protected SimDouble m_simY;
protected SimDouble m_simZ;
private SimDouble m_simX;
private SimDouble m_simY;
private SimDouble m_simZ;
/**
* Constructor.
@@ -34,15 +35,30 @@ public class ADXL362Sim {
Objects.requireNonNull(m_simZ);
}
public void setX(double x) {
m_simX.set(x);
/**
* Sets the X acceleration.
*
* @param accel The X acceleration.
*/
public void setX(double accel) {
m_simX.set(accel);
}
public void setY(double y) {
m_simY.set(y);
/**
* Sets the Y acceleration.
*
* @param accel The Y acceleration.
*/
public void setY(double accel) {
m_simY.set(accel);
}
public void setZ(double z) {
m_simZ.set(z);
/**
* Sets the Z acceleration.
*
* @param accel The Z acceleration.
*/
public void setZ(double accel) {
m_simZ.set(accel);
}
}

View File

@@ -23,9 +23,9 @@ import org.ejml.simple.SimpleMatrix;
*
* <p>Set simulated sensor readings with the simulated positions in {@link #getOutput()}
*
* @param <States> The number of states of the system.
* @param <Inputs> The number of inputs to the system.
* @param <Outputs> The number of outputs of the system.
* @param <States> Number of states of the system.
* @param <Inputs> Number of inputs to the system.
* @param <Outputs> Number of outputs of the system.
*/
public class LinearSystemSim<States extends Num, Inputs extends Num, Outputs extends Num> {
// The plant that represents the linear system.