mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[docs] Fix wpilibj JavaDoc warnings (#6154)
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -243,6 +243,9 @@ class IterativeRobotBase : public RobotBase {
|
||||
IterativeRobotBase(IterativeRobotBase&&) = default;
|
||||
IterativeRobotBase& operator=(IterativeRobotBase&&) = default;
|
||||
|
||||
/**
|
||||
* Loop function.
|
||||
*/
|
||||
void LoopFunc();
|
||||
|
||||
private:
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -144,6 +144,9 @@ class PWM : public wpi::Sendable, public wpi::SendableHelper<PWM> {
|
||||
*/
|
||||
void SetPeriodMultiplier(PeriodMultiplier mult);
|
||||
|
||||
/**
|
||||
* Latches PWM to zero.
|
||||
*/
|
||||
void SetZeroLatch();
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,10 @@ namespace frc {
|
||||
class Solenoid;
|
||||
class DoubleSolenoid;
|
||||
class Compressor;
|
||||
|
||||
/**
|
||||
* Base class for pneumatics devices.
|
||||
*/
|
||||
class PneumaticsBase {
|
||||
public:
|
||||
virtual ~PneumaticsBase() = default;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -67,6 +67,11 @@ class SPI {
|
||||
SPI(SPI&&) = default;
|
||||
SPI& operator=(SPI&&) = default;
|
||||
|
||||
/**
|
||||
* Returns the SPI port.
|
||||
*
|
||||
* @return The SPI port.
|
||||
*/
|
||||
Port GetPort() const;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace frc {
|
||||
*/
|
||||
class TimedRobot : public IterativeRobotBase {
|
||||
public:
|
||||
/// Default loop period.
|
||||
static constexpr auto kDefaultPeriod = 20_ms;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ class PWMMotorController : public MotorController,
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
/// PWM instances for motor controller.
|
||||
PWM m_pwm;
|
||||
|
||||
private:
|
||||
|
||||
@@ -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 = "");
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -136,6 +136,7 @@ class GenericHIDSim {
|
||||
double GetRumble(GenericHID::RumbleType type);
|
||||
|
||||
protected:
|
||||
/// GenericHID port.
|
||||
int m_port;
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Implementation detail for SendableBuilder.
|
||||
*/
|
||||
class SendableBuilderImpl : public nt::NTSendableBuilder {
|
||||
public:
|
||||
SendableBuilderImpl() = default;
|
||||
|
||||
Reference in New Issue
Block a user