[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

@@ -4,18 +4,25 @@
package edu.wpi.first.hal;
/** Power distribution version. */
@SuppressWarnings("MemberName")
public class PowerDistributionVersion {
/** Firmware major version number. */
public final int firmwareMajor;
/** Firmware minor version number. */
public final int firmwareMinor;
/** Firmware fix version number. */
public final int firmwareFix;
/** Hardware minor version number. */
public final int hardwareMinor;
/** Hardware major version number. */
public final int hardwareMajor;
/** Unique ID. */
public final int uniqueId;
/**

View File

@@ -138,6 +138,8 @@ void HAL_AddDMACounter(HAL_DMAHandle handle, HAL_CounterHandle counterHandle,
/**
* Adds timer data for an counter to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param[in] handle the dma handle
* @param[in] counterHandle the counter to add
* @param[out] status Error status variable. 0 on success.

View File

@@ -217,12 +217,21 @@ void HAL_SetPowerDistributionSwitchableChannel(
HAL_Bool HAL_GetPowerDistributionSwitchableChannel(
HAL_PowerDistributionHandle handle, int32_t* status);
/**
* Power distribution version.
*/
struct HAL_PowerDistributionVersion {
/// Firmware major version number.
uint32_t firmwareMajor;
/// Firmware minor version number.
uint32_t firmwareMinor;
/// Firmware fix version number.
uint32_t firmwareFix;
/// Hardware minor version number.
uint32_t hardwareMinor;
/// Hardware major version number.
uint32_t hardwareMajor;
/// Unique ID.
uint32_t uniqueId;
};

View File

@@ -40,9 +40,9 @@ void DMA::SetPause(bool pause) {
FRC_CheckErrorStatus(status, "SetPause");
}
void DMA::SetTimedTrigger(units::second_t seconds) {
void DMA::SetTimedTrigger(units::second_t period) {
int32_t status = 0;
HAL_SetDMATimedTrigger(dmaHandle, seconds.value(), &status);
HAL_SetDMATimedTrigger(dmaHandle, period.value(), &status);
FRC_CheckErrorStatus(status, "SetTimedTrigger");
}

View File

@@ -23,13 +23,14 @@ DriverStationModeThread::~DriverStationModeThread() {
}
}
void DriverStationModeThread::InAutonomous(bool entering) {
m_userInAutonomous = entering;
}
void DriverStationModeThread::InDisabled(bool entering) {
m_userInDisabled = entering;
}
void DriverStationModeThread::InAutonomous(bool entering) {
m_userInAutonomous = entering;
}
void DriverStationModeThread::InTeleop(bool entering) {
m_userInTeleop = entering;
}

View File

@@ -12,11 +12,6 @@
using namespace frc;
using namespace frc::sim;
PneumaticsBaseSim::PneumaticsBaseSim(int module) : m_index{module} {}
PneumaticsBaseSim::PneumaticsBaseSim(const PneumaticsBase& module)
: m_index{module.GetModuleNumber()} {}
std::shared_ptr<PneumaticsBaseSim> PneumaticsBaseSim::GetForType(
int module, PneumaticsModuleType type) {
switch (type) {
@@ -31,3 +26,8 @@ std::shared_ptr<PneumaticsBaseSim> PneumaticsBaseSim::GetForType(
static_cast<int>(module));
}
}
PneumaticsBaseSim::PneumaticsBaseSim(int module) : m_index{module} {}
PneumaticsBaseSim::PneumaticsBaseSim(const PneumaticsBase& module)
: m_index{module.GetModuleNumber()} {}

View File

@@ -18,8 +18,8 @@ UltrasonicSim::UltrasonicSim(int ping, int echo) {
m_simRange = deviceSim.GetDouble("Range (in)");
}
void UltrasonicSim::SetRangeValid(bool isValid) {
m_simRangeValid.Set(isValid);
void UltrasonicSim::SetRangeValid(bool valid) {
m_simRangeValid.Set(valid);
}
void UltrasonicSim::SetRange(units::inch_t range) {

View File

@@ -170,7 +170,10 @@ class CAN {
*/
static uint64_t GetTimestampBaseTime();
/// Team manufacturer.
static constexpr HAL_CANManufacturer kTeamManufacturer = HAL_CAN_Man_kTeamUse;
/// Team device type.
static constexpr HAL_CANDeviceType kTeamDeviceType =
HAL_CAN_Dev_kMiscellaneous;

View File

@@ -5,10 +5,17 @@
#pragma once
namespace frc {
/**
* Compressor config type.
*/
enum class CompressorConfigType {
/// Disabled.
Disabled = 0,
/// Digital.
Digital = 1,
/// Analog.
Analog = 2,
/// Hybrid.
Hybrid = 3
};

View File

@@ -451,17 +451,20 @@ class Counter : public CounterBase,
void InitSendable(wpi::SendableBuilder& builder) override;
protected:
// Makes the counter count up.
/// Makes the counter count up.
std::shared_ptr<DigitalSource> m_upSource;
// Makes the counter count down.
/// Makes the counter count down.
std::shared_ptr<DigitalSource> m_downSource;
// The FPGA counter object
/// The FPGA counter object
hal::Handle<HAL_CounterHandle> m_counter;
private:
int m_index = 0; // The index of this counter.
/// The index of this counter.
int m_index = 0;
/// Distance of travel for each tick.
double m_distancePerPulse = 1;
friend class DigitalGlitchFilter;

View File

@@ -17,6 +17,9 @@ class DMASample;
class PWM;
class PWMMotorController;
/**
* Class for configuring Direct Memory Access (DMA) of FPGA inputs.
*/
class DMA {
friend class DMASample;
@@ -27,32 +30,162 @@ class DMA {
DMA& operator=(DMA&& other) = default;
DMA(DMA&& other) = default;
/**
* Sets whether DMA is paused.
*
* @param pause True pauses DMA.
*/
void SetPause(bool pause);
void SetTimedTrigger(units::second_t seconds);
/**
* Sets DMA to trigger at an interval.
*
* @param period Period at which to trigger DMA.
*/
void SetTimedTrigger(units::second_t period);
/**
* Sets number of DMA cycles to trigger.
*
* @param cycles Number of cycles.
*/
void SetTimedTriggerCycles(int cycles);
/**
* Adds position data for an encoder to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param encoder Encoder to add to DMA.
*/
void AddEncoder(const Encoder* encoder);
/**
* Adds timer data for an encoder to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param encoder Encoder to add to DMA.
*/
void AddEncoderPeriod(const Encoder* encoder);
/**
* Adds position data for an counter to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param counter Counter to add to DMA.
*/
void AddCounter(const Counter* counter);
/**
* Adds timer data for an counter to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param counter Counter to add to DMA.
*/
void AddCounterPeriod(const Counter* counter);
/**
* Adds a digital source to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param digitalSource DigitalSource to add to DMA.
*/
void AddDigitalSource(const DigitalSource* digitalSource);
/**
* Adds a digital source to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param digitalSource DigitalSource to add to DMA.
*/
void AddDutyCycle(const DutyCycle* digitalSource);
/**
* Adds an analog input to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param analogInput AnalogInput to add to DMA.
*/
void AddAnalogInput(const AnalogInput* analogInput);
/**
* Adds averaged data of an analog input to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param analogInput AnalogInput to add to DMA.
*/
void AddAveragedAnalogInput(const AnalogInput* analogInput);
/**
* Adds accumulator data of an analog input to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param analogInput AnalogInput to add to DMA.
*/
void AddAnalogAccumulator(const AnalogInput* analogInput);
/**
* Sets an external DMA trigger.
*
* @param source the source to trigger from.
* @param rising trigger on rising edge.
* @param falling trigger on falling edge.
* @return the index of the trigger
*/
int SetExternalTrigger(DigitalSource* source, bool rising, bool 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
*/
int SetPwmEdgeTrigger(PWM* pwm, bool rising, bool 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
*/
int SetPwmEdgeTrigger(PWMMotorController* pwm, bool rising, bool falling);
/**
* Clear all sensors from the DMA collection list.
*
* This can only be called if DMA is not started.
*/
void ClearSensors();
/**
* Clear all external triggers from the DMA trigger list.
*
* This can only be called if DMA is not started.
*/
void ClearExternalTriggers();
/**
* Starts DMA Collection.
*
* @param queueDepth The number of objects to be able to queue.
*/
void Start(int queueDepth);
/**
* Stops DMA Collection.
*/
void Stop();
private:

View File

@@ -17,8 +17,14 @@
#include "frc/Encoder.h"
namespace frc {
/**
* DMA sample.
*/
class DMASample : public HAL_DMASample {
public:
/**
* DMA read status.
*/
enum class DMAReadStatus {
/// OK status.
kOk = HAL_DMA_OK,
@@ -28,22 +34,54 @@ class DMASample : public HAL_DMASample {
kError = HAL_DMA_ERROR
};
/**
* Retrieves a new DMA sample.
*
* @param dma DMA object.
* @param timeout Timeout for retrieval.
* @param remaining Number of remaining samples.
* @param status DMA read status.
*/
DMAReadStatus Update(const DMA* dma, units::second_t timeout,
int32_t* remaining, int32_t* status) {
return static_cast<DMAReadStatus>(
HAL_ReadDMA(dma->dmaHandle, this, timeout.value(), remaining, status));
}
/**
* Returns the DMA sample time in microseconds.
*
* @return The DMA sample time in microseconds.
*/
uint64_t GetTime() const { return timeStamp; }
/**
* Returns the DMA sample timestamp.
*
* @return The DMA sample timestamp.
*/
units::second_t GetTimeStamp() const {
return units::second_t{static_cast<double>(GetTime()) * 1.0e-6};
}
/**
* Returns raw encoder value from DMA.
*
* @param encoder Encoder used for DMA.
* @param status DMA read status.
* @return Raw encoder value from DMA.
*/
int32_t GetEncoderRaw(const Encoder* encoder, int32_t* status) const {
return HAL_GetDMASampleEncoderRaw(this, encoder->m_encoder, status);
}
/**
* Returns encoder distance from DMA.
*
* @param encoder Encoder used for DMA.
* @param status DMA read status.
* @return Encoder distance from DMA.
*/
double GetEncoderDistance(const Encoder* encoder, int32_t* status) const {
double val = GetEncoderRaw(encoder, status);
val *= encoder->DecodingScaleFactor();
@@ -51,41 +89,97 @@ class DMASample : public HAL_DMASample {
return val;
}
/**
* Returns raw encoder period from DMA.
*
* @param encoder Encoder used for DMA.
* @param status DMA read status.
* @return Raw encoder period from DMA.
*/
int32_t GetEncoderPeriodRaw(const Encoder* encoder, int32_t* status) const {
return HAL_GetDMASampleEncoderPeriodRaw(this, encoder->m_encoder, status);
}
/**
* Returns counter value from DMA.
*
* @param counter Counter used for DMA.
* @param status DMA read status.
* @return Counter value from DMA.
*/
int32_t GetCounter(const Counter* counter, int32_t* status) const {
return HAL_GetDMASampleCounter(this, counter->m_counter, status);
}
/**
* Returns counter period from DMA.
*
* @param counter Counter used for DMA.
* @param status DMA read status.
* @return Counter period from DMA.
*/
int32_t GetCounterPeriod(const Counter* counter, int32_t* status) const {
return HAL_GetDMASampleCounterPeriod(this, counter->m_counter, status);
}
/**
* Returns digital source value from DMA.
*
* @param digitalSource DigitalSource used for DMA.
* @param status DMA read status.
* @return DigitalSource value from DMA.
*/
bool GetDigitalSource(const DigitalSource* digitalSource,
int32_t* status) const {
return HAL_GetDMASampleDigitalSource(
this, digitalSource->GetPortHandleForRouting(), status);
}
/**
* Returns raw analog input value from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @param status DMA read status.
* @return Raw analog input value from DMA.
*/
int32_t GetAnalogInputRaw(const AnalogInput* analogInput,
int32_t* status) const {
return HAL_GetDMASampleAnalogInputRaw(this, analogInput->m_port, status);
}
/**
* Returns analog input voltage from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @param status DMA read status.
* @return Analog input voltage from DMA.
*/
double GetAnalogInputVoltage(const AnalogInput* analogInput,
int32_t* status) {
return HAL_GetAnalogValueToVolts(
analogInput->m_port, GetAnalogInputRaw(analogInput, status), status);
}
/**
* Returns averaged analog input raw value from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @param status DMA read status.
* @return Averaged analog input raw value from DMA.
*/
int32_t GetAveragedAnalogInputRaw(const AnalogInput* analogInput,
int32_t* status) const {
return HAL_GetDMASampleAveragedAnalogInputRaw(this, analogInput->m_port,
status);
}
/**
* Returns averaged analog input voltage from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @param status DMA read status.
* @return Averaged analog input voltage from DMA.
*/
double GetAveragedAnalogInputVoltage(const AnalogInput* analogInput,
int32_t* status) {
return HAL_GetAnalogValueToVolts(
@@ -93,18 +187,40 @@ class DMASample : public HAL_DMASample {
status);
}
/**
* Returns analog accumulator value from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @param count Accumulator sample count.
* @param value Accumulator value.
* @param status DMA read status.
*/
void GetAnalogAccumulator(const AnalogInput* analogInput, int64_t* count,
int64_t* value, int32_t* status) const {
return HAL_GetDMASampleAnalogAccumulator(this, analogInput->m_port, count,
value, status);
}
/**
* Returns raw duty cycle output from DMA.
*
* @param dutyCycle DutyCycle used for DMA.
* @param status DMA read status.
* @return Raw duty cycle output from DMA.
*/
int32_t GetDutyCycleOutputRaw(const DutyCycle* dutyCycle,
int32_t* status) const {
return HAL_GetDMASampleDutyCycleOutputRaw(this, dutyCycle->m_handle,
status);
}
/**
* Returns duty cycle output (0-1) from DMA.
*
* @param dutyCycle DutyCycle used for DMA.
* @param status DMA read status.
* @return Duty cycle output (0-1) from DMA.
*/
double GetDutyCycleOutput(const DutyCycle* dutyCycle, int32_t* status) {
return GetDutyCycleOutputRaw(dutyCycle, status) /
static_cast<double>(dutyCycle->GetOutputScaleFactor());

View File

@@ -355,9 +355,25 @@ class DriverStation final {
*/
static double GetBatteryVoltage();
/**
* Copy data from the DS task for the user. If no new data exists, it will
* just be returned, otherwise the data will be copied from the DS polling
* loop.
*/
static void RefreshData();
/**
* Registers the given handle for DS data refresh notifications.
*
* @param handle The event handle.
*/
static void ProvideRefreshedDataEventHandle(WPI_EventHandle handle);
/**
* Unregisters the given handle from DS data refresh notifications.
*
* @param handle The event handle.
*/
static void RemoveRefreshedDataEventHandle(WPI_EventHandle handle);
/**

View File

@@ -45,7 +45,18 @@ class I2C {
I2C(I2C&&) = default;
I2C& operator=(I2C&&) = default;
/**
* Returns I2C port.
*
* @return I2C port.
*/
Port GetPort() const;
/**
* Returns I2C device address.
*
* @return I2C device address.
*/
int GetDeviceAddress() const;
/**

View File

@@ -243,6 +243,9 @@ class IterativeRobotBase : public RobotBase {
IterativeRobotBase(IterativeRobotBase&&) = default;
IterativeRobotBase& operator=(IterativeRobotBase&&) = default;
/**
* Loop function.
*/
void LoopFunc();
private:

View File

@@ -22,10 +22,15 @@ namespace frc {
*/
class Joystick : public GenericHID {
public:
/// Default X axis channel.
static constexpr int kDefaultXChannel = 0;
/// Default Y axis channel.
static constexpr int kDefaultYChannel = 1;
/// Default Z axis channel.
static constexpr int kDefaultZChannel = 2;
/// Default twist axis channel.
static constexpr int kDefaultTwistChannel = 2;
/// Default throttle axis channel.
static constexpr int kDefaultThrottleChannel = 3;
/**

View File

@@ -93,12 +93,15 @@ class MotorSafety {
*/
static void CheckMotors();
/**
* Called to stop the motor when the timeout expires.
*/
virtual void StopMotor() = 0;
/**
* The return value from this method is printed out when an error occurs
* Returns a description to print when an error occurs.
*
* This method must not throw!
* @return Description to print when an error occurs.
*/
virtual std::string GetDescription() const = 0;

View File

@@ -144,6 +144,9 @@ class PWM : public wpi::Sendable, public wpi::SendableHelper<PWM> {
*/
void SetPeriodMultiplier(PeriodMultiplier mult);
/**
* Latches PWM to zero.
*/
void SetZeroLatch();
/**

View File

@@ -18,6 +18,10 @@ namespace frc {
class Solenoid;
class DoubleSolenoid;
class Compressor;
/**
* Base class for pneumatics devices.
*/
class PneumaticsBase {
public:
virtual ~PneumaticsBase() = default;

View File

@@ -5,5 +5,13 @@
#pragma once
namespace frc {
enum class PneumaticsModuleType { CTREPCM, REVPH };
/**
* Pneumatics module type.
*/
enum class PneumaticsModuleType {
/// CTRE PCM.
CTREPCM,
/// REV PH.
REVPH
};
} // namespace frc

View File

@@ -17,6 +17,7 @@ namespace frc {
class PowerDistribution : public wpi::Sendable,
public wpi::SendableHelper<PowerDistribution> {
public:
/// Default module number.
static constexpr int kDefaultModule = -1;
/**
@@ -179,6 +180,11 @@ class PowerDistribution : public wpi::Sendable,
bool GetBreakerFault(int channel) const;
};
/**
* Returns the power distribution faults.
*
* @return The power distribution faults.
*/
Faults GetFaults() const;
struct StickyFaults {
@@ -222,6 +228,11 @@ class PowerDistribution : public wpi::Sendable,
bool GetBreakerFault(int channel) const;
};
/**
* Returns the power distribution sticky faults.
*
* @return The power distribution sticky faults.
*/
StickyFaults GetStickyFaults() const;
void InitSendable(wpi::SendableBuilder& builder) override;

View File

@@ -189,7 +189,9 @@ class RobotBase {
bool IsTestEnabled() const;
/**
* Gets the ID of the main robot thread.
* Returns the main thread ID.
*
* @return The main thread ID.
*/
static std::thread::id GetThreadId();

View File

@@ -6,15 +6,53 @@
namespace frc {
/**
* Robot state utility functions.
*/
class RobotState {
public:
RobotState() = delete;
/**
* Returns true if the robot is disabled.
*
* @return True if the robot is disabled.
*/
static bool IsDisabled();
/**
* Returns true if the robot is enabled.
*
* @return True if the robot is enabled.
*/
static bool IsEnabled();
/**
* Returns true if the robot is E-stopped.
*
* @return True if the robot is E-stopped.
*/
static bool IsEStopped();
/**
* Returns true if the robot is in teleop mode.
*
* @return True if the robot is in teleop mode.
*/
static bool IsTeleop();
/**
* Returns true if the robot is in autonomous mode.
*
* @return True if the robot is in autonomous mode.
*/
static bool IsAutonomous();
/**
* Returns true if the robot is in test mode.
*
* @return True if the robot is in test mode.
*/
static bool IsTest();
};

View File

@@ -5,5 +5,15 @@
#pragma once
namespace frc {
enum RuntimeType { kRoboRIO, kRoboRIO2, kSimulation };
/**
* Runtime type.
*/
enum RuntimeType {
/// roboRIO 1.0.
kRoboRIO,
/// roboRIO 2.0.
kRoboRIO2,
/// Simulation runtime.
kSimulation
};
} // namespace frc

View File

@@ -67,6 +67,11 @@ class SPI {
SPI(SPI&&) = default;
SPI& operator=(SPI&&) = default;
/**
* Returns the SPI port.
*
* @return The SPI port.
*/
Port GetPort() const;
/**

View File

@@ -19,6 +19,11 @@ namespace frc {
class Servo : public PWM {
public:
/**
* Constructor.
*
* By default, 2.4 ms is used as the max PWM value and 0.6 ms is used as the
* min PWM 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

@@ -29,6 +29,7 @@ namespace frc {
*/
class TimedRobot : public IterativeRobotBase {
public:
/// Default loop period.
static constexpr auto kDefaultPeriod = 20_ms;
/**

View File

@@ -90,6 +90,11 @@ class Ultrasonic : public wpi::Sendable,
Ultrasonic(Ultrasonic&&) = default;
Ultrasonic& operator=(Ultrasonic&&) = default;
/**
* Returns the echo channel.
*
* @return The echo channel.
*/
int GetEchoChannel() const;
/**

View File

@@ -65,7 +65,9 @@ class DifferentialDrive : public RobotDriveBase,
* Uses normalized voltage [-1.0..1.0].
*/
struct WheelSpeeds {
/// Left wheel speed.
double left = 0.0;
/// Right wheel speed.
double right = 0.0;
};

View File

@@ -65,9 +65,13 @@ class MecanumDrive : public RobotDriveBase,
* Uses normalized voltage [-1.0..1.0].
*/
struct WheelSpeeds {
/// Front-left wheel speed.
double frontLeft = 0.0;
/// Front-right wheel speed.
double frontRight = 0.0;
/// Rear-left wheel speed.
double rearLeft = 0.0;
/// Rear-right wheel speed.
double rearRight = 0.0;
};

View File

@@ -77,14 +77,23 @@ class RobotDriveBase : public MotorSafety {
std::string GetDescription() const override = 0;
protected:
/// Default input deadband.
static constexpr double kDefaultDeadband = 0.02;
/// Default maximum output.
static constexpr double kDefaultMaxOutput = 1.0;
/**
* Renormalize all wheel speeds if the magnitude of any wheel is greater than
* 1.0.
*/
static void Desaturate(std::span<double> wheelSpeeds);
double m_deadband = 0.02;
double m_maxOutput = 1.0;
/// Input deadband.
double m_deadband = kDefaultDeadband;
/// Maximum output.
double m_maxOutput = kDefaultMaxOutput;
};
} // namespace frc

View File

@@ -8,9 +8,16 @@
#include <thread>
namespace frc::internal {
/**
* For internal use only.
*/
class DriverStationModeThread {
public:
/**
* For internal use only.
*/
DriverStationModeThread();
~DriverStationModeThread();
DriverStationModeThread(const DriverStationModeThread& other) = delete;
@@ -19,9 +26,39 @@ class DriverStationModeThread {
delete;
DriverStationModeThread& operator=(DriverStationModeThread&& other) = delete;
void InAutonomous(bool entering);
/**
* Only to be used to tell the Driver Station what code you claim to be
* executing for diagnostic purposes only.
*
* @param entering If true, starting disabled code; if false, leaving disabled
* code
*/
void InDisabled(bool entering);
/**
* Only to be used to tell the Driver Station what code you claim to be
* executing for diagnostic purposes only.
*
* @param entering If true, starting autonomous code; if false, leaving
* autonomous code
*/
void InAutonomous(bool entering);
/**
* Only to be used to tell the Driver Station what code you claim to be
* executing for diagnostic purposes only.
*
* @param entering If true, starting teleop code; if false, leaving teleop
* code
*/
void InTeleop(bool entering);
/**
* Only to be used to tell the Driver Station what code you claim to be
* executing for diagnostic purposes only.
*
* @param entering If true, starting test code; if false, leaving test code
*/
void InTest(bool entering);
private:

View File

@@ -19,14 +19,14 @@ namespace frc {
class LiveWindow final {
public:
/**
* Set function to be called when LiveWindow is enabled.
* Sets function to be called when LiveWindow is enabled.
*
* @param func function (or nullptr for none)
*/
static void SetEnabledCallback(std::function<void()> func);
/**
* Set function to be called when LiveWindow is disabled.
* Sets function to be called when LiveWindow is disabled.
*
* @param func function (or nullptr for none)
*/
@@ -56,6 +56,11 @@ class LiveWindow final {
*/
static void EnableAllTelemetry();
/**
* Returns true if LiveWindow is enabled.
*
* @return True if LiveWindow is enabled.
*/
static bool IsEnabled();
/**

View File

@@ -27,9 +27,22 @@ class [[deprecated(
public MotorController,
public wpi::SendableHelper<MotorControllerGroup> {
public:
/**
* Create a new MotorControllerGroup with the provided MotorControllers.
*
* @tparam MotorControllers The MotorController types.
* @param motorController The first MotorController to add
* @param motorControllers The MotorControllers to add
*/
template <class... MotorControllers>
explicit MotorControllerGroup(MotorController& motorController,
MotorControllers&... motorControllers);
/**
* Create a new MotorControllerGroup with the provided MotorControllers.
*
* @param motorControllers The MotorControllers to add.
*/
explicit MotorControllerGroup(
std::vector<std::reference_wrapper<MotorController>>&& motorControllers);

View File

@@ -124,6 +124,7 @@ class PWMMotorController : public MotorController,
void InitSendable(wpi::SendableBuilder& builder) override;
/// PWM instances for motor controller.
PWM m_pwm;
private:

View File

@@ -26,6 +26,13 @@ class ShuffleboardContainer;
template <typename Derived>
class ShuffleboardComponent : public ShuffleboardComponentBase {
public:
/**
* Constructs a ShuffleboardComponent.
*
* @param parent The parent container.
* @param title The component title.
* @param type The component type.
*/
ShuffleboardComponent(ShuffleboardContainer& parent, std::string_view title,
std::string_view type = "");

View File

@@ -14,6 +14,11 @@ namespace frc {
enum ShuffleboardEventImportance { kTrivial, kLow, kNormal, kHigh, kCritical };
/**
* Returns name of the given enum.
*
* @return Name of the given enum.
*/
inline std::string_view ShuffleboardEventImportanceName(
ShuffleboardEventImportance importance) {
switch (importance) {

View File

@@ -187,6 +187,13 @@ class DifferentialDrivetrainSim {
*/
void SetPose(const frc::Pose2d& pose);
/**
* The differential drive dynamics function.
*
* @param x The state.
* @param u The input.
* @return The state derivative with respect to time.
*/
Vectord<7> Dynamics(const Vectord<7>& x, const Eigen::Vector2d& u);
class State {

View File

@@ -136,6 +136,7 @@ class GenericHIDSim {
double GetRumble(GenericHID::RumbleType type);
protected:
/// GenericHID port.
int m_port;
};

View File

@@ -140,11 +140,20 @@ class LinearSystemSim {
u, frc::RobotController::GetInputVoltage());
}
/// The plant that represents the linear system.
LinearSystem<States, Inputs, Outputs> m_plant;
/// State vector.
Vectord<States> m_x;
Vectord<Outputs> m_y;
/// Input vector.
Vectord<Inputs> m_u;
/// Output vector.
Vectord<Outputs> m_y;
/// The standard deviations of measurements, used for adding noise to the
/// measurements.
std::array<double, Outputs> m_measurementStdDevs;
};
} // namespace frc::sim

View File

@@ -177,9 +177,22 @@ class PneumaticsBaseSim {
virtual void ResetData() = 0;
protected:
/// PneumaticsBase index.
const int m_index;
explicit PneumaticsBaseSim(const PneumaticsBase& module);
/**
* Constructs a PneumaticsBaseSim with the given index.
*
* @param index The index.
*/
explicit PneumaticsBaseSim(const int index);
/**
* Constructs a PneumaticsBaseSim for the given module.
*
* @param module The module.
*/
explicit PneumaticsBaseSim(const PneumaticsBase& module);
};
} // namespace frc::sim

View File

@@ -36,14 +36,14 @@ class UltrasonicSim {
/**
* Sets if the range measurement is valid.
*
* @param isValid True if valid
* @param valid True if valid
*/
void SetRangeValid(bool isValid);
void SetRangeValid(bool valid);
/**
* Sets the range measurement
* Sets the range measurement.
*
* @param range The range
* @param range The range.
*/
void SetRange(units::inch_t range);

View File

@@ -21,6 +21,9 @@
namespace frc {
/**
* Implementation detail for SendableBuilder.
*/
class SendableBuilderImpl : public nt::NTSendableBuilder {
public:
SendableBuilderImpl() = default;

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