[docs] Add missing JavaDocs (#6146)

This commit is contained in:
Tyler Veness
2024-01-04 08:38:06 -08:00
committed by GitHub
parent 6e58db398d
commit f29a7d2e50
145 changed files with 1106 additions and 94 deletions

View File

@@ -33,10 +33,10 @@ class WPILIB_DLLEXPORT ArmFeedforward {
/**
* Creates a new ArmFeedforward with the specified gains.
*
* @param kS The static gain, in volts.
* @param kS The static gain, in volts.
* @param kG The gravity gain, in volts.
* @param kV The velocity gain, in volt seconds per radian.
* @param kA The acceleration gain, in volt seconds² per radian.
* @param kV The velocity gain, in volt seconds per radian.
* @param kA The acceleration gain, in volt seconds² per radian.
*/
constexpr ArmFeedforward(
units::volt_t kS, units::volt_t kG, units::unit_t<kv_unit> kV,
@@ -175,9 +175,16 @@ class WPILIB_DLLEXPORT ArmFeedforward {
return MaxAchievableAcceleration(-maxVoltage, angle, velocity);
}
/// The static gain, in volts.
const units::volt_t kS;
/// The gravity gain, in volts.
const units::volt_t kG;
/// The velocity gain, in volt seconds per radian.
const units::unit_t<kv_unit> kV;
/// The acceleration gain, in volt seconds² per radian.
const units::unit_t<ka_unit> kA;
};
} // namespace frc

View File

@@ -12,7 +12,10 @@ namespace frc {
* Motor voltages for a differential drive.
*/
struct DifferentialDriveWheelVoltages {
/// Left wheel voltage.
units::volt_t left = 0_V;
/// Right wheel voltage.
units::volt_t right = 0_V;
};

View File

@@ -182,9 +182,16 @@ class ElevatorFeedforward {
return MaxAchievableAcceleration(-maxVoltage, velocity);
}
/// The static gain.
const units::volt_t kS;
/// The gravity gain.
const units::volt_t kG;
/// The velocity gain.
const units::unit_t<kv_unit> kV;
/// The acceleration gain.
const units::unit_t<ka_unit> kA;
};
} // namespace frc

View File

@@ -160,8 +160,13 @@ class SimpleMotorFeedforward {
return MaxAchievableAcceleration(-maxVoltage, velocity);
}
/** The static gain. */
const units::volt_t kS;
/** The velocity gain. */
const units::unit_t<kv_unit> kV;
/** The acceleration gain. */
const units::unit_t<ka_unit> kA;
};
} // namespace frc

View File

@@ -16,13 +16,28 @@
namespace frc {
/**
* This class incorporates time-delayed measurements into a Kalman filter's
* state estimate.
*
* @tparam States The number of states.
* @tparam Inputs The number of inputs.
* @tparam Outputs The number of outputs.
*/
template <int States, int Inputs, int Outputs, typename KalmanFilterType>
class KalmanFilterLatencyCompensator {
public:
/**
* This class contains all the information about our observer at a given time.
*/
struct ObserverSnapshot {
/// The state estimate.
Vectord<States> xHat;
/// The square root error covariance.
Matrixd<States, States> squareRootErrorCovariances;
/// The inputs.
Vectord<Inputs> inputs;
/// The local measurements.
Vectord<Outputs> localMeasurements;
ObserverSnapshot(const KalmanFilterType& observer, const Vectord<Inputs>& u,

View File

@@ -17,7 +17,17 @@ namespace frc {
*/
class WPILIB_DLLEXPORT Debouncer {
public:
enum DebounceType { kRising, kFalling, kBoth };
/**
* Type of debouncing to perform.
*/
enum DebounceType {
/// Rising edge.
kRising,
/// Falling edge.
kFalling,
/// Both rising and falling edges.
kBoth
};
/**
* Creates a new Debouncer.

View File

@@ -10,6 +10,9 @@
namespace frc {
/**
* Represents a quaternion.
*/
class WPILIB_DLLEXPORT Quaternion {
public:
/**

View File

@@ -88,6 +88,7 @@ class WPILIB_DLLEXPORT DifferentialDriveKinematics
return ToTwist2d(end.left - start.left, end.right - start.right);
}
/// Differential drive trackwidth.
units::meter_t trackWidth;
};
} // namespace frc

View File

@@ -138,10 +138,33 @@ class WPILIB_DLLEXPORT MecanumDriveKinematics
*/
Twist2d ToTwist2d(const MecanumDriveWheelPositions& wheelDeltas) const;
const Translation2d GetFrontLeftWheel() const { return m_frontLeftWheel; }
const Translation2d GetFrontRightWheel() const { return m_frontRightWheel; }
const Translation2d GetRearLeftWheel() const { return m_rearLeftWheel; }
const Translation2d GetRearRightWheel() const { return m_rearRightWheel; }
/**
* Returns the front-left wheel translation.
*
* @return The front-left wheel translation.
*/
const Translation2d& GetFrontLeft() const { return m_frontLeftWheel; }
/**
* Returns the front-right wheel translation.
*
* @return The front-right wheel translation.
*/
const Translation2d& GetFrontRight() const { return m_frontRightWheel; }
/**
* Returns the rear-left wheel translation.
*
* @return The rear-left wheel translation.
*/
const Translation2d& GetRearLeft() const { return m_rearLeftWheel; }
/**
* Returns the rear-right wheel translation.
*
* @return The rear-right wheel translation.
*/
const Translation2d& GetRearRight() const { return m_rearRightWheel; }
private:
mutable Matrixd<4, 3> m_inverseKinematics;

View File

@@ -44,7 +44,10 @@ class Spline {
* dimension.
*/
struct ControlVector {
/// The x components of the control vector.
wpi::array<double, (Degree + 1) / 2> x;
/// The y components of the control vector.
wpi::array<double, (Degree + 1) / 2> y;
};

View File

@@ -26,19 +26,28 @@ class WPILIB_DLLEXPORT DCMotor {
units::unit_t<units::compound_unit<units::newton_meters,
units::inverse<units::ampere>>>;
/// Voltage at which the motor constants were measured.
units::volt_t nominalVoltage;
/// Torque when stalled.
units::newton_meter_t stallTorque;
/// Current draw when stalled.
units::ampere_t stallCurrent;
/// Current draw under no load.
units::ampere_t freeCurrent;
/// Angular velocity under no load.
units::radians_per_second_t freeSpeed;
// Resistance of motor
/// Motor internal resistance.
units::ohm_t R;
// Motor velocity constant
/// Motor velocity constant.
radians_per_second_per_volt_t Kv;
// Torque constant
/// Motor torque constant.
newton_meters_per_ampere_t Kt;
/**

View File

@@ -20,6 +20,9 @@
#include "units/voltage.h"
namespace frc {
/**
* Linear system ID utility functions.
*/
class WPILIB_DLLEXPORT LinearSystemId {
public:
template <typename Distance>

View File

@@ -55,36 +55,80 @@ class ExponentialProfile {
using KA = units::compound_unit<Input, units::inverse<Acceleration>>;
using kA_t = units::unit_t<KA>;
/**
* Profile timing.
*/
class ProfileTiming {
public:
/// Profile inflection time.
units::second_t inflectionTime;
/// Total profile time.
units::second_t totalTime;
/**
* Decides if the profile is finished by time t.
*
* @param t The time since the beginning of the profile.
* @return if the profile is finished at time t.
*/
bool IsFinished(const units::second_t& t) const { return t >= totalTime; }
};
/**
* Profile constraints.
*/
class Constraints {
public:
/**
* Construct constraints for an ExponentialProfile.
*
* @param maxInput maximum unsigned input voltage
* @param A The State-Space 1x1 system matrix.
* @param B The State-Space 1x1 input matrix.
*/
Constraints(Input_t maxInput, A_t A, B_t B)
: maxInput{maxInput}, A{A}, B{B} {}
/**
* Construct constraints for an ExponentialProfile from characteristics.
*
* @param maxInput maximum unsigned input voltage
* @param kV The velocity gain.
* @param kA The acceleration gain.
*/
Constraints(Input_t maxInput, kV_t kV, kA_t kA)
: maxInput{maxInput}, A{-kV / kA}, B{1 / kA} {}
/**
* Computes the max achievable velocity for an Exponential Profile.
*
* @return The seady-state velocity achieved by this profile.
*/
Velocity_t MaxVelocity() const { return -maxInput * B / A; }
/// Maximum unsigned input voltage.
Input_t maxInput{0};
/// The State-Space 1x1 system matrix.
A_t A{0};
/// The State-Space 1x1 input matrix.
B_t B{0};
};
/** Profile state. */
class State {
public:
/// The position at this state.
Distance_t position{0};
/// The velocity at this state.
Velocity_t velocity{0};
bool operator==(const State&) const = default;
};
class ProfileTiming {
public:
units::second_t inflectionTime;
units::second_t totalTime;
bool IsFinished(const units::second_t& time) const {
return time > totalTime;
}
};
/**
* Construct a ExponentialProfile.
*

View File

@@ -28,19 +28,19 @@ class WPILIB_DLLEXPORT Trajectory {
* Represents one point on the trajectory.
*/
struct WPILIB_DLLEXPORT State {
// The time elapsed since the beginning of the trajectory.
/// The time elapsed since the beginning of the trajectory.
units::second_t t = 0_s;
// The speed at that point of the trajectory.
/// The speed at that point of the trajectory.
units::meters_per_second_t velocity = 0_mps;
// The acceleration at that point of the trajectory.
/// The acceleration at that point of the trajectory.
units::meters_per_second_squared_t acceleration = 0_mps_sq;
// The pose at that point of the trajectory.
/// The pose at that point of the trajectory.
Pose2d pose;
// The curvature at that point of the trajectory.
/// The curvature at that point of the trajectory.
units::curvature_t curvature{0.0};
/**

View File

@@ -12,6 +12,9 @@
#include "frc/trajectory/Trajectory.h"
namespace frc {
/**
* Trajectory utilities.
*/
class WPILIB_DLLEXPORT TrajectoryUtil {
public:
TrajectoryUtil() = delete;

View File

@@ -52,25 +52,49 @@ class TrapezoidProfile {
units::compound_unit<Velocity, units::inverse<units::seconds>>;
using Acceleration_t = units::unit_t<Acceleration>;
/**
* Profile constraints.
*/
class Constraints {
public:
/// Maximum velocity.
Velocity_t maxVelocity{0};
/// Maximum acceleration.
Acceleration_t maxAcceleration{0};
/**
* Default constructor.
*/
Constraints() {
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kTrajectory_TrapezoidProfile, 1);
}
Constraints(Velocity_t maxVelocity_, Acceleration_t maxAcceleration_)
: maxVelocity{maxVelocity_}, maxAcceleration{maxAcceleration_} {
/**
* Constructs constraints for a Trapezoid Profile.
*
* @param maxVelocity Maximum velocity.
* @param maxAcceleration Maximum acceleration.
*/
Constraints(Velocity_t maxVelocity, Acceleration_t maxAcceleration)
: maxVelocity{maxVelocity}, maxAcceleration{maxAcceleration} {
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kTrajectory_TrapezoidProfile, 1);
}
Velocity_t maxVelocity{0};
Acceleration_t maxAcceleration{0};
};
/**
* Profile state.
*/
class State {
public:
/// The position at this state.
Distance_t position{0};
/// The velocity at this state.
Velocity_t velocity{0};
bool operator==(const State&) const = default;
};