[docs] Fix wpilibj JavaDoc warnings (#6154)

This commit is contained in:
Tyler Veness
2024-01-05 07:35:59 -08:00
committed by GitHub
parent 19cb2a8eb4
commit 106518c3f8
97 changed files with 1112 additions and 71 deletions

View File

@@ -22,7 +22,10 @@ import java.io.Closeable;
* calls.
*/
public class CAN implements Closeable {
/** Team manufacturer. */
public static final int kTeamManufacturer = CANAPITypes.CANManufacturer.kTeamUse.id;
/** Team device type. */
public static final int kTeamDeviceType = CANAPITypes.CANDeviceType.kMiscellaneous.id;
private final int m_handle;

View File

@@ -6,12 +6,18 @@ package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.REVPHJNI;
/** Compressor config type. */
public enum CompressorConfigType {
/** Disabled. */
Disabled(REVPHJNI.COMPRESSOR_CONFIG_TYPE_DISABLED),
/** Digital. */
Digital(REVPHJNI.COMPRESSOR_CONFIG_TYPE_DIGITAL),
/** Analog. */
Analog(REVPHJNI.COMPRESSOR_CONFIG_TYPE_ANALOG),
/** Hybrid. */
Hybrid(REVPHJNI.COMPRESSOR_CONFIG_TYPE_HYBRID);
/** CompressorConfigType value. */
public final int value;
CompressorConfigType(int value) {
@@ -37,6 +43,11 @@ public enum CompressorConfigType {
}
}
/**
* Returns the CompressorConfigType's value.
*
* @return The CompressorConfigType's value.
*/
public int getValue() {
return value;
}

View File

@@ -38,6 +38,7 @@ public class Counter implements CounterBase, Sendable, AutoCloseable {
/** mode: external direction. */
kExternalDirection(3);
/** Mode value. */
public final int value;
Mode(int value) {
@@ -45,13 +46,23 @@ public class Counter implements CounterBase, Sendable, AutoCloseable {
}
}
protected DigitalSource m_upSource; // /< What makes the counter count up.
protected DigitalSource m_downSource; // /< What makes the counter count down.
/** What makes the counter count up. */
protected DigitalSource m_upSource;
/** What makes the counter count down. */
protected DigitalSource m_downSource;
private boolean m_allocatedUpSource;
private boolean m_allocatedDownSource;
int m_counter; // /< The FPGA counter object.
private int m_index; // /< The index of this counter.
private double m_distancePerPulse = 1; // distance of travel for each tick
/** The FPGA counter object. */
int m_counter;
/** The index of this counter. */
private int m_index;
/** Distance of travel for each tick. */
private double m_distancePerPulse = 1;
/**
* Create an instance of a counter with the given mode.

View File

@@ -22,6 +22,7 @@ public interface CounterBase {
/** Count rising and falling on both channels. */
k4X(2);
/** EncodingType value. */
public final int value;
EncodingType(int value) {

View File

@@ -7,9 +7,11 @@ package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.DMAJNI;
import edu.wpi.first.wpilibj.motorcontrol.PWMMotorController;
/** Class for configuring Direct Memory Access (DMA) of FPGA inputs. */
public class DMA implements AutoCloseable {
final int m_dmaHandle;
/** Default constructor. */
public DMA() {
m_dmaHandle = DMAJNI.initialize();
}
@@ -19,50 +21,128 @@ public class DMA implements AutoCloseable {
DMAJNI.free(m_dmaHandle);
}
/**
* Sets whether DMA is paused.
*
* @param pause True pauses DMA.
*/
public void setPause(boolean pause) {
DMAJNI.setPause(m_dmaHandle, pause);
}
/**
* Sets DMA to trigger at an interval.
*
* @param periodSeconds Period at which to trigger DMA in seconds.
*/
public void setTimedTrigger(double periodSeconds) {
DMAJNI.setTimedTrigger(m_dmaHandle, periodSeconds);
}
/**
* Sets number of DMA cycles to trigger.
*
* @param cycles Number of cycles.
*/
public void setTimedTriggerCycles(int cycles) {
DMAJNI.setTimedTriggerCycles(m_dmaHandle, cycles);
}
/**
* Adds position data for an encoder to be collected by DMA.
*
* <p>This can only be called if DMA is not started.
*
* @param encoder Encoder to add to DMA.
*/
public void addEncoder(Encoder encoder) {
DMAJNI.addEncoder(m_dmaHandle, encoder.m_encoder);
}
/**
* Adds timer data for an encoder to be collected by DMA.
*
* <p>This can only be called if DMA is not started.
*
* @param encoder Encoder to add to DMA.
*/
public void addEncoderPeriod(Encoder encoder) {
DMAJNI.addEncoderPeriod(m_dmaHandle, encoder.m_encoder);
}
/**
* Adds position data for an counter to be collected by DMA.
*
* <p>This can only be called if DMA is not started.
*
* @param counter Counter to add to DMA.
*/
public void addCounter(Counter counter) {
DMAJNI.addCounter(m_dmaHandle, counter.m_counter);
}
/**
* Adds timer data for an counter to be collected by DMA.
*
* <p>This can only be called if DMA is not started.
*
* @param counter Counter to add to DMA.
*/
public void addCounterPeriod(Counter counter) {
DMAJNI.addCounterPeriod(m_dmaHandle, counter.m_counter);
}
/**
* Adds a digital source to be collected by DMA.
*
* <p>This can only be called if DMA is not started.
*
* @param digitalSource DigitalSource to add to DMA.
*/
public void addDigitalSource(DigitalSource digitalSource) {
DMAJNI.addDigitalSource(m_dmaHandle, digitalSource.getPortHandleForRouting());
}
/**
* Adds a duty cycle input to be collected by DMA.
*
* <p>This can only be called if DMA is not started.
*
* @param dutyCycle DutyCycle to add to DMA.
*/
public void addDutyCycle(DutyCycle dutyCycle) {
DMAJNI.addDutyCycle(m_dmaHandle, dutyCycle.m_handle);
}
/**
* Adds an analog input to be collected by DMA.
*
* <p>This can only be called if DMA is not started.
*
* @param analogInput AnalogInput to add to DMA.
*/
public void addAnalogInput(AnalogInput analogInput) {
DMAJNI.addAnalogInput(m_dmaHandle, analogInput.m_port);
}
/**
* Adds averaged data of an analog input to be collected by DMA.
*
* <p>This can only be called if DMA is not started.
*
* @param analogInput AnalogInput to add to DMA.
*/
public void addAveragedAnalogInput(AnalogInput analogInput) {
DMAJNI.addAveragedAnalogInput(m_dmaHandle, analogInput.m_port);
}
/**
* Adds accumulator data of an analog input to be collected by DMA.
*
* <p>This can only be called if DMA is not started.
*
* @param analogInput AnalogInput to add to DMA.
*/
public void addAnalogAccumulator(AnalogInput analogInput) {
DMAJNI.addAnalogAccumulator(m_dmaHandle, analogInput.m_port);
}
@@ -84,26 +164,58 @@ public class DMA implements AutoCloseable {
falling);
}
public int setPwmEdgeTrigger(PWMMotorController pwm, boolean rising, boolean falling) {
return DMAJNI.setExternalTrigger(m_dmaHandle, pwm.getPwmHandle(), 0, rising, falling);
}
/**
* Sets a DMA PWM edge trigger.
*
* @param pwm the PWM to trigger from.
* @param rising trigger on rising edge.
* @param falling trigger on falling edge.
* @return the index of the trigger
*/
public int setPwmEdgeTrigger(PWM pwm, boolean rising, boolean falling) {
return DMAJNI.setExternalTrigger(m_dmaHandle, pwm.getHandle(), 0, rising, falling);
}
/**
* Sets a DMA PWMMotorController edge trigger.
*
* @param pwm the PWMMotorController to trigger from.
* @param rising trigger on rising edge.
* @param falling trigger on falling edge.
* @return the index of the trigger
*/
public int setPwmEdgeTrigger(PWMMotorController pwm, boolean rising, boolean falling) {
return DMAJNI.setExternalTrigger(m_dmaHandle, pwm.getPwmHandle(), 0, rising, falling);
}
/**
* Clear all sensors from the DMA collection list.
*
* <p>This can only be called if DMA is not started.
*/
public void clearSensors() {
DMAJNI.clearSensors(m_dmaHandle);
}
/**
* Clear all external triggers from the DMA trigger list.
*
* <p>This can only be called if DMA is not started.
*/
public void clearExternalTriggers() {
DMAJNI.clearExternalTriggers(m_dmaHandle);
}
/**
* Starts DMA Collection.
*
* @param queueDepth The number of objects to be able to queue.
*/
public void start(int queueDepth) {
DMAJNI.startDMA(m_dmaHandle, queueDepth);
}
/** Stops DMA Collection. */
public void stop() {
DMAJNI.stopDMA(m_dmaHandle);
}

View File

@@ -7,7 +7,9 @@ package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.AnalogJNI;
import edu.wpi.first.hal.DMAJNISample;
/** DMA sample. */
public class DMASample {
/** DMA read status. */
public enum DMAReadStatus {
/** OK status. */
kOk(1),
@@ -22,6 +24,11 @@ public class DMASample {
this.value = value;
}
/**
* Returns the DMAReadStatus value.
*
* @return The DMAReadStatus value.
*/
public int getValue() {
return value;
}
@@ -47,39 +54,77 @@ public class DMASample {
/** Default constructor. */
public DMASample() {}
/**
* Retrieves a new DMA sample.
*
* @param dma DMA object.
* @param timeoutSeconds Timeout in seconds for retrieval.
* @return DMA read status.
*/
public DMAReadStatus update(DMA dma, double timeoutSeconds) {
return DMAReadStatus.getValue(m_dmaSample.update(dma.m_dmaHandle, timeoutSeconds));
}
public int getCaptureSize() {
return m_dmaSample.getCaptureSize();
}
public int getTriggerChannels() {
return m_dmaSample.getTriggerChannels();
}
public int getRemaining() {
return m_dmaSample.getRemaining();
}
/**
* Returns the DMA sample time in microseconds.
*
* @return The DMA sample time in microseconds.
*/
public long getTime() {
return m_dmaSample.getTime();
}
/**
* Returns the DMA sample timestamp in seconds.
*
* @return The DMA sample timestamp in seconds.
*/
public double getTimeStamp() {
return getTime() * 1.0e-6;
}
/**
* Returns the DMA sample capture size.
*
* @return The DMA sample capture size.
*/
public int getCaptureSize() {
return m_dmaSample.getCaptureSize();
}
/**
* Returns the number of DMA trigger channels.
*
* @return The number of DMA trigger channels.
*/
public int getTriggerChannels() {
return m_dmaSample.getTriggerChannels();
}
/**
* Returns the number of remaining samples.
*
* @return The number of remaining samples.
*/
public int getRemaining() {
return m_dmaSample.getRemaining();
}
/**
* Returns raw encoder value from DMA.
*
* @param encoder Encoder used for DMA.
* @return Raw encoder value from DMA.
*/
public int getEncoderRaw(Encoder encoder) {
return m_dmaSample.getEncoder(encoder.m_encoder);
}
/**
* Gets the scaled encoder distance for this sample.
* Returns encoder distance from DMA.
*
* @param encoder the encoder to use to read
* @return the distance
* @param encoder Encoder used for DMA.
* @return Encoder distance from DMA.
*/
public double getEncoderDistance(Encoder encoder) {
double val = getEncoderRaw(encoder);
@@ -88,43 +133,103 @@ public class DMASample {
return val;
}
/**
* Returns raw encoder period from DMA.
*
* @param encoder Encoder used for DMA.
* @return Raw encoder period from DMA.
*/
public int getEncoderPeriodRaw(Encoder encoder) {
return m_dmaSample.getEncoderPeriod(encoder.m_encoder);
}
/**
* Returns counter value from DMA.
*
* @param counter Counter used for DMA.
* @return Counter value from DMA.
*/
public int getCounter(Counter counter) {
return m_dmaSample.getCounter(counter.m_counter);
}
/**
* Returns counter period from DMA.
*
* @param counter Counter used for DMA.
* @return Counter period from DMA.
*/
public int getCounterPeriod(Counter counter) {
return m_dmaSample.getCounterPeriod(counter.m_counter);
}
/**
* Returns digital source value from DMA.
*
* @param digitalSource DigitalSource used for DMA.
* @return DigitalSource value from DMA.
*/
public boolean getDigitalSource(DigitalSource digitalSource) {
return m_dmaSample.getDigitalSource(digitalSource.getPortHandleForRouting());
}
/**
* Returns raw analog input value from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @return Raw analog input value from DMA.
*/
public int getAnalogInputRaw(AnalogInput analogInput) {
return m_dmaSample.getAnalogInput(analogInput.m_port);
}
/**
* Returns analog input voltage from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @return Analog input voltage from DMA.
*/
public double getAnalogInputVoltage(AnalogInput analogInput) {
return AnalogJNI.getAnalogValueToVolts(analogInput.m_port, getAnalogInputRaw(analogInput));
}
/**
* Returns averaged raw analog input value from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @return Averaged raw analog input value from DMA.
*/
public int getAveragedAnalogInputRaw(AnalogInput analogInput) {
return m_dmaSample.getAnalogInputAveraged(analogInput.m_port);
}
/**
* Returns averaged analog input voltage from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @return Averaged analog input voltage from DMA.
*/
public double getAveragedAnalogInputVoltage(AnalogInput analogInput) {
return AnalogJNI.getAnalogValueToVolts(
analogInput.m_port, getAveragedAnalogInputRaw(analogInput));
}
/**
* Returns raw duty cycle output from DMA.
*
* @param dutyCycle DutyCycle used for DMA.
* @return Raw duty cycle output from DMA.
*/
public int getDutyCycleOutputRaw(DutyCycle dutyCycle) {
return m_dmaSample.getDutyCycleOutput(dutyCycle.m_handle);
}
/**
* Returns duty cycle output (0-1) from DMA.
*
* @param dutyCycle DutyCycle used for DMA.
* @return Duty cycle output (0-1) from DMA.
*/
public double getDutyCycleOutput(DutyCycle dutyCycle) {
return m_dmaSample.getDutyCycleOutput(dutyCycle.m_handle)
/ (double) dutyCycle.getOutputScaleFactor();

View File

@@ -1321,10 +1321,20 @@ public final class DriverStation {
}
}
/**
* Registers the given handle for DS data refresh notifications.
*
* @param handle The event handle.
*/
public static void provideRefreshedDataEventHandle(int handle) {
m_refreshEvents.add(handle);
}
/**
* Unregisters the given handle from DS data refresh notifications.
*
* @param handle The event handle.
*/
public static void removeRefreshedDataEventHandle(int handle) {
m_refreshEvents.remove(handle);
}

View File

@@ -103,6 +103,11 @@ public class DutyCycle implements Sendable, AutoCloseable {
return DutyCycleJNI.getFPGAIndex(m_handle);
}
/**
* Get the channel of the source.
*
* @return the source channel
*/
public int getSourceChannel() {
return m_source.getChannel();
}

View File

@@ -40,6 +40,7 @@ public class Encoder implements CounterBase, Sendable, AutoCloseable {
/** Reset on rising edge of the signal. */
kResetOnRisingEdge(3);
/** IndexingType value. */
public final int value;
IndexingType(int value) {

View File

@@ -66,6 +66,7 @@ public class GenericHID {
/** HID1stPerson. */
kHID1stPerson(24);
/** HIDType value. */
public final int value;
@SuppressWarnings("PMD.UseConcurrentHashMap")
@@ -81,6 +82,12 @@ public class GenericHID {
}
}
/**
* Creates an HIDType with the given value.
*
* @param value HIDType's value.
* @return HIDType with the given value.
*/
public static HIDType of(int value) {
return map.get(value);
}

View File

@@ -30,6 +30,7 @@ public class I2C implements AutoCloseable {
/** MXP (roboRIO MXP) I2C port. */
kMXP(1);
/** Port value. */
public final int value;
Port(int value) {
@@ -61,10 +62,20 @@ public class I2C implements AutoCloseable {
HAL.report(tResourceType.kResourceType_I2C, deviceAddress);
}
/**
* Returns I2C port.
*
* @return I2C port.
*/
public int getPort() {
return m_port;
}
/**
* Returns I2C device address.
*
* @return I2C device address.
*/
public int getDeviceAddress() {
return m_deviceAddress;
}

View File

@@ -288,6 +288,7 @@ public abstract class IterativeRobotBase extends RobotBase {
return m_period;
}
/** Loop function. */
protected void loopFunc() {
DriverStation.refreshData();
m_watchdog.reset();

View File

@@ -17,10 +17,19 @@ import edu.wpi.first.wpilibj.event.EventLoop;
* and the mapping of ports to hardware buttons depends on the code in the Driver Station.
*/
public class Joystick extends GenericHID {
/** Default X axis channel. */
public static final byte kDefaultXChannel = 0;
/** Default Y axis channel. */
public static final byte kDefaultYChannel = 1;
/** Default Z axis channel. */
public static final byte kDefaultZChannel = 2;
/** Default twist axis channel. */
public static final byte kDefaultTwistChannel = 2;
/** Default throttle axis channel. */
public static final byte kDefaultThrottleChannel = 3;
/** Represents an analog axis on a joystick. */
@@ -36,6 +45,7 @@ public class Joystick extends GenericHID {
/** Throttle axis. */
kThrottle(4);
/** AxisType value. */
public final int value;
AxisType(int value) {
@@ -50,6 +60,7 @@ public class Joystick extends GenericHID {
/** kTop. */
kTop(2);
/** ButtonType value. */
public final int value;
ButtonType(int value) {

View File

@@ -186,7 +186,13 @@ public abstract class MotorSafety {
}
}
/** Called to stop the motor when the timeout expires. */
public abstract void stopMotor();
/**
* Returns a description to print when an error occurs.
*
* @return Description to print when an error occurs.
*/
public abstract String getDescription();
}

View File

@@ -63,6 +63,7 @@ public class PS4Controller extends GenericHID {
/** Touchpad click button. */
kTouchpad(14);
/** Button value. */
public final int value;
Button(int index) {
@@ -102,6 +103,7 @@ public class PS4Controller extends GenericHID {
/** Right Trigger 2. */
kR2(4);
/** Axis value. */
public final int value;
Axis(int index) {

View File

@@ -60,6 +60,7 @@ public class PS5Controller extends GenericHID {
/** Touchpad click button. */
kTouchpad(14);
/** Button value. */
public final int value;
Button(int index) {
@@ -99,6 +100,7 @@ public class PS5Controller extends GenericHID {
/** Right Trigger 2. */
kR2(4);
/** Axis value. */
public final int value;
Axis(int index) {

View File

@@ -229,6 +229,7 @@ public class PWM implements Sendable, AutoCloseable {
}
}
/** Latches PWM to zero. */
public void setZeroLatch() {
PWMJNI.latchPWMZero(m_handle);
}

View File

@@ -4,6 +4,7 @@
package edu.wpi.first.wpilibj;
/** Interface for pneumatics devices. */
public interface PneumaticsBase extends AutoCloseable {
/**
* For internal use to get a module for a specific type.

View File

@@ -186,10 +186,23 @@ public class PneumaticsControlModule implements PneumaticsBase {
return CTREPCMJNI.getSolenoidDisabledList(m_handle);
}
/**
* Returns whether the solenoid is currently reporting a voltage fault.
*
* @return True if solenoid is reporting a fault, otherwise false.
* @see #getSolenoidVoltageStickyFault()
*/
public boolean getSolenoidVoltageFault() {
return CTREPCMJNI.getSolenoidVoltageFault(m_handle);
}
/**
* Returns whether the solenoid has reported a voltage fault since sticky faults were last
* cleared. This fault is persistent and can be cleared by ClearAllStickyFaults()
*
* @return True if solenoid is reporting a fault, otherwise false.
* @see #getSolenoidVoltageFault()
*/
public boolean getSolenoidVoltageStickyFault() {
return CTREPCMJNI.getSolenoidVoltageStickyFault(m_handle);
}

View File

@@ -4,7 +4,10 @@
package edu.wpi.first.wpilibj;
/** Pneumatics module type. */
public enum PneumaticsModuleType {
/** CTRE PCM. */
CTREPCM,
/** REV PH. */
REVPH
}

View File

@@ -22,6 +22,7 @@ public class PowerDistribution implements Sendable, AutoCloseable {
private final int m_handle;
private final int m_module;
/** Default module number. */
public static final int kDefaultModule = PowerDistributionJNI.DEFAULT_MODULE;
/** Power distribution module type. */
@@ -31,6 +32,7 @@ public class PowerDistribution implements Sendable, AutoCloseable {
/** REV Power Distribution Hub (PDH). */
kRev(PowerDistributionJNI.REV_TYPE);
/** ModuleType value. */
public final int value;
ModuleType(int value) {
@@ -187,14 +189,29 @@ public class PowerDistribution implements Sendable, AutoCloseable {
PowerDistributionJNI.setSwitchableChannel(m_handle, enabled);
}
/**
* Returns the power distribution version number.
*
* @return The power distribution version number.
*/
public PowerDistributionVersion getVersion() {
return PowerDistributionJNI.getVersion(m_handle);
}
/**
* Returns the power distribution faults.
*
* @return The power distribution faults.
*/
public PowerDistributionFaults getFaults() {
return PowerDistributionJNI.getFaults(m_handle);
}
/**
* Returns the power distribution sticky faults.
*
* @return The power distribution sticky faults.
*/
public PowerDistributionStickyFaults getStickyFaults() {
return PowerDistributionJNI.getStickyFaults(m_handle);
}

View File

@@ -59,10 +59,21 @@ public class Relay extends MotorSafety implements Sendable, AutoCloseable {
m_prettyValue = prettyValue;
}
/**
* Returns the pretty string representation of the value.
*
* @return The pretty string representation of the value.
*/
public String getPrettyValue() {
return m_prettyValue;
}
/**
* Returns the value for a given pretty string.
*
* @param value The pretty string.
* @return The value or an empty optional if there is no corresponding value.
*/
public static Optional<Value> getValueOf(String value) {
return Arrays.stream(Value.values()).filter(v -> v.m_prettyValue.equals(value)).findFirst();
}

View File

@@ -178,6 +178,11 @@ public abstract class RobotBase implements AutoCloseable {
Shuffleboard.disableActuatorWidgets();
}
/**
* Returns the main thread ID.
*
* @return The main thread ID.
*/
public static long getMainThreadId() {
return m_threadId;
}

View File

@@ -4,6 +4,7 @@
package edu.wpi.first.wpilibj;
/** Robot state utility functions. */
public final class RobotState {
/**
* Returns true if the robot is disabled.

View File

@@ -6,14 +6,16 @@ package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.HALUtil;
/** Runtime type. */
public enum RuntimeType {
/** RoboRio 1.0. */
/** roboRIO 1.0. */
kRoboRIO(HALUtil.RUNTIME_ROBORIO),
/** RoboRio 2.0. */
/** roboRIO 2.0. */
kRoboRIO2(HALUtil.RUNTIME_ROBORIO2),
/** Simulation runtime. */
kSimulation(HALUtil.RUNTIME_SIMULATION);
/** RuntimeType value. */
public final int value;
RuntimeType(int value) {

View File

@@ -27,6 +27,7 @@ public class SPI implements AutoCloseable {
/** MXP (roboRIO MXP) SPI bus port. */
kMXP(SPIJNI.MXP_PORT);
/** SPI port value. */
public final int value;
Port(int value) {
@@ -45,6 +46,7 @@ public class SPI implements AutoCloseable {
/** Clock idle high, data sampled on rising edge. */
kMode3(SPIJNI.SPI_MODE3);
/** SPI mode value. */
public final int value;
Mode(int value) {
@@ -71,6 +73,11 @@ public class SPI implements AutoCloseable {
HAL.report(tResourceType.kResourceType_SPI, port.value + 1);
}
/**
* Returns the SPI port value.
*
* @return SPI port value.
*/
public int getPort() {
return m_port;
}

View File

@@ -47,8 +47,10 @@ public final class SensorUtil {
/** Number of PCM Modules. */
public static final int kCTREPCMModules = PortsJNI.getNumCTREPCMModules();
/** Number of power distribution channels per PH. */
public static final int kREVPHChannels = PortsJNI.getNumREVPHChannels();
/** Number of PH modules. */
public static final int kREVPHModules = PortsJNI.getNumREVPHModules();
/**

View File

@@ -26,6 +26,7 @@ public class SerialPort implements AutoCloseable {
/** USB serial port 2. */
kUSB2(3);
/** Port value. */
public final int value;
Port(int value) {
@@ -46,6 +47,7 @@ public class SerialPort implements AutoCloseable {
/** Parity bit always off. */
kSpace(4);
/** Parity value. */
public final int value;
Parity(int value) {
@@ -62,6 +64,7 @@ public class SerialPort implements AutoCloseable {
/** Two stop bits. */
kTwo(20);
/** StopBits value. */
public final int value;
StopBits(int value) {
@@ -80,6 +83,7 @@ public class SerialPort implements AutoCloseable {
/** DTS/DSR flow control. */
kDtsDsr(4);
/** FlowControl value. */
public final int value;
FlowControl(int value) {
@@ -94,6 +98,7 @@ public class SerialPort implements AutoCloseable {
/** Flush the buffer when it is full. */
kFlushWhenFull(2);
/** WriteBufferMode value. */
public final int value;
WriteBufferMode(int value) {

View File

@@ -23,10 +23,10 @@ public class Servo extends PWM {
private static final int kDefaultMinServoPWM = 600;
/**
* Constructor.<br>
* Constructor.
*
* <p>By default {@value #kDefaultMaxServoPWM} ms is used as the maxPWM value<br>
* By default {@value #kDefaultMinServoPWM} ms is used as the minPWM value<br>
* <p>By default, {@value #kDefaultMaxServoPWM} ms is used as the max PWM value and {@value
* #kDefaultMinServoPWM} ms is used as the minPWM value.
*
* @param channel The PWM channel to which the servo is attached. 0-9 are on-board, 10-19 are on
* the MXP port

View File

@@ -50,6 +50,7 @@ public class StadiaController extends GenericHID {
/** Frame button. */
kFrame(15);
/** Button value. */
public final int value;
Button(int value) {
@@ -85,6 +86,7 @@ public class StadiaController extends GenericHID {
/** Right Y axis. */
kRightY(4);
/** Axis value. */
public final int value;
Axis(int value) {

View File

@@ -32,6 +32,7 @@ public class SynchronousInterrupt implements AutoCloseable {
/** Both rising and falling edge events. */
kBoth(0x101);
/** WaitResult value. */
public final int value;
WaitResult(int value) {

View File

@@ -6,6 +6,7 @@ package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.ThreadsJNI;
/** Thread utility functions. */
public final class Threads {
/**
* Get the thread priority for the current thread.

View File

@@ -65,6 +65,7 @@ public class TimedRobot extends IterativeRobotBase {
}
}
/** Default loop period. */
public static final double kDefaultPeriod = 0.02;
// The C pointer to the notifier object. We don't use it directly, it is

View File

@@ -108,6 +108,11 @@ public class Ultrasonic implements Sendable, AutoCloseable {
SendableRegistry.addLW(this, "Ultrasonic", m_echoChannel.getChannel());
}
/**
* Returns the echo channel.
*
* @return The echo channel.
*/
public int getEchoChannel() {
return m_echoChannel.getChannel();
}

View File

@@ -15,9 +15,11 @@ public enum EdgeConfiguration {
/** Both rising and falling edge configuration. */
kBoth(true, true);
/** True if triggering on rising edge. */
@SuppressWarnings("MemberName")
public final boolean rising;
/** True if triggering on falling edge. */
@SuppressWarnings("MemberName")
public final boolean falling;

View File

@@ -71,7 +71,10 @@ public class DifferentialDrive extends RobotDriveBase implements Sendable, AutoC
*/
@SuppressWarnings("MemberName")
public static class WheelSpeeds {
/** Left wheel speed. */
public double left;
/** Right wheel speed. */
public double right;
/** Constructs a WheelSpeeds with zeroes for left and right speeds. */

View File

@@ -77,9 +77,16 @@ public class MecanumDrive extends RobotDriveBase implements Sendable, AutoClosea
*/
@SuppressWarnings("MemberName")
public static class WheelSpeeds {
/** Front-left wheel speed. */
public double frontLeft;
/** Front-right wheel speed. */
public double frontRight;
/** Rear-left wheel speed. */
public double rearLeft;
/** Rear-right wheel speed. */
public double rearRight;
/** Constructs a WheelSpeeds with zeroes for all four speeds. */

View File

@@ -12,10 +12,16 @@ import edu.wpi.first.wpilibj.MotorSafety;
* <p>{@link edu.wpi.first.wpilibj.MotorSafety} is enabled by default.
*/
public abstract class RobotDriveBase extends MotorSafety {
/** Default input deadband. */
public static final double kDefaultDeadband = 0.02;
/** Default maximum output. */
public static final double kDefaultMaxOutput = 1.0;
/** Input deadband. */
protected double m_deadband = kDefaultDeadband;
/** Maximum output. */
protected double m_maxOutput = kDefaultMaxOutput;
/** The location of a motor on the robot for the purpose of driving. */
@@ -35,6 +41,7 @@ public abstract class RobotDriveBase extends MotorSafety {
/** Back motor. */
kBack(2);
/** MotorType value. */
public final int value;
MotorType(int value) {

View File

@@ -9,9 +9,7 @@ import edu.wpi.first.util.WPIUtilJNI;
import edu.wpi.first.wpilibj.DriverStation;
import java.util.concurrent.atomic.AtomicBoolean;
/*
* For internal use only.
*/
/** For internal use only. */
public class DriverStationModeThread implements AutoCloseable {
private final AtomicBoolean m_keepAlive = new AtomicBoolean();
private final Thread m_thread;

View File

@@ -67,14 +67,29 @@ public final class LiveWindow {
throw new UnsupportedOperationException("This is a utility class!");
}
/**
* Sets function to be called when LiveWindow is enabled.
*
* @param runnable function (or null for none)
*/
public static synchronized void setEnabledListener(Runnable runnable) {
enabledListener = runnable;
}
/**
* Sets function to be called when LiveWindow is disabled.
*
* @param runnable function (or null for none)
*/
public static synchronized void setDisabledListener(Runnable runnable) {
disabledListener = runnable;
}
/**
* Returns true if LiveWindow is enabled.
*
* @return True if LiveWindow is enabled.
*/
public static synchronized boolean isEnabled() {
return liveWindowEnabled;
}

View File

@@ -37,6 +37,11 @@ public class MotorControllerGroup implements MotorController, Sendable, AutoClos
init();
}
/**
* Create a new MotorControllerGroup with the provided MotorControllers.
*
* @param motorControllers The MotorControllers to add.
*/
@SuppressWarnings("this-escape")
public MotorControllerGroup(MotorController[] motorControllers) {
m_motorControllers = Arrays.copyOf(motorControllers, motorControllers.length);

View File

@@ -17,6 +17,8 @@ public abstract class PWMMotorController extends MotorSafety
implements MotorController, Sendable, AutoCloseable {
private boolean m_isInverted;
private final ArrayList<PWMMotorController> m_followers = new ArrayList<>();
/** PWM instances for motor controller. */
protected PWM m_pwm;
/**

View File

@@ -38,6 +38,11 @@ public enum EventImportance {
m_simpleName = simpleName;
}
/**
* Returns name of the given enum.
*
* @return Name of the given enum.
*/
public String getSimpleName() {
return m_simpleName;
}

View File

@@ -74,7 +74,7 @@ public final class SendableCameraWrapper implements Sendable, AutoCloseable {
}
}
/*
/**
* Sets NetworkTable instance used for camera publisher entries.
*
* @param inst NetworkTable instance

View File

@@ -26,25 +26,53 @@ public abstract class ShuffleboardComponent<C extends ShuffleboardComponent<C>>
private int m_width = -1;
private int m_height = -1;
/**
* Constructs a ShuffleboardComponent.
*
* @param parent The parent container.
* @param title The component title.
* @param type The component type.
*/
protected ShuffleboardComponent(ShuffleboardContainer parent, String title, String type) {
m_parent = requireNonNullParam(parent, "parent", "ShuffleboardComponent");
m_title = requireNonNullParam(title, "title", "ShuffleboardComponent");
m_type = type;
}
/**
* Constructs a ShuffleboardComponent.
*
* @param parent The parent container.
* @param title The component title.
*/
protected ShuffleboardComponent(ShuffleboardContainer parent, String title) {
this(parent, title, null);
}
/**
* Returns the parent container.
*
* @return The parent container.
*/
public final ShuffleboardContainer getParent() {
return m_parent;
}
/**
* Sets the component type.
*
* @param type The component type.
*/
protected final void setType(String type) {
m_type = type;
m_metadataDirty = true;
}
/**
* Returns the component type.
*
* @return The component type.
*/
public final String getType() {
return m_type;
}
@@ -109,6 +137,11 @@ public abstract class ShuffleboardComponent<C extends ShuffleboardComponent<C>>
return (C) this;
}
/**
* Builds NT metadata.
*
* @param metaTable The NT metadata table.
*/
protected final void buildMetadata(NetworkTable metaTable) {
if (!m_metadataDirty) {
return;

View File

@@ -301,6 +301,13 @@ public class DifferentialDrivetrainSim {
m_x.set(State.kRightPosition.value, 0, 0);
}
/**
* The differential drive dynamics function.
*
* @param x The state.
* @param u The input.
* @return The state derivative with respect to time.
*/
protected Matrix<N7, N1> getDynamics(Matrix<N7, N1> x, Matrix<N2, N1> u) {
// Because G can be factored out of B, we can divide by the old ratio and multiply
// by the new ratio to get a new drivetrain model.
@@ -380,6 +387,7 @@ public class DifferentialDrivetrainSim {
/** Gear ratio of 5.95:1. */
k5p95(5.95);
/** KitbotGearing value. */
public final double value;
KitbotGearing(double i) {
@@ -406,6 +414,7 @@ public class DifferentialDrivetrainSim {
/** Two NEO motors per drive side. */
kDoubleNEOPerSide(DCMotor.getNEO(2));
/** KitbotMotor value. */
public final DCMotor value;
KitbotMotor(DCMotor i) {
@@ -422,6 +431,7 @@ public class DifferentialDrivetrainSim {
/** Ten inch diameter wheels. */
kTenInch(Units.inchesToMeters(10));
/** KitbotWheelSize value. */
public final double value;
KitbotWheelSize(double i) {

View File

@@ -8,6 +8,7 @@ import edu.wpi.first.wpilibj.GenericHID;
/** Class to control a simulated generic joystick. */
public class GenericHIDSim {
/** GenericHID port. */
protected final int m_port;
/**

View File

@@ -28,16 +28,19 @@ import org.ejml.simple.SimpleMatrix;
* @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.
/** The plant that represents the linear system. */
protected final LinearSystem<States, Inputs, Outputs> m_plant;
// Variables for state, output, and input.
/** State vector. */
protected Matrix<States, N1> m_x;
protected Matrix<Outputs, N1> m_y;
/** Input vector. */
protected Matrix<Inputs, N1> m_u;
// The standard deviations of measurements, used for adding noise
// to the measurements.
/** Output vector. */
protected Matrix<Outputs, N1> m_y;
/** The standard deviations of measurements, used for adding noise to the measurements. */
protected final Matrix<Outputs, N1> m_measurementStdDevs;
/**

View File

@@ -10,6 +10,7 @@ import edu.wpi.first.wpilibj.PneumaticsModuleType;
/** Common base class for pneumatics module simulation classes. */
public abstract class PneumaticsBaseSim {
/** PneumaticsBase index. */
protected final int m_index;
/**
@@ -30,10 +31,20 @@ public abstract class PneumaticsBaseSim {
}
}
/**
* Constructs a PneumaticsBaseSim with the given index.
*
* @param index The index.
*/
protected PneumaticsBaseSim(int index) {
m_index = index;
}
/**
* Constructs a PneumaticsBaseSim for the given module.
*
* @param module The module.
*/
protected PneumaticsBaseSim(PneumaticsBase module) {
this(module.getModuleNumber());
}

View File

@@ -74,6 +74,13 @@ public class SPISim {
return new CallbackStore(m_index, uid, SPIDataJNI::cancelWriteCallback);
}
/**
* Register a callback to be run whenever an auto receive buffer is received.
*
* @param callback the callback
* @return the {@link CallbackStore} object associated with this callback. Save a reference to
* this object so GC doesn't cancel the callback.
*/
public CallbackStore registerReadAutoReceiveBufferCallback(
SpiReadAutoReceiveBufferCallback callback) {
int uid = SPIDataJNI.registerReadAutoReceiveBufferCallback(m_index, callback);

View File

@@ -19,14 +19,21 @@ public final class SimHooks {
SimulatorJNI.setRuntimeType(type);
}
/** Waits until the user program has started. */
public static void waitForProgramStart() {
SimulatorJNI.waitForProgramStart();
}
/** Sets that the user program has started. */
public static void setProgramStarted() {
SimulatorJNI.setProgramStarted();
}
/**
* Returns true if the user program has started.
*
* @return True if the user program has started.
*/
public static boolean getProgramStarted() {
return SimulatorJNI.getProgramStarted();
}

View File

@@ -36,14 +36,29 @@ public class UltrasonicSim {
m_simRange = simDevice.getDouble("Range (in)");
}
/**
* Sets if the range measurement is valid.
*
* @param valid True if valid
*/
public void setRangeValid(boolean valid) {
m_simRangeValid.set(valid);
}
/**
* Sets the range measurement.
*
* @param inches The range in inches.
*/
public void setRangeInches(double inches) {
m_simRange.set(inches);
}
/**
* Sets the range measurement.
*
* @param meters The range in meters.
*/
public void setRangeMeters(double meters) {
m_simRange.set(Units.metersToInches(meters));
}

View File

@@ -74,6 +74,11 @@ public abstract class MechanismObject2d implements AutoCloseable {
*/
protected abstract void updateEntries(NetworkTable table);
/**
* Retrieve the object's name.
*
* @return the object's name relative to its parent.
*/
public final String getName() {
return m_name;
}

View File

@@ -57,6 +57,7 @@ import java.util.function.LongConsumer;
import java.util.function.LongSupplier;
import java.util.function.Supplier;
/** Implementation detail for SendableBuilder. */
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public class SendableBuilderImpl implements NTSendableBuilder {
@FunctionalInterface