From f29a7d2e501be363c821e15da4fab8eceba2bc5b Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Thu, 4 Jan 2024 08:38:06 -0800 Subject: [PATCH] [docs] Add missing JavaDocs (#6146) --- .../wpi/first/apriltag/AprilTagDetector.java | 26 +++++ .../first/apriltag/AprilTagFieldLayout.java | 3 + .../wpi/first/apriltag/AprilTagFields.java | 5 + .../first/apriltag/AprilTagPoseEstimator.java | 9 ++ .../frc/apriltag/AprilTagFieldLayout.h | 5 + .../include/frc/apriltag/AprilTagFields.h | 5 + .../wpi/first/cameraserver/CameraServer.java | 1 + .../cameraserver/CameraServerShared.java | 1 + .../cameraserver/CameraServerSharedStore.java | 1 + .../include/cameraserver/CameraServer.h | 4 +- .../src/main/generate/WPILibVersion.cpp.in | 2 +- glass/src/app/generate/WPILibVersion.cpp.in | 2 +- .../first/hal/simulation/BufferCallback.java | 8 ++ .../src/main/generate/WPILibVersion.cpp.in | 2 +- .../src/main/generate/WPILibVersion.cpp.in | 2 +- sysid/src/main/generate/WPILibVersion.cpp.in | 2 +- .../wpi/first/wpilibj2/command/Command.java | 2 + .../first/wpilibj2/command/CommandBase.java | 7 +- .../first/wpilibj2/command/PIDCommand.java | 7 ++ .../first/wpilibj2/command/PIDSubsystem.java | 8 ++ .../wpilibj2/command/ProfiledPIDCommand.java | 7 ++ .../command/ProfiledPIDSubsystem.java | 8 ++ .../first/wpilibj2/command/WaitCommand.java | 2 + .../command/button/InternalButton.java | 10 ++ .../native/include/frc2/command/Command.h | 1 + .../native/include/frc2/command/PIDCommand.h | 7 ++ .../include/frc2/command/PIDSubsystem.h | 3 + .../include/frc2/command/ProfiledPIDCommand.h | 7 ++ .../frc2/command/ProfiledPIDSubsystem.h | 3 + .../native/include/frc2/command/WaitCommand.h | 1 + wpilibc/src/generate/WPILibVersion.cpp.in | 2 +- .../src/main/native/include/frc/util/Color.h | 5 + .../main/native/include/frc/util/Color8Bit.h | 5 + wpilibj/src/generate/WPILibVersion.java.in | 7 +- .../first/wpilibj/simulation/SimHooks.java | 1 + .../edu/wpi/first/wpilibj/util/Color.java | 6 + .../edu/wpi/first/wpilibj/util/Color8Bit.java | 5 + wpimath/src/generate/main/java/Nat.java.jinja | 5 + .../main/java/edu/wpi/first/math/Nat.java | 105 ++++++++++++++++++ .../wpi/first/math/ComputerVisionUtil.java | 1 + .../main/java/edu/wpi/first/math/DARE.java | 1 + .../math/InterpolatingMatrixTreeMap.java | 3 + .../java/edu/wpi/first/math/MatBuilder.java | 3 + .../java/edu/wpi/first/math/MathShared.java | 1 + .../edu/wpi/first/math/MathSharedStore.java | 1 + .../java/edu/wpi/first/math/MathUsageId.java | 20 ++++ .../java/edu/wpi/first/math/MathUtil.java | 1 + .../main/java/edu/wpi/first/math/Matrix.java | 1 + .../src/main/java/edu/wpi/first/math/Num.java | 3 + .../main/java/edu/wpi/first/math/Pair.java | 31 ++++++ .../edu/wpi/first/math/StateSpaceUtil.java | 1 + .../first/math/controller/ArmFeedforward.java | 10 ++ .../DifferentialDriveWheelVoltages.java | 13 +++ .../math/controller/ElevatorFeedforward.java | 10 ++ .../controller/SimpleMotorFeedforward.java | 5 + .../KalmanFilterLatencyCompensator.java | 15 +++ .../math/estimator/KalmanTypeFilter.java | 59 ++++++++++ .../estimator/SteadyStateKalmanFilter.java | 1 + .../edu/wpi/first/math/filter/Debouncer.java | 4 + .../edu/wpi/first/math/geometry/Pose2d.java | 5 +- .../edu/wpi/first/math/geometry/Pose3d.java | 5 +- .../wpi/first/math/geometry/Quaternion.java | 6 +- .../wpi/first/math/geometry/Rotation2d.java | 5 +- .../wpi/first/math/geometry/Rotation3d.java | 5 +- .../wpi/first/math/geometry/Transform2d.java | 5 +- .../wpi/first/math/geometry/Transform3d.java | 5 +- .../first/math/geometry/Translation2d.java | 5 +- .../first/math/geometry/Translation3d.java | 5 +- .../edu/wpi/first/math/geometry/Twist2d.java | 6 +- .../edu/wpi/first/math/geometry/Twist3d.java | 6 +- .../InterpolatingDoubleTreeMap.java | 1 + .../math/interpolation/Interpolator.java | 5 + .../interpolation/InverseInterpolator.java | 5 + .../first/math/kinematics/ChassisSpeeds.java | 3 + .../DifferentialDriveKinematics.java | 4 + .../DifferentialDriveWheelPositions.java | 1 + .../DifferentialDriveWheelSpeeds.java | 3 + .../kinematics/MecanumDriveKinematics.java | 23 ++++ .../MecanumDriveWheelPositions.java | 6 +- .../kinematics/MecanumDriveWheelSpeeds.java | 6 +- .../kinematics/SwerveDriveKinematics.java | 2 + .../kinematics/SwerveDriveWheelPositions.java | 2 + .../math/kinematics/SwerveModulePosition.java | 5 +- .../math/kinematics/SwerveModuleState.java | 5 +- .../first/math/kinematics/WheelPositions.java | 5 + .../first/math/spline/CubicHermiteSpline.java | 1 + .../first/math/spline/PoseWithCurvature.java | 4 +- .../math/spline/QuinticHermiteSpline.java | 1 + .../edu/wpi/first/math/spline/Spline.java | 3 + .../wpi/first/math/spline/SplineHelper.java | 1 + .../math/spline/SplineParameterizer.java | 1 + .../wpi/first/math/system/Discretization.java | 1 + .../wpi/first/math/system/LinearSystem.java | 12 ++ .../math/system/NumericalIntegration.java | 1 + .../first/math/system/NumericalJacobian.java | 1 + .../wpi/first/math/system/plant/DCMotor.java | 18 +++ .../math/system/plant/LinearSystemId.java | 1 + .../math/trajectory/ExponentialProfile.java | 21 +++- .../wpi/first/math/trajectory/Trajectory.java | 13 ++- .../math/trajectory/TrajectoryGenerator.java | 22 +++- .../trajectory/TrajectoryParameterizer.java | 6 + .../first/math/trajectory/TrajectoryUtil.java | 7 ++ .../math/trajectory/TrapezoidProfile.java | 27 +++++ .../constraint/TrajectoryConstraint.java | 3 + .../proto/MecanumDriveKinematicsProto.cpp | 8 +- .../struct/MecanumDriveKinematicsStruct.cpp | 8 +- .../include/frc/controller/ArmFeedforward.h | 13 ++- .../DifferentialDriveWheelVoltages.h | 3 + .../frc/controller/ElevatorFeedforward.h | 7 ++ .../frc/controller/SimpleMotorFeedforward.h | 5 + .../KalmanFilterLatencyCompensator.h | 15 +++ .../native/include/frc/filter/Debouncer.h | 12 +- .../native/include/frc/geometry/Quaternion.h | 3 + .../kinematics/DifferentialDriveKinematics.h | 1 + .../frc/kinematics/MecanumDriveKinematics.h | 31 +++++- .../main/native/include/frc/spline/Spline.h | 3 + .../native/include/frc/system/plant/DCMotor.h | 15 ++- .../include/frc/system/plant/LinearSystemId.h | 3 + .../frc/trajectory/ExponentialProfile.h | 64 +++++++++-- .../include/frc/trajectory/Trajectory.h | 10 +- .../include/frc/trajectory/TrajectoryUtil.h | 3 + .../include/frc/trajectory/TrapezoidProfile.h | 32 +++++- .../proto/MecanumDriveKinematicsProtoTest.cpp | 11 +- .../MecanumDriveKinematicsStructTest.cpp | 11 +- .../wpi/first/util/CombinedRuntimeLoader.java | 12 ++ .../java/edu/wpi/first/util/EventVector.java | 3 + .../wpi/first/util/InterpolatingTreeMap.java | 3 + .../edu/wpi/first/util/RuntimeLoader.java | 5 + .../java/edu/wpi/first/util/WPIUtilJNI.java | 22 ++++ .../wpi/first/util/cleanup/CleanupPool.java | 3 + .../wpi/first/util/cleanup/SkipCleanup.java | 1 + .../wpi/first/util/datalog/DataLogJNI.java | 3 + .../first/util/protobuf/ProtobufBuffer.java | 8 ++ .../first/util/sendable/SendableBuilder.java | 4 + .../first/util/sendable/SendableRegistry.java | 3 + .../wpi/first/util/struct/StructBuffer.java | 9 +- .../util/struct/StructDescriptorDatabase.java | 3 + .../first/util/struct/StructFieldType.java | 13 +++ .../util/struct/parser/ParseException.java | 25 +++++ .../util/struct/parser/ParsedDeclaration.java | 8 ++ .../util/struct/parser/ParsedSchema.java | 4 + .../first/util/struct/parser/TokenKind.java | 23 ++++ .../include/wpi/sendable/SendableBuilder.h | 10 +- .../native/include/wpi/struct/DynamicStruct.h | 13 +++ .../native/include/wpi/struct/SchemaParser.h | 13 +++ 145 files changed, 1106 insertions(+), 94 deletions(-) diff --git a/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagDetector.java b/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagDetector.java index 61756854a9..a0774da171 100644 --- a/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagDetector.java +++ b/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagDetector.java @@ -57,8 +57,21 @@ public class AprilTagDetector implements AutoCloseable { */ public boolean debug; + /** Default constructor. */ public Config() {} + /** + * Constructs a detector configuration. + * + * @param numThreads How many threads should be used for computation. + * @param quadDecimate Quad decimation. + * @param quadSigma What Gaussian blur should be applied to the segmented image (used for quad + * detection). + * @param refineEdges When true, the edges of the each quad are adjusted to "snap to" strong + * gradients nearby. + * @param decodeSharpening How much sharpening should be done to decoded images. + * @param debug Debug mode. + */ Config( int numThreads, float quadDecimate, @@ -139,8 +152,21 @@ public class AprilTagDetector implements AutoCloseable { */ public boolean deglitch; + /** Default constructor. */ public QuadThresholdParameters() {} + /** + * Constructs quad threshold parameters. + * + * @param minClusterPixels Threshold used to reject quads containing too few pixels. + * @param maxNumMaxima How many corner candidates to consider when segmenting a group of pixels + * into a quad. + * @param criticalAngle Critical angle, in radians. + * @param maxLineFitMSE When fitting lines to the contours, the maximum mean squared error + * allowed. + * @param minWhiteBlackDiff Minimum brightness offset. + * @param deglitch Whether the thresholded image be should be deglitched. + */ QuadThresholdParameters( int minClusterPixels, int maxNumMaxima, diff --git a/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagFieldLayout.java b/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagFieldLayout.java index c4b1eb8de8..5d0e424887 100644 --- a/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagFieldLayout.java +++ b/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagFieldLayout.java @@ -44,8 +44,11 @@ import java.util.Optional; @JsonIgnoreProperties(ignoreUnknown = true) @JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE) public class AprilTagFieldLayout { + /** Common origin positions for the AprilTag coordinate system. */ public enum OriginPosition { + /** Blue alliance wall, right side. */ kBlueAllianceWallRightSide, + /** Red alliance wall, right side. */ kRedAllianceWallRightSide, } diff --git a/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagFields.java b/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagFields.java index dda8d343c5..8c5bfc2d93 100644 --- a/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagFields.java +++ b/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagFields.java @@ -7,15 +7,20 @@ package edu.wpi.first.apriltag; import java.io.IOException; import java.io.UncheckedIOException; +/** Loadable AprilTag field layouts. */ public enum AprilTagFields { + /** 2022 Rapid React. */ k2022RapidReact("2022-rapidreact.json"), + /** 2023 Charged Up. */ k2023ChargedUp("2023-chargedup.json"); + /** Base resource directory. */ public static final String kBaseResourceDir = "/edu/wpi/first/apriltag/"; /** Alias to the current game. */ public static final AprilTagFields kDefaultField = k2023ChargedUp; + /** Resource filename. */ public final String m_resourceFile; AprilTagFields(String resourceFile) { diff --git a/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagPoseEstimator.java b/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagPoseEstimator.java index 2b7f68a526..182f394a31 100644 --- a/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagPoseEstimator.java +++ b/apriltag/src/main/java/edu/wpi/first/apriltag/AprilTagPoseEstimator.java @@ -29,10 +29,19 @@ public class AprilTagPoseEstimator { this.cy = cy; } + /** Tag size, in meters. */ public double tagSize; + + /** Camera horizontal focal length, in pixels. */ public double fx; + + /** Camera vertical focal length, in pixels. */ public double fy; + + /** Camera horizontal focal center, in pixels. */ public double cx; + + /** Camera vertical focal center, in pixels. */ public double cy; @Override diff --git a/apriltag/src/main/native/include/frc/apriltag/AprilTagFieldLayout.h b/apriltag/src/main/native/include/frc/apriltag/AprilTagFieldLayout.h index 2b57d2ce4a..1f5397b25a 100644 --- a/apriltag/src/main/native/include/frc/apriltag/AprilTagFieldLayout.h +++ b/apriltag/src/main/native/include/frc/apriltag/AprilTagFieldLayout.h @@ -38,8 +38,13 @@ namespace frc { * towards the opposing alliance). */ class WPILIB_DLLEXPORT AprilTagFieldLayout { public: + /** + * Common origin positions for the AprilTag coordinate system. + */ enum class OriginPosition { + /// Blue alliance wall, right side. kBlueAllianceWallRightSide, + /// Red alliance wall, right side. kRedAllianceWallRightSide, }; diff --git a/apriltag/src/main/native/include/frc/apriltag/AprilTagFields.h b/apriltag/src/main/native/include/frc/apriltag/AprilTagFields.h index 4bab29919c..3f2b8a470f 100644 --- a/apriltag/src/main/native/include/frc/apriltag/AprilTagFields.h +++ b/apriltag/src/main/native/include/frc/apriltag/AprilTagFields.h @@ -12,8 +12,13 @@ namespace frc { +/** + * Loadable AprilTag field layouts. + */ enum class AprilTagField { + /// 2022 Rapid React. k2022RapidReact, + /// 2023 Charged Up. k2023ChargedUp, // This is a placeholder for denoting the last supported field. This should diff --git a/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServer.java b/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServer.java index 24f2ba28d0..12dfbf66a1 100644 --- a/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServer.java +++ b/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServer.java @@ -39,6 +39,7 @@ import java.util.concurrent.atomic.AtomicInteger; * NetworkTables. */ public final class CameraServer { + /** CameraServer base port. */ public static final int kBasePort = 1181; private static final String kPublishName = "/CameraPublisher"; diff --git a/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServerShared.java b/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServerShared.java index 4726de184f..dfa570f85c 100644 --- a/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServerShared.java +++ b/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServerShared.java @@ -4,6 +4,7 @@ package edu.wpi.first.cameraserver; +/** CameraServer shared functions. */ public interface CameraServerShared { /** * get the main thread id func. diff --git a/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServerSharedStore.java b/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServerSharedStore.java index 3d9e119406..b129d55291 100644 --- a/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServerSharedStore.java +++ b/cameraserver/src/main/java/edu/wpi/first/cameraserver/CameraServerSharedStore.java @@ -4,6 +4,7 @@ package edu.wpi.first.cameraserver; +/** Storage for CameraServerShared instance. */ public final class CameraServerSharedStore { private static CameraServerShared cameraServerShared; diff --git a/cameraserver/src/main/native/include/cameraserver/CameraServer.h b/cameraserver/src/main/native/include/cameraserver/CameraServer.h index 5553710a0d..09606128bd 100644 --- a/cameraserver/src/main/native/include/cameraserver/CameraServer.h +++ b/cameraserver/src/main/native/include/cameraserver/CameraServer.h @@ -22,10 +22,8 @@ namespace frc { */ class CameraServer { public: + /// CameraServer base port. static constexpr uint16_t kBasePort = 1181; - static constexpr int kSize640x480 = 0; - static constexpr int kSize320x240 = 1; - static constexpr int kSize160x120 = 2; /** * Start automatically capturing images to send to the dashboard. diff --git a/datalogtool/src/main/generate/WPILibVersion.cpp.in b/datalogtool/src/main/generate/WPILibVersion.cpp.in index b0a4490520..cfe2441158 100644 --- a/datalogtool/src/main/generate/WPILibVersion.cpp.in +++ b/datalogtool/src/main/generate/WPILibVersion.cpp.in @@ -1,4 +1,4 @@ -/* +/** * Autogenerated file! Do not manually edit this file. This version is regenerated * any time the publish task is run, or when this file is deleted. */ diff --git a/glass/src/app/generate/WPILibVersion.cpp.in b/glass/src/app/generate/WPILibVersion.cpp.in index b0a4490520..cfe2441158 100644 --- a/glass/src/app/generate/WPILibVersion.cpp.in +++ b/glass/src/app/generate/WPILibVersion.cpp.in @@ -1,4 +1,4 @@ -/* +/** * Autogenerated file! Do not manually edit this file. This version is regenerated * any time the publish task is run, or when this file is deleted. */ diff --git a/hal/src/main/java/edu/wpi/first/hal/simulation/BufferCallback.java b/hal/src/main/java/edu/wpi/first/hal/simulation/BufferCallback.java index e93a92127d..7c66563a32 100644 --- a/hal/src/main/java/edu/wpi/first/hal/simulation/BufferCallback.java +++ b/hal/src/main/java/edu/wpi/first/hal/simulation/BufferCallback.java @@ -4,6 +4,14 @@ package edu.wpi.first.hal.simulation; +/** Interface for simulation buffer callbacks. */ public interface BufferCallback { + /** + * Simulation buffer callback function. + * + * @param name Buffer name. + * @param buffer Buffer. + * @param count Buffer size. + */ void callback(String name, byte[] buffer, int count); } diff --git a/outlineviewer/src/main/generate/WPILibVersion.cpp.in b/outlineviewer/src/main/generate/WPILibVersion.cpp.in index b0a4490520..cfe2441158 100644 --- a/outlineviewer/src/main/generate/WPILibVersion.cpp.in +++ b/outlineviewer/src/main/generate/WPILibVersion.cpp.in @@ -1,4 +1,4 @@ -/* +/** * Autogenerated file! Do not manually edit this file. This version is regenerated * any time the publish task is run, or when this file is deleted. */ diff --git a/roborioteamnumbersetter/src/main/generate/WPILibVersion.cpp.in b/roborioteamnumbersetter/src/main/generate/WPILibVersion.cpp.in index b0a4490520..cfe2441158 100644 --- a/roborioteamnumbersetter/src/main/generate/WPILibVersion.cpp.in +++ b/roborioteamnumbersetter/src/main/generate/WPILibVersion.cpp.in @@ -1,4 +1,4 @@ -/* +/** * Autogenerated file! Do not manually edit this file. This version is regenerated * any time the publish task is run, or when this file is deleted. */ diff --git a/sysid/src/main/generate/WPILibVersion.cpp.in b/sysid/src/main/generate/WPILibVersion.cpp.in index b0a4490520..cfe2441158 100644 --- a/sysid/src/main/generate/WPILibVersion.cpp.in +++ b/sysid/src/main/generate/WPILibVersion.cpp.in @@ -1,4 +1,4 @@ -/* +/** * Autogenerated file! Do not manually edit this file. This version is regenerated * any time the publish task is run, or when this file is deleted. */ diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index f46feb1b2a..5ea1a362ec 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -25,8 +25,10 @@ import java.util.function.BooleanSupplier; *

This class is provided by the NewCommands VendorDep */ public abstract class Command implements Sendable { + /** Requirements set. */ protected Set m_requirements = new HashSet<>(); + /** Default constructor. */ @SuppressWarnings("this-escape") protected Command() { String name = getClass().getName(); diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandBase.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandBase.java index 12243cb58b..d75f08a29e 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandBase.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandBase.java @@ -16,4 +16,9 @@ import edu.wpi.first.util.sendable.Sendable; */ @Deprecated(since = "2024", forRemoval = true) @SuppressWarnings("PMD.AbstractClassWithoutAnyMethod") -public abstract class CommandBase extends Command {} +public abstract class CommandBase extends Command { + /** Default constructor. */ + public CommandBase() { + super(); + } +} diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PIDCommand.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PIDCommand.java index c761f3f18d..26627fa30f 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PIDCommand.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PIDCommand.java @@ -19,9 +19,16 @@ import java.util.function.DoubleSupplier; *

This class is provided by the NewCommands VendorDep */ public class PIDCommand extends Command { + /** PID controller. */ protected final PIDController m_controller; + + /** Measurement getter. */ protected DoubleSupplier m_measurement; + + /** Setpoint getter. */ protected DoubleSupplier m_setpoint; + + /** PID controller output consumer. */ protected DoubleConsumer m_useOutput; /** diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PIDSubsystem.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PIDSubsystem.java index e1c0dc893e..8146ca4d7b 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PIDSubsystem.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PIDSubsystem.java @@ -15,7 +15,10 @@ import edu.wpi.first.math.controller.PIDController; *

This class is provided by the NewCommands VendorDep */ public abstract class PIDSubsystem extends SubsystemBase { + /** PID controller. */ protected final PIDController m_controller; + + /** Whether PID controller output is enabled. */ protected boolean m_enabled; /** @@ -47,6 +50,11 @@ public abstract class PIDSubsystem extends SubsystemBase { } } + /** + * Returns the PIDController. + * + * @return The controller. + */ public PIDController getController() { return m_controller; } diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ProfiledPIDCommand.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ProfiledPIDCommand.java index f7175fc2eb..4e82811739 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ProfiledPIDCommand.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ProfiledPIDCommand.java @@ -21,9 +21,16 @@ import java.util.function.Supplier; *

This class is provided by the NewCommands VendorDep */ public class ProfiledPIDCommand extends Command { + /** Profiled PID controller. */ protected final ProfiledPIDController m_controller; + + /** Measurement getter. */ protected DoubleSupplier m_measurement; + + /** Goal getter. */ protected Supplier m_goal; + + /** Profiled PID controller output consumer. */ protected BiConsumer m_useOutput; /** diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ProfiledPIDSubsystem.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ProfiledPIDSubsystem.java index b8bb39843a..05318edc61 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ProfiledPIDSubsystem.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ProfiledPIDSubsystem.java @@ -17,7 +17,10 @@ import edu.wpi.first.math.trajectory.TrapezoidProfile; *

This class is provided by the NewCommands VendorDep */ public abstract class ProfiledPIDSubsystem extends SubsystemBase { + /** Profiled PID controller. */ protected final ProfiledPIDController m_controller; + + /** Whether the profiled PID controller output is enabled. */ protected boolean m_enabled; /** @@ -47,6 +50,11 @@ public abstract class ProfiledPIDSubsystem extends SubsystemBase { } } + /** + * Returns the ProfiledPIDController. + * + * @return The controller. + */ public ProfiledPIDController getController() { return m_controller; } diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/WaitCommand.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/WaitCommand.java index 828e8f5932..6d4c52bb61 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/WaitCommand.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/WaitCommand.java @@ -14,7 +14,9 @@ import edu.wpi.first.wpilibj.Timer; *

This class is provided by the NewCommands VendorDep */ public class WaitCommand extends Command { + /** The timer used for waiting. */ protected Timer m_timer = new Timer(); + private final double m_duration; /** diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/InternalButton.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/InternalButton.java index f4897f2aca..87c9b739b3 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/InternalButton.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/InternalButton.java @@ -42,10 +42,20 @@ public class InternalButton extends Trigger { this.m_inverted = inverted; } + /** + * Sets whether to invert button state. + * + * @param inverted Whether button state should be inverted. + */ public void setInverted(boolean inverted) { m_inverted.set(inverted); } + /** + * Sets whether button is pressed. + * + * @param pressed Whether button is pressed. + */ public void setPressed(boolean pressed) { m_pressed.set(pressed); } diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h index 27f5f18407..ad6aa79040 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h @@ -426,6 +426,7 @@ class Command : public wpi::Sendable, public wpi::SendableHelper { protected: Command(); + /// Requirements set. wpi::SmallSet m_requirements; /** diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/PIDCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/PIDCommand.h index bede6d0d51..ab16e7dd25 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/PIDCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/PIDCommand.h @@ -74,9 +74,16 @@ class PIDCommand : public CommandHelper { frc::PIDController& GetController(); protected: + /// PID controller. frc::PIDController m_controller; + + /// Measurement getter. std::function m_measurement; + + /// Setpoint getter. std::function m_setpoint; + + /// PID controller output consumer. std::function m_useOutput; }; } // namespace frc2 diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/PIDSubsystem.h b/wpilibNewCommands/src/main/native/include/frc2/command/PIDSubsystem.h index af61430e8a..af7d298087 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/PIDSubsystem.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/PIDSubsystem.h @@ -69,7 +69,10 @@ class PIDSubsystem : public SubsystemBase { frc::PIDController& GetController(); protected: + /// PID controller. frc::PIDController m_controller; + + /// Whether PID controller output is enabled. bool m_enabled{false}; /** diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h index 9ea5db5c7e..6fbb12b199 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h @@ -139,9 +139,16 @@ class ProfiledPIDCommand frc::ProfiledPIDController& GetController() { return m_controller; } protected: + /// Profiled PID controller. frc::ProfiledPIDController m_controller; + + /// Measurement getter. std::function m_measurement; + + /// Goal getter. std::function m_goal; + + /// Profiled PID controller output consumer. std::function m_useOutput; }; } // namespace frc2 diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDSubsystem.h b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDSubsystem.h index cfdfc6b631..1dac7fab27 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDSubsystem.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDSubsystem.h @@ -91,7 +91,10 @@ class ProfiledPIDSubsystem : public SubsystemBase { frc::ProfiledPIDController& GetController() { return m_controller; } protected: + /// Profiled PID controller. frc::ProfiledPIDController m_controller; + + /// Whether the profiled PID controller output is enabled. bool m_enabled{false}; /** diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/WaitCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/WaitCommand.h index e28615e468..6f6db40667 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/WaitCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/WaitCommand.h @@ -41,6 +41,7 @@ class WaitCommand : public CommandHelper { void InitSendable(wpi::SendableBuilder& builder) override; protected: + /// The timer used for waiting. frc::Timer m_timer; private: diff --git a/wpilibc/src/generate/WPILibVersion.cpp.in b/wpilibc/src/generate/WPILibVersion.cpp.in index b0a4490520..cfe2441158 100644 --- a/wpilibc/src/generate/WPILibVersion.cpp.in +++ b/wpilibc/src/generate/WPILibVersion.cpp.in @@ -1,4 +1,4 @@ -/* +/** * Autogenerated file! Do not manually edit this file. This version is regenerated * any time the publish task is run, or when this file is deleted. */ diff --git a/wpilibc/src/main/native/include/frc/util/Color.h b/wpilibc/src/main/native/include/frc/util/Color.h index 9e9228fe6d..f51d3b12b7 100644 --- a/wpilibc/src/main/native/include/frc/util/Color.h +++ b/wpilibc/src/main/native/include/frc/util/Color.h @@ -864,8 +864,13 @@ class Color { wpi::hexdigit(b % 16)}}; } + /// Red component (0-1). double red = 0.0; + + /// Green component (0-1). double green = 0.0; + + /// Blue component (0-1). double blue = 0.0; private: diff --git a/wpilibc/src/main/native/include/frc/util/Color8Bit.h b/wpilibc/src/main/native/include/frc/util/Color8Bit.h index ce7915a5fd..f4bc10406e 100644 --- a/wpilibc/src/main/native/include/frc/util/Color8Bit.h +++ b/wpilibc/src/main/native/include/frc/util/Color8Bit.h @@ -115,8 +115,13 @@ class Color8Bit { wpi::hexdigit(blue / 16), wpi::hexdigit(blue % 16)}}; } + /// Red component (0-255). int red = 0; + + /// Green component (0-255). int green = 0; + + /// Blue component (0-255). int blue = 0; }; diff --git a/wpilibj/src/generate/WPILibVersion.java.in b/wpilibj/src/generate/WPILibVersion.java.in index cc5e6b084d..f38d1b0b72 100644 --- a/wpilibj/src/generate/WPILibVersion.java.in +++ b/wpilibj/src/generate/WPILibVersion.java.in @@ -1,10 +1,13 @@ package edu.wpi.first.wpilibj.util; -/* +/** * Autogenerated file! Do not manually edit this file. This version is regenerated * any time the publish task is run, or when this file is deleted. */ - public final class WPILibVersion { + /** The version number. */ public static final String Version = "${wpilib_version}"; + + /** Utility class. */ + private WPILibVersion() {} } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SimHooks.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SimHooks.java index 1664081de9..053d646b80 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SimHooks.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SimHooks.java @@ -6,6 +6,7 @@ package edu.wpi.first.wpilibj.simulation; import edu.wpi.first.hal.simulation.SimulatorJNI; +/** Simulation hooks. */ public final class SimHooks { private SimHooks() {} diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/util/Color.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/util/Color.java index 47594ec1e6..50605676f7 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/util/Color.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/util/Color.java @@ -14,9 +14,15 @@ import java.util.Objects; */ @SuppressWarnings("MemberName") public class Color { + /** Red component (0-1). */ public final double red; + + /** Green component (0-1). */ public final double green; + + /** Blue component (0-1). */ public final double blue; + private String m_name; /** Constructs a default color (black). */ diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/util/Color8Bit.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/util/Color8Bit.java index 5d916e1941..132ea64a41 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/util/Color8Bit.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/util/Color8Bit.java @@ -10,8 +10,13 @@ import java.util.Objects; /** Represents colors with 8 bits of precision. */ @SuppressWarnings("MemberName") public class Color8Bit { + /** Red component (0-255). */ public final int red; + + /** Green component (0-255). */ public final int green; + + /** Blue component (0-255). */ public final int blue; /** Constructs a default color (black). */ diff --git a/wpimath/src/generate/main/java/Nat.java.jinja b/wpimath/src/generate/main/java/Nat.java.jinja index 7a3fc5ad64..66f06390c2 100644 --- a/wpimath/src/generate/main/java/Nat.java.jinja +++ b/wpimath/src/generate/main/java/Nat.java.jinja @@ -26,6 +26,11 @@ public interface Nat { */ int getNum(); {% for num in nums %} + /** + * Returns the Nat instance for {{ num }}. + * + * @return The Nat instance for {{ num }}. + */ static Nat N{{ num }}() { return N{{ num }}.instance; } diff --git a/wpimath/src/generated/main/java/edu/wpi/first/math/Nat.java b/wpimath/src/generated/main/java/edu/wpi/first/math/Nat.java index dc8d0add6f..f6b0b81250 100644 --- a/wpimath/src/generated/main/java/edu/wpi/first/math/Nat.java +++ b/wpimath/src/generated/main/java/edu/wpi/first/math/Nat.java @@ -45,86 +45,191 @@ public interface Nat { */ int getNum(); + /** + * Returns the Nat instance for 0. + * + * @return The Nat instance for 0. + */ static Nat N0() { return N0.instance; } + /** + * Returns the Nat instance for 1. + * + * @return The Nat instance for 1. + */ static Nat N1() { return N1.instance; } + /** + * Returns the Nat instance for 2. + * + * @return The Nat instance for 2. + */ static Nat N2() { return N2.instance; } + /** + * Returns the Nat instance for 3. + * + * @return The Nat instance for 3. + */ static Nat N3() { return N3.instance; } + /** + * Returns the Nat instance for 4. + * + * @return The Nat instance for 4. + */ static Nat N4() { return N4.instance; } + /** + * Returns the Nat instance for 5. + * + * @return The Nat instance for 5. + */ static Nat N5() { return N5.instance; } + /** + * Returns the Nat instance for 6. + * + * @return The Nat instance for 6. + */ static Nat N6() { return N6.instance; } + /** + * Returns the Nat instance for 7. + * + * @return The Nat instance for 7. + */ static Nat N7() { return N7.instance; } + /** + * Returns the Nat instance for 8. + * + * @return The Nat instance for 8. + */ static Nat N8() { return N8.instance; } + /** + * Returns the Nat instance for 9. + * + * @return The Nat instance for 9. + */ static Nat N9() { return N9.instance; } + /** + * Returns the Nat instance for 10. + * + * @return The Nat instance for 10. + */ static Nat N10() { return N10.instance; } + /** + * Returns the Nat instance for 11. + * + * @return The Nat instance for 11. + */ static Nat N11() { return N11.instance; } + /** + * Returns the Nat instance for 12. + * + * @return The Nat instance for 12. + */ static Nat N12() { return N12.instance; } + /** + * Returns the Nat instance for 13. + * + * @return The Nat instance for 13. + */ static Nat N13() { return N13.instance; } + /** + * Returns the Nat instance for 14. + * + * @return The Nat instance for 14. + */ static Nat N14() { return N14.instance; } + /** + * Returns the Nat instance for 15. + * + * @return The Nat instance for 15. + */ static Nat N15() { return N15.instance; } + /** + * Returns the Nat instance for 16. + * + * @return The Nat instance for 16. + */ static Nat N16() { return N16.instance; } + /** + * Returns the Nat instance for 17. + * + * @return The Nat instance for 17. + */ static Nat N17() { return N17.instance; } + /** + * Returns the Nat instance for 18. + * + * @return The Nat instance for 18. + */ static Nat N18() { return N18.instance; } + /** + * Returns the Nat instance for 19. + * + * @return The Nat instance for 19. + */ static Nat N19() { return N19.instance; } + /** + * Returns the Nat instance for 20. + * + * @return The Nat instance for 20. + */ static Nat N20() { return N20.instance; } diff --git a/wpimath/src/main/java/edu/wpi/first/math/ComputerVisionUtil.java b/wpimath/src/main/java/edu/wpi/first/math/ComputerVisionUtil.java index 7b1c377680..609cdf5e5a 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/ComputerVisionUtil.java +++ b/wpimath/src/main/java/edu/wpi/first/math/ComputerVisionUtil.java @@ -7,6 +7,7 @@ package edu.wpi.first.math; import edu.wpi.first.math.geometry.Pose3d; import edu.wpi.first.math.geometry.Transform3d; +/** Computer vision utility functions. */ public final class ComputerVisionUtil { private ComputerVisionUtil() { throw new AssertionError("utility class"); diff --git a/wpimath/src/main/java/edu/wpi/first/math/DARE.java b/wpimath/src/main/java/edu/wpi/first/math/DARE.java index ad07d056e7..44c488dc52 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/DARE.java +++ b/wpimath/src/main/java/edu/wpi/first/math/DARE.java @@ -6,6 +6,7 @@ package edu.wpi.first.math; import org.ejml.simple.SimpleMatrix; +/** DARE solver utility functions. */ public final class DARE { private DARE() { throw new UnsupportedOperationException("This is a utility class!"); diff --git a/wpimath/src/main/java/edu/wpi/first/math/InterpolatingMatrixTreeMap.java b/wpimath/src/main/java/edu/wpi/first/math/InterpolatingMatrixTreeMap.java index 2980e92a05..a0aedef2dc 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/InterpolatingMatrixTreeMap.java +++ b/wpimath/src/main/java/edu/wpi/first/math/InterpolatingMatrixTreeMap.java @@ -17,6 +17,9 @@ import java.util.TreeMap; public class InterpolatingMatrixTreeMap { private final TreeMap> m_map = new TreeMap<>(); + /** Default constructor. */ + public InterpolatingMatrixTreeMap() {} + /** * Inserts a key-value pair. * diff --git a/wpimath/src/main/java/edu/wpi/first/math/MatBuilder.java b/wpimath/src/main/java/edu/wpi/first/math/MatBuilder.java index 80c9d0dc9d..46e42f47f4 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/MatBuilder.java +++ b/wpimath/src/main/java/edu/wpi/first/math/MatBuilder.java @@ -40,7 +40,10 @@ public class MatBuilder { return new Matrix<>(new SimpleMatrix(rows.getNum(), cols.getNum(), true, data)); } + /** Number of rows. */ protected final Nat m_rows; + + /** Number of columns. */ protected final Nat m_cols; /** diff --git a/wpimath/src/main/java/edu/wpi/first/math/MathShared.java b/wpimath/src/main/java/edu/wpi/first/math/MathShared.java index 3c2b843388..ad4e2e81e6 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/MathShared.java +++ b/wpimath/src/main/java/edu/wpi/first/math/MathShared.java @@ -4,6 +4,7 @@ package edu.wpi.first.math; +/** WPIMath utility functions. */ public interface MathShared { /** * Report an error. diff --git a/wpimath/src/main/java/edu/wpi/first/math/MathSharedStore.java b/wpimath/src/main/java/edu/wpi/first/math/MathSharedStore.java index d6e3e9655f..d490a6e44e 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/MathSharedStore.java +++ b/wpimath/src/main/java/edu/wpi/first/math/MathSharedStore.java @@ -6,6 +6,7 @@ package edu.wpi.first.math; import edu.wpi.first.util.WPIUtilJNI; +/** Storage for MathShared object. */ public final class MathSharedStore { private static MathShared mathShared; diff --git a/wpimath/src/main/java/edu/wpi/first/math/MathUsageId.java b/wpimath/src/main/java/edu/wpi/first/math/MathUsageId.java index a3cc299875..c3449cfc61 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/MathUsageId.java +++ b/wpimath/src/main/java/edu/wpi/first/math/MathUsageId.java @@ -4,15 +4,35 @@ package edu.wpi.first.math; +/** WPIMath usage reporting IDs. */ public enum MathUsageId { + /** DifferentialDriveKinematics. */ kKinematics_DifferentialDrive, + + /** MecanumDriveKinematics. */ kKinematics_MecanumDrive, + + /** SwerveDriveKinematics. */ kKinematics_SwerveDrive, + + /** TrapezoidProfile. */ kTrajectory_TrapezoidProfile, + + /** LinearFilter. */ kFilter_Linear, + + /** DifferentialDriveOdometry. */ kOdometry_DifferentialDrive, + + /** SwerveDriveOdometry. */ kOdometry_SwerveDrive, + + /** MecanumDriveOdometry. */ kOdometry_MecanumDrive, + + /** PIDController. */ kController_PIDController2, + + /** ProfiledPIDController. */ kController_ProfiledPIDController, } diff --git a/wpimath/src/main/java/edu/wpi/first/math/MathUtil.java b/wpimath/src/main/java/edu/wpi/first/math/MathUtil.java index 3785780a8d..044cddfab6 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/MathUtil.java +++ b/wpimath/src/main/java/edu/wpi/first/math/MathUtil.java @@ -4,6 +4,7 @@ package edu.wpi.first.math; +/** Math utility functions. */ public final class MathUtil { private MathUtil() { throw new AssertionError("utility class"); diff --git a/wpimath/src/main/java/edu/wpi/first/math/Matrix.java b/wpimath/src/main/java/edu/wpi/first/math/Matrix.java index 80700d4027..c3f796ed0f 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/Matrix.java +++ b/wpimath/src/main/java/edu/wpi/first/math/Matrix.java @@ -24,6 +24,7 @@ import org.ejml.simple.SimpleMatrix; * @param The number of columns in this matrix. */ public class Matrix { + /** Storage for underlying EJML matrix. */ protected final SimpleMatrix m_storage; /** diff --git a/wpimath/src/main/java/edu/wpi/first/math/Num.java b/wpimath/src/main/java/edu/wpi/first/math/Num.java index ef0fd2d815..aa31dd7991 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/Num.java +++ b/wpimath/src/main/java/edu/wpi/first/math/Num.java @@ -6,6 +6,9 @@ package edu.wpi.first.math; /** A number expressed as a java class. */ public abstract class Num { + /** Default constructor. */ + public Num() {} + /** * The number this is backing. * diff --git a/wpimath/src/main/java/edu/wpi/first/math/Pair.java b/wpimath/src/main/java/edu/wpi/first/math/Pair.java index 8ddf1ae37b..f854894ff6 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/Pair.java +++ b/wpimath/src/main/java/edu/wpi/first/math/Pair.java @@ -4,23 +4,54 @@ package edu.wpi.first.math; +/** + * Represents a pair of two objects. + * + * @param The first object's type. + * @param The second object's type. + */ public class Pair { private final A m_first; private final B m_second; + /** + * Constructs a pair. + * + * @param first The first object. + * @param second The second object. + */ public Pair(A first, B second) { m_first = first; m_second = second; } + /** + * Returns the first object. + * + * @return The first object. + */ public A getFirst() { return m_first; } + /** + * Returns the second object. + * + * @return The second object. + */ public B getSecond() { return m_second; } + /** + * Returns a pair comprised of the two given objects. + * + * @param The first object's type. + * @param The second object's type. + * @param a The first object. + * @param b The second object. + * @return A pair comprised of the two given objects. + */ public static Pair of(A a, B b) { return new Pair<>(a, b); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/StateSpaceUtil.java b/wpimath/src/main/java/edu/wpi/first/math/StateSpaceUtil.java index 77c5fb93df..525d5ef1be 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/StateSpaceUtil.java +++ b/wpimath/src/main/java/edu/wpi/first/math/StateSpaceUtil.java @@ -11,6 +11,7 @@ import edu.wpi.first.math.numbers.N4; import java.util.Random; import org.ejml.simple.SimpleMatrix; +/** State-space utilities. */ public final class StateSpaceUtil { private static Random rand = new Random(); diff --git a/wpimath/src/main/java/edu/wpi/first/math/controller/ArmFeedforward.java b/wpimath/src/main/java/edu/wpi/first/math/controller/ArmFeedforward.java index a69653305b..d7a695fced 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/controller/ArmFeedforward.java +++ b/wpimath/src/main/java/edu/wpi/first/math/controller/ArmFeedforward.java @@ -14,12 +14,22 @@ import edu.wpi.first.util.struct.StructSerializable; * against the force of gravity on a beam suspended at an angle). */ public class ArmFeedforward implements ProtobufSerializable, StructSerializable { + /** The static gain, in volts. */ public final double ks; + + /** The gravity gain, in volts. */ public final double kg; + + /** The velocity gain, in volt seconds per radian. */ public final double kv; + + /** The acceleration gain, in volt seconds² per radian. */ public final double ka; + /** Arm feedforward protobuf for serialization. */ public static final ArmFeedforwardProto proto = new ArmFeedforwardProto(); + + /** Arm feedforward struct for serialization. */ public static final ArmFeedforwardStruct struct = new ArmFeedforwardStruct(); /** diff --git a/wpimath/src/main/java/edu/wpi/first/math/controller/DifferentialDriveWheelVoltages.java b/wpimath/src/main/java/edu/wpi/first/math/controller/DifferentialDriveWheelVoltages.java index e45195655e..1569be0685 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/controller/DifferentialDriveWheelVoltages.java +++ b/wpimath/src/main/java/edu/wpi/first/math/controller/DifferentialDriveWheelVoltages.java @@ -11,16 +11,29 @@ import edu.wpi.first.util.struct.StructSerializable; /** Motor voltages for a differential drive. */ public class DifferentialDriveWheelVoltages implements ProtobufSerializable, StructSerializable { + /** Left wheel voltage. */ public double left; + + /** Right wheel voltage. */ public double right; + /** DifferentialDriveWheelVoltages protobuf for serialization. */ public static final DifferentialDriveWheelVoltagesProto proto = new DifferentialDriveWheelVoltagesProto(); + + /** DifferentialDriveWheelVoltages struct for serialization. */ public static final DifferentialDriveWheelVoltagesStruct struct = new DifferentialDriveWheelVoltagesStruct(); + /** Default constructor. */ public DifferentialDriveWheelVoltages() {} + /** + * Constructs a DifferentialDriveWheelVoltages. + * + * @param left Left wheel voltage. + * @param right Right wheel voltage. + */ public DifferentialDriveWheelVoltages(double left, double right) { this.left = left; this.right = right; diff --git a/wpimath/src/main/java/edu/wpi/first/math/controller/ElevatorFeedforward.java b/wpimath/src/main/java/edu/wpi/first/math/controller/ElevatorFeedforward.java index a83a457f92..854462a652 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/controller/ElevatorFeedforward.java +++ b/wpimath/src/main/java/edu/wpi/first/math/controller/ElevatorFeedforward.java @@ -17,12 +17,22 @@ import edu.wpi.first.util.struct.StructSerializable; * against the force of gravity). */ public class ElevatorFeedforward implements ProtobufSerializable, StructSerializable { + /** The static gain. */ public final double ks; + + /** The gravity gain. */ public final double kg; + + /** The velocity gain. */ public final double kv; + + /** The acceleration gain. */ public final double ka; + /** ElevatorFeedforward protobuf for serialization. */ public static final ElevatorFeedforwardProto proto = new ElevatorFeedforwardProto(); + + /** ElevatorFeedforward struct for serialization. */ public static final ElevatorFeedforwardStruct struct = new ElevatorFeedforwardStruct(); /** diff --git a/wpimath/src/main/java/edu/wpi/first/math/controller/SimpleMotorFeedforward.java b/wpimath/src/main/java/edu/wpi/first/math/controller/SimpleMotorFeedforward.java index f19e836617..2b25bccbf8 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/controller/SimpleMotorFeedforward.java +++ b/wpimath/src/main/java/edu/wpi/first/math/controller/SimpleMotorFeedforward.java @@ -10,8 +10,13 @@ import edu.wpi.first.math.system.plant.LinearSystemId; /** A helper class that computes feedforward outputs for a simple permanent-magnet DC motor. */ public class SimpleMotorFeedforward { + /** The static gain. */ public final double ks; + + /** The velocity gain. */ public final double kv; + + /** The acceleration gain. */ public final double ka; /** diff --git a/wpimath/src/main/java/edu/wpi/first/math/estimator/KalmanFilterLatencyCompensator.java b/wpimath/src/main/java/edu/wpi/first/math/estimator/KalmanFilterLatencyCompensator.java index 15e7bd4b6d..ad4db52337 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/estimator/KalmanFilterLatencyCompensator.java +++ b/wpimath/src/main/java/edu/wpi/first/math/estimator/KalmanFilterLatencyCompensator.java @@ -13,11 +13,19 @@ import java.util.List; import java.util.Map; import java.util.function.BiConsumer; +/** + * This class incorporates time-delayed measurements into a Kalman filter's state estimate. + * + * @param The number of states. + * @param The number of inputs. + * @param The number of outputs. + */ public class KalmanFilterLatencyCompensator { private static final int kMaxPastObserverStates = 300; private final List> m_pastObserverSnapshots; + /** Default constructor. */ KalmanFilterLatencyCompensator() { m_pastObserverSnapshots = new ArrayList<>(); } @@ -164,9 +172,16 @@ public class KalmanFilterLatencyCompensator xHat; + + /** The error covariance. */ public final Matrix errorCovariances; + + /** The inputs. */ public final Matrix inputs; + + /** The local measurements. */ public final Matrix localMeasurements; private ObserverSnapshot( diff --git a/wpimath/src/main/java/edu/wpi/first/math/estimator/KalmanTypeFilter.java b/wpimath/src/main/java/edu/wpi/first/math/estimator/KalmanTypeFilter.java index 7b14839f2a..ff9856c32d 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/estimator/KalmanTypeFilter.java +++ b/wpimath/src/main/java/edu/wpi/first/math/estimator/KalmanTypeFilter.java @@ -8,24 +8,83 @@ import edu.wpi.first.math.Matrix; import edu.wpi.first.math.Num; import edu.wpi.first.math.numbers.N1; +/** + * Interface for Kalman filters for use with KalmanFilterLatencyCompensator. + * + * @param The number of states. + * @param The number of inputs. + * @param The number of outputs. + */ public interface KalmanTypeFilter { + /** + * Returns the error covariance matrix. + * + * @return The error covariance matrix. + */ Matrix getP(); + /** + * Returns an element of the error covariance matrix. + * + * @param i The row. + * @param j The column. + * @return An element of the error covariance matrix. + */ double getP(int i, int j); + /** + * Sets the error covariance matrix. + * + * @param newP The error covariance matrix. + */ void setP(Matrix newP); + /** + * Returns the state estimate. + * + * @return The state estimate. + */ Matrix getXhat(); + /** + * Returns an element of the state estimate. + * + * @param i The row. + * @return An element of the state estimate. + */ double getXhat(int i); + /** + * Sets the state estimate. + * + * @param xHat The state estimate. + */ void setXhat(Matrix xHat); + /** + * Sets an element of the state estimate. + * + * @param i The row. + * @param value The value. + */ void setXhat(int i, double value); + /** Resets the observer. */ void reset(); + /** + * Project the model into the future with a new control input u. + * + * @param u New control input from controller. + * @param dtSeconds Timestep for prediction. + */ void predict(Matrix u, double dtSeconds); + /** + * Correct the state estimate x-hat using the measurements in y. + * + * @param u Same control input used in the predict step. + * @param y Measurement vector. + */ void correct(Matrix u, Matrix y); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/estimator/SteadyStateKalmanFilter.java b/wpimath/src/main/java/edu/wpi/first/math/estimator/SteadyStateKalmanFilter.java index 96e51bca75..0f2e4a5e5e 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/estimator/SteadyStateKalmanFilter.java +++ b/wpimath/src/main/java/edu/wpi/first/math/estimator/SteadyStateKalmanFilter.java @@ -119,6 +119,7 @@ public class SteadyStateKalmanFilter(m_states, Nat.N1()); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/filter/Debouncer.java b/wpimath/src/main/java/edu/wpi/first/math/filter/Debouncer.java index 3472198d4b..c113d9655a 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/filter/Debouncer.java +++ b/wpimath/src/main/java/edu/wpi/first/math/filter/Debouncer.java @@ -11,9 +11,13 @@ import edu.wpi.first.math.MathSharedStore; * baseline for a specified period of time before the filtered value changes. */ public class Debouncer { + /** Type of debouncing to perform. */ public enum DebounceType { + /** Rising edge. */ kRising, + /** Falling edge. */ kFalling, + /** Both rising and falling edges. */ kBoth } diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose2d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose2d.java index 42740c5ffb..97e8307999 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose2d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose2d.java @@ -326,6 +326,9 @@ public class Pose2d implements Interpolatable, ProtobufSerializable, Str } } - public static final Pose2dStruct struct = new Pose2dStruct(); + /** Pose2d protobuf for serialization. */ public static final Pose2dProto proto = new Pose2dProto(); + + /** Pose2d struct for serialization. */ + public static final Pose2dStruct struct = new Pose2dStruct(); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose3d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose3d.java index 4ed67c519f..282420fefb 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose3d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose3d.java @@ -323,6 +323,9 @@ public class Pose3d implements Interpolatable, ProtobufSerializable, Str } } - public static final Pose3dStruct struct = new Pose3dStruct(); + /** Pose3d protobuf for serialization. */ public static final Pose3dProto proto = new Pose3dProto(); + + /** Pose3d struct for serialization. */ + public static final Pose3dStruct struct = new Pose3dStruct(); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Quaternion.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Quaternion.java index 9ef0a740b0..ea0be3cfdd 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Quaternion.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Quaternion.java @@ -17,6 +17,7 @@ import edu.wpi.first.util.protobuf.ProtobufSerializable; import edu.wpi.first.util.struct.StructSerializable; import java.util.Objects; +/** Represents a quaternion. */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE) public class Quaternion implements ProtobufSerializable, StructSerializable { @@ -405,6 +406,9 @@ public class Quaternion implements ProtobufSerializable, StructSerializable { return VecBuilder.fill(coeff * getX(), coeff * getY(), coeff * getZ()); } - public static final QuaternionStruct struct = new QuaternionStruct(); + /** Quaternion protobuf for serialization. */ public static final QuaternionProto proto = new QuaternionProto(); + + /** Quaternion struct for serialization. */ + public static final QuaternionStruct struct = new QuaternionStruct(); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Rotation2d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Rotation2d.java index afca0e84c5..1106a103a5 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Rotation2d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Rotation2d.java @@ -275,6 +275,9 @@ public class Rotation2d return plus(endValue.minus(this).times(MathUtil.clamp(t, 0, 1))); } - public static final Rotation2dStruct struct = new Rotation2dStruct(); + /** Rotation2d protobuf for serialization. */ public static final Rotation2dProto proto = new Rotation2dProto(); + + /** Rotation2d struct for serialization. */ + public static final Rotation2dStruct struct = new Rotation2dStruct(); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Rotation3d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Rotation3d.java index ac784ebfa2..33fd34a3b2 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Rotation3d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Rotation3d.java @@ -432,6 +432,9 @@ public class Rotation3d return plus(endValue.minus(this).times(MathUtil.clamp(t, 0, 1))); } - public static final Rotation3dStruct struct = new Rotation3dStruct(); + /** Rotation3d protobuf for serialization. */ public static final Rotation3dProto proto = new Rotation3dProto(); + + /** Rotation3d struct for serialization. */ + public static final Rotation3dStruct struct = new Rotation3dStruct(); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Transform2d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Transform2d.java index b307812914..68747af423 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Transform2d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Transform2d.java @@ -184,6 +184,9 @@ public class Transform2d implements ProtobufSerializable, StructSerializable { return Objects.hash(m_translation, m_rotation); } - public static final Transform2dStruct struct = new Transform2dStruct(); + /** Transform2d protobuf for serialization. */ public static final Transform2dProto proto = new Transform2dProto(); + + /** Transform2d struct for serialization. */ + public static final Transform2dStruct struct = new Transform2dStruct(); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Transform3d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Transform3d.java index d211f7ef21..cdd021f835 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Transform3d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Transform3d.java @@ -178,6 +178,9 @@ public class Transform3d implements ProtobufSerializable, StructSerializable { return Objects.hash(m_translation, m_rotation); } - public static final Transform3dStruct struct = new Transform3dStruct(); + /** Transform3d protobuf for serialization. */ public static final Transform3dProto proto = new Transform3dProto(); + + /** Transform3d struct for serialization. */ + public static final Transform3dStruct struct = new Transform3dStruct(); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation2d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation2d.java index 228582311e..f089f6690f 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation2d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation2d.java @@ -250,6 +250,9 @@ public class Translation2d MathUtil.interpolate(this.getY(), endValue.getY(), t)); } - public static final Translation2dStruct struct = new Translation2dStruct(); + /** Translation2d protobuf for serialization. */ public static final Translation2dProto proto = new Translation2dProto(); + + /** Translation2d struct for serialization. */ + public static final Translation2dStruct struct = new Translation2dStruct(); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation3d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation3d.java index af76f155c1..6d4fa9247e 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation3d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation3d.java @@ -253,6 +253,9 @@ public class Translation3d MathUtil.interpolate(this.getZ(), endValue.getZ(), t)); } - public static final Translation3dStruct struct = new Translation3dStruct(); + /** Translation3d protobuf for serialization. */ public static final Translation3dProto proto = new Translation3dProto(); + + /** Translation3d struct for serialization. */ + public static final Translation3dStruct struct = new Translation3dStruct(); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Twist2d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Twist2d.java index 9d353a4b1d..53ab6ba9c2 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Twist2d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Twist2d.java @@ -26,6 +26,7 @@ public class Twist2d implements ProtobufSerializable, StructSerializable { /** Angular "dtheta" component (radians). */ public double dtheta; + /** Default constructor. */ public Twist2d() {} /** @@ -67,6 +68,9 @@ public class Twist2d implements ProtobufSerializable, StructSerializable { return Objects.hash(dx, dy, dtheta); } - public static final Twist2dStruct struct = new Twist2dStruct(); + /** Twist2d protobuf for serialization. */ public static final Twist2dProto proto = new Twist2dProto(); + + /** Twist2d struct for serialization. */ + public static final Twist2dStruct struct = new Twist2dStruct(); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Twist3d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Twist3d.java index 0045f29f7a..80786029ef 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Twist3d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Twist3d.java @@ -35,6 +35,7 @@ public class Twist3d implements ProtobufSerializable, StructSerializable { /** Rotation vector z component (radians). */ public double rz; + /** Default constructor. */ public Twist3d() {} /** @@ -87,6 +88,9 @@ public class Twist3d implements ProtobufSerializable, StructSerializable { return Objects.hash(dx, dy, dz, rx, ry, rz); } - public static final Twist3dStruct struct = new Twist3dStruct(); + /** Twist3d protobuf for serialization. */ public static final Twist3dProto proto = new Twist3dProto(); + + /** Twist3d struct for serialization. */ + public static final Twist3dStruct struct = new Twist3dStruct(); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/interpolation/InterpolatingDoubleTreeMap.java b/wpimath/src/main/java/edu/wpi/first/math/interpolation/InterpolatingDoubleTreeMap.java index bcd57a392e..15c55d091c 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/interpolation/InterpolatingDoubleTreeMap.java +++ b/wpimath/src/main/java/edu/wpi/first/math/interpolation/InterpolatingDoubleTreeMap.java @@ -9,6 +9,7 @@ package edu.wpi.first.math.interpolation; * from points that are defined. This uses linear interpolation. */ public class InterpolatingDoubleTreeMap extends InterpolatingTreeMap { + /** Default constructor. */ public InterpolatingDoubleTreeMap() { super(InverseInterpolator.forDouble(), Interpolator.forDouble()); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/interpolation/Interpolator.java b/wpimath/src/main/java/edu/wpi/first/math/interpolation/Interpolator.java index be6d8a2d26..5fe1a8f28a 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/interpolation/Interpolator.java +++ b/wpimath/src/main/java/edu/wpi/first/math/interpolation/Interpolator.java @@ -24,6 +24,11 @@ public interface Interpolator { */ T interpolate(T startValue, T endValue, double t); + /** + * Returns interpolator for Double. + * + * @return Interpolator for Double. + */ static Interpolator forDouble() { return MathUtil::interpolate; } diff --git a/wpimath/src/main/java/edu/wpi/first/math/interpolation/InverseInterpolator.java b/wpimath/src/main/java/edu/wpi/first/math/interpolation/InverseInterpolator.java index 8278af3f45..d6d0bc8c5b 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/interpolation/InverseInterpolator.java +++ b/wpimath/src/main/java/edu/wpi/first/math/interpolation/InverseInterpolator.java @@ -24,6 +24,11 @@ public interface InverseInterpolator { */ double inverseInterpolate(T startValue, T endValue, T q); + /** + * Returns inverse interpolator for Double. + * + * @return Inverse interpolator for Double. + */ static InverseInterpolator forDouble() { return MathUtil::inverseInterpolate; } diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/ChassisSpeeds.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/ChassisSpeeds.java index a6662b9599..33a5edca43 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/ChassisSpeeds.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/ChassisSpeeds.java @@ -40,7 +40,10 @@ public class ChassisSpeeds implements ProtobufSerializable, StructSerializable { /** Represents the angular velocity of the robot frame. (CCW is +) */ public double omegaRadiansPerSecond; + /** ChassisSpeeds protobuf for serialization. */ public static final ChassisSpeedsProto proto = new ChassisSpeedsProto(); + + /** ChassisSpeeds struct for serialization. */ public static final ChassisSpeedsStruct struct = new ChassisSpeedsStruct(); /** Constructs a ChassisSpeeds with zeros for dx, dy, and theta. */ diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveKinematics.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveKinematics.java index 7711721e7f..1d18b005da 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveKinematics.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveKinematics.java @@ -28,10 +28,14 @@ public class DifferentialDriveKinematics implements Kinematics, ProtobufSerializable, StructSerializable { + /** Differential drive trackwidth. */ public final double trackWidthMeters; + /** DifferentialDriveKinematics protobuf for serialization. */ public static final DifferentialDriveKinematicsProto proto = new DifferentialDriveKinematicsProto(); + + /** DifferentialDriveKinematics struct for serialization. */ public static final DifferentialDriveKinematicsStruct struct = new DifferentialDriveKinematicsStruct(); diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveWheelPositions.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveWheelPositions.java index c0a211e049..fbdf54d881 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveWheelPositions.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveWheelPositions.java @@ -11,6 +11,7 @@ import edu.wpi.first.units.Distance; import edu.wpi.first.units.Measure; import java.util.Objects; +/** Represents the wheel positions for a differential drive drivetrain. */ public class DifferentialDriveWheelPositions implements WheelPositions { /** Distance measured by the left side. */ diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveWheelSpeeds.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveWheelSpeeds.java index d5e317bfb8..de18817953 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveWheelSpeeds.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveWheelSpeeds.java @@ -22,8 +22,11 @@ public class DifferentialDriveWheelSpeeds implements ProtobufSerializable, Struc /** Speed of the right side of the robot. */ public double rightMetersPerSecond; + /** DifferentialDriveWheelSpeeds protobuf for serialization. */ public static final DifferentialDriveWheelSpeedsProto proto = new DifferentialDriveWheelSpeedsProto(); + + /** DifferentialDriveWheelSpeeds struct for serialization. */ public static final DifferentialDriveWheelSpeedsStruct struct = new DifferentialDriveWheelSpeedsStruct(); diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveKinematics.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveKinematics.java index f73f8d48d4..44dbb6b25f 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveKinematics.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveKinematics.java @@ -48,7 +48,10 @@ public class MecanumDriveKinematics private Translation2d m_prevCoR = new Translation2d(); + /** MecanumDriveKinematics protobuf for serialization. */ public static final MecanumDriveKinematicsProto proto = new MecanumDriveKinematicsProto(); + + /** MecanumDriveKinematics struct for serialization. */ public static final MecanumDriveKinematicsStruct struct = new MecanumDriveKinematicsStruct(); /** @@ -217,18 +220,38 @@ public class MecanumDriveKinematics m_inverseKinematics.setRow(3, 0, 1, -1, -(rr.getX() + rr.getY())); } + /** + * Returns the front-left wheel translation. + * + * @return The front-left wheel translation. + */ public Translation2d getFrontLeft() { return m_frontLeftWheelMeters; } + /** + * Returns the front-right wheel translation. + * + * @return The front-right wheel translation. + */ public Translation2d getFrontRight() { return m_frontRightWheelMeters; } + /** + * Returns the rear-left wheel translation. + * + * @return The rear-left wheel translation. + */ public Translation2d getRearLeft() { return m_rearLeftWheelMeters; } + /** + * Returns the rear-right wheel translation. + * + * @return The rear-right wheel translation. + */ public Translation2d getRearRight() { return m_rearRightWheelMeters; } diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveWheelPositions.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveWheelPositions.java index 5b5a02ee4e..179e1bf14b 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveWheelPositions.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveWheelPositions.java @@ -15,6 +15,7 @@ import edu.wpi.first.util.protobuf.ProtobufSerializable; import edu.wpi.first.util.struct.StructSerializable; import java.util.Objects; +/** Represents the wheel positions for a mecanum drive drivetrain. */ public class MecanumDriveWheelPositions implements WheelPositions, ProtobufSerializable, @@ -31,9 +32,12 @@ public class MecanumDriveWheelPositions /** Distance measured by the rear right wheel. */ public double rearRightMeters; + /** MecanumDriveWheelPositions protobuf for serialization. */ + public static final MecanumDriveWheelPositionsProto proto = new MecanumDriveWheelPositionsProto(); + + /** MecanumDriveWheelPositions struct for serialization. */ public static final MecanumDriveWheelPositionsStruct struct = new MecanumDriveWheelPositionsStruct(); - public static final MecanumDriveWheelPositionsProto proto = new MecanumDriveWheelPositionsProto(); /** Constructs a MecanumDriveWheelPositions with zeros for all member fields. */ public MecanumDriveWheelPositions() {} diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveWheelSpeeds.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveWheelSpeeds.java index b1e6bf4423..59a34558a1 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveWheelSpeeds.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveWheelSpeeds.java @@ -14,6 +14,7 @@ import edu.wpi.first.units.Velocity; import edu.wpi.first.util.protobuf.ProtobufSerializable; import edu.wpi.first.util.struct.StructSerializable; +/** Represents the wheel speeds for a mecanum drive drivetrain. */ public class MecanumDriveWheelSpeeds implements ProtobufSerializable, StructSerializable { /** Speed of the front left wheel. */ public double frontLeftMetersPerSecond; @@ -27,9 +28,12 @@ public class MecanumDriveWheelSpeeds implements ProtobufSerializable, StructSeri /** Speed of the rear right wheel. */ public double rearRightMetersPerSecond; - public static final MecanumDriveWheelSpeedsStruct struct = new MecanumDriveWheelSpeedsStruct(); + /** MecanumDriveWheelSpeeds protobuf for serialization. */ public static final MecanumDriveWheelSpeedsProto proto = new MecanumDriveWheelSpeedsProto(); + /** MecanumDriveWheelSpeeds struct for serialization. */ + public static final MecanumDriveWheelSpeedsStruct struct = new MecanumDriveWheelSpeedsStruct(); + /** Constructs a MecanumDriveWheelSpeeds with zeros for all member fields. */ public MecanumDriveWheelSpeeds() {} diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java index 2498b33742..6648343f89 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java @@ -41,7 +41,9 @@ import org.ejml.simple.SimpleMatrix; */ public class SwerveDriveKinematics implements Kinematics { + /** Wrapper class for swerve module states. */ public static class SwerveDriveWheelStates { + /** Swerve module states. */ public SwerveModuleState[] states; /** diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveWheelPositions.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveWheelPositions.java index e88f044803..5d0f0af113 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveWheelPositions.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveWheelPositions.java @@ -7,7 +7,9 @@ package edu.wpi.first.math.kinematics; import java.util.Arrays; import java.util.Objects; +/** Represents the wheel positions for a swerve drive drivetrain. */ public class SwerveDriveWheelPositions implements WheelPositions { + /** The distances driven by the wheels. */ public SwerveModulePosition[] positions; /** diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveModulePosition.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveModulePosition.java index cccf1466fa..3041d42cd0 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveModulePosition.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveModulePosition.java @@ -29,9 +29,12 @@ public class SwerveModulePosition /** Angle of the module. */ public Rotation2d angle = Rotation2d.fromDegrees(0); - public static final SwerveModulePositionStruct struct = new SwerveModulePositionStruct(); + /** SwerveModulePosition protobuf for serialization. */ public static final SwerveModulePositionProto proto = new SwerveModulePositionProto(); + /** SwerveModulePosition struct for serialization. */ + public static final SwerveModulePositionStruct struct = new SwerveModulePositionStruct(); + /** Constructs a SwerveModulePosition with zeros for distance and angle. */ public SwerveModulePosition() {} diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveModuleState.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveModuleState.java index 9c6b180ca4..9f1604a0d6 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveModuleState.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveModuleState.java @@ -25,9 +25,12 @@ public class SwerveModuleState /** Angle of the module. */ public Rotation2d angle = Rotation2d.fromDegrees(0); - public static final SwerveModuleStateStruct struct = new SwerveModuleStateStruct(); + /** SwerveModuleState protobuf for serialization. */ public static final SwerveModuleStateProto proto = new SwerveModuleStateProto(); + /** SwerveModuleState struct for serialization. */ + public static final SwerveModuleStateStruct struct = new SwerveModuleStateStruct(); + /** Constructs a SwerveModuleState with zeros for speed and angle. */ public SwerveModuleState() {} diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/WheelPositions.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/WheelPositions.java index 029a0ac40d..c0167e3e86 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/WheelPositions.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/WheelPositions.java @@ -6,6 +6,11 @@ package edu.wpi.first.math.kinematics; import edu.wpi.first.math.interpolation.Interpolatable; +/** + * Interface for wheel positions. + * + * @param Wheel positions type. + */ public interface WheelPositions> extends Interpolatable { /** * Returns a copy of this instance. diff --git a/wpimath/src/main/java/edu/wpi/first/math/spline/CubicHermiteSpline.java b/wpimath/src/main/java/edu/wpi/first/math/spline/CubicHermiteSpline.java index 8f93661f99..72108a5deb 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/spline/CubicHermiteSpline.java +++ b/wpimath/src/main/java/edu/wpi/first/math/spline/CubicHermiteSpline.java @@ -6,6 +6,7 @@ package edu.wpi.first.math.spline; import org.ejml.simple.SimpleMatrix; +/** Represents a hermite spline of degree 3. */ public class CubicHermiteSpline extends Spline { private static SimpleMatrix hermiteBasis; private final SimpleMatrix m_coefficients; diff --git a/wpimath/src/main/java/edu/wpi/first/math/spline/PoseWithCurvature.java b/wpimath/src/main/java/edu/wpi/first/math/spline/PoseWithCurvature.java index 30b3caefef..fbeeb35dc8 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/spline/PoseWithCurvature.java +++ b/wpimath/src/main/java/edu/wpi/first/math/spline/PoseWithCurvature.java @@ -8,10 +8,10 @@ import edu.wpi.first.math.geometry.Pose2d; /** Represents a pair of a pose and a curvature. */ public class PoseWithCurvature { - // Represents the pose. + /** Represents the pose. */ public Pose2d poseMeters; - // Represents the curvature. + /** Represents the curvature. */ public double curvatureRadPerMeter; /** diff --git a/wpimath/src/main/java/edu/wpi/first/math/spline/QuinticHermiteSpline.java b/wpimath/src/main/java/edu/wpi/first/math/spline/QuinticHermiteSpline.java index 6d9ded0243..5d38bef60a 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/spline/QuinticHermiteSpline.java +++ b/wpimath/src/main/java/edu/wpi/first/math/spline/QuinticHermiteSpline.java @@ -6,6 +6,7 @@ package edu.wpi.first.math.spline; import org.ejml.simple.SimpleMatrix; +/** Represents a hermite spline of degree 5. */ public class QuinticHermiteSpline extends Spline { private static SimpleMatrix hermiteBasis; private final SimpleMatrix m_coefficients; diff --git a/wpimath/src/main/java/edu/wpi/first/math/spline/Spline.java b/wpimath/src/main/java/edu/wpi/first/math/spline/Spline.java index afdb2d2255..dc6c5e6996 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/spline/Spline.java +++ b/wpimath/src/main/java/edu/wpi/first/math/spline/Spline.java @@ -99,7 +99,10 @@ public abstract class Spline { * the value of x[2] is the second derivative in the x dimension. */ public static class ControlVector { + /** The x components of the control vector. */ public double[] x; + + /** The y components of the control vector. */ public double[] y; /** diff --git a/wpimath/src/main/java/edu/wpi/first/math/spline/SplineHelper.java b/wpimath/src/main/java/edu/wpi/first/math/spline/SplineHelper.java index d6a95671df..3ba2714403 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/spline/SplineHelper.java +++ b/wpimath/src/main/java/edu/wpi/first/math/spline/SplineHelper.java @@ -10,6 +10,7 @@ import java.util.Arrays; import java.util.List; import org.ejml.simple.SimpleMatrix; +/** Helper class that is used to generate cubic and quintic splines from user provided waypoints. */ public final class SplineHelper { /** Private constructor because this is a utility class. */ private SplineHelper() {} diff --git a/wpimath/src/main/java/edu/wpi/first/math/spline/SplineParameterizer.java b/wpimath/src/main/java/edu/wpi/first/math/spline/SplineParameterizer.java index b2a34a5db5..5cf742b3da 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/spline/SplineParameterizer.java +++ b/wpimath/src/main/java/edu/wpi/first/math/spline/SplineParameterizer.java @@ -56,6 +56,7 @@ public final class SplineParameterizer { } } + /** Exception for malformed splines. */ public static class MalformedSplineException extends RuntimeException { /** * Create a new exception with the given message. diff --git a/wpimath/src/main/java/edu/wpi/first/math/system/Discretization.java b/wpimath/src/main/java/edu/wpi/first/math/system/Discretization.java index b2fe9c8c8e..b4afdf476a 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/system/Discretization.java +++ b/wpimath/src/main/java/edu/wpi/first/math/system/Discretization.java @@ -9,6 +9,7 @@ import edu.wpi.first.math.Num; import edu.wpi.first.math.Pair; import org.ejml.simple.SimpleMatrix; +/** Discretization helper functions. */ public final class Discretization { private Discretization() { // Utility class diff --git a/wpimath/src/main/java/edu/wpi/first/math/system/LinearSystem.java b/wpimath/src/main/java/edu/wpi/first/math/system/LinearSystem.java index d7b660298a..18deaa97fc 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/system/LinearSystem.java +++ b/wpimath/src/main/java/edu/wpi/first/math/system/LinearSystem.java @@ -8,6 +8,18 @@ import edu.wpi.first.math.Matrix; import edu.wpi.first.math.Num; import edu.wpi.first.math.numbers.N1; +/** + * A plant defined using state-space notation. + * + *

A plant is a mathematical model of a system's dynamics. + * + *

For more on the underlying math, read + * https://file.tavsys.net/control/controls-engineering-in-frc.pdf. + * + * @param Number of states. + * @param Number of inputs. + * @param Number of outputs. + */ public class LinearSystem { /** Continuous system matrix. */ private final Matrix m_A; diff --git a/wpimath/src/main/java/edu/wpi/first/math/system/NumericalIntegration.java b/wpimath/src/main/java/edu/wpi/first/math/system/NumericalIntegration.java index e9b46fcbe1..36d7bcb7a7 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/system/NumericalIntegration.java +++ b/wpimath/src/main/java/edu/wpi/first/math/system/NumericalIntegration.java @@ -11,6 +11,7 @@ import java.util.function.BiFunction; import java.util.function.DoubleFunction; import java.util.function.Function; +/** Numerical integration utilities. */ public final class NumericalIntegration { private NumericalIntegration() { // utility Class diff --git a/wpimath/src/main/java/edu/wpi/first/math/system/NumericalJacobian.java b/wpimath/src/main/java/edu/wpi/first/math/system/NumericalJacobian.java index 43eba93bbe..1be22a8fca 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/system/NumericalJacobian.java +++ b/wpimath/src/main/java/edu/wpi/first/math/system/NumericalJacobian.java @@ -11,6 +11,7 @@ import edu.wpi.first.math.numbers.N1; import java.util.function.BiFunction; import java.util.function.Function; +/** Numerical Jacobian utilities. */ public final class NumericalJacobian { private NumericalJacobian() { // Utility Class. diff --git a/wpimath/src/main/java/edu/wpi/first/math/system/plant/DCMotor.java b/wpimath/src/main/java/edu/wpi/first/math/system/plant/DCMotor.java index 25da66ceab..6d18846f25 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/system/plant/DCMotor.java +++ b/wpimath/src/main/java/edu/wpi/first/math/system/plant/DCMotor.java @@ -12,16 +12,34 @@ import edu.wpi.first.util.struct.StructSerializable; /** Holds the constants for a DC motor. */ public class DCMotor implements ProtobufSerializable, StructSerializable { + /** Voltage at which the motor constants were measured. */ public final double nominalVoltageVolts; + + /** Torque when stalled. */ public final double stallTorqueNewtonMeters; + + /** Current draw when stalled. */ public final double stallCurrentAmps; + + /** Current draw under no load. */ public final double freeCurrentAmps; + + /** Angular velocity under no load. */ public final double freeSpeedRadPerSec; + + /** Motor internal resistance. */ public final double rOhms; + + /** Motor velocity constant. */ public final double KvRadPerSecPerVolt; + + /** Motor torque constant. */ public final double KtNMPerAmp; + /** DCMotor protobuf for serialization. */ public static final DCMotorProto proto = new DCMotorProto(); + + /** DCMotor struct for serialization. */ public static final DCMotorStruct struct = new DCMotorStruct(); /** diff --git a/wpimath/src/main/java/edu/wpi/first/math/system/plant/LinearSystemId.java b/wpimath/src/main/java/edu/wpi/first/math/system/plant/LinearSystemId.java index 3ab305872d..2e7d4b94f2 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/system/plant/LinearSystemId.java +++ b/wpimath/src/main/java/edu/wpi/first/math/system/plant/LinearSystemId.java @@ -12,6 +12,7 @@ import edu.wpi.first.math.numbers.N1; import edu.wpi.first.math.numbers.N2; import edu.wpi.first.math.system.LinearSystem; +/** Linear system ID utility functions. */ public final class LinearSystemId { private LinearSystemId() { // Utility class diff --git a/wpimath/src/main/java/edu/wpi/first/math/trajectory/ExponentialProfile.java b/wpimath/src/main/java/edu/wpi/first/math/trajectory/ExponentialProfile.java index 505b47ca4e..46b0c14416 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/trajectory/ExponentialProfile.java +++ b/wpimath/src/main/java/edu/wpi/first/math/trajectory/ExponentialProfile.java @@ -39,10 +39,20 @@ import java.util.Objects; public class ExponentialProfile { private final Constraints m_constraints; + /** Profile timing. */ public static class ProfileTiming { + /** Profile inflection time. */ public final double inflectionTime; + + /** Total profile time. */ public final double totalTime; + /** + * Constructs a ProfileTiming. + * + * @param inflectionTime Profile inflection time. + * @param totalTime Total profile time. + */ protected ProfileTiming(double inflectionTime, double totalTime) { this.inflectionTime = inflectionTime; this.totalTime = totalTime; @@ -55,14 +65,19 @@ public class ExponentialProfile { * @return if the profile is finished at time t. */ public boolean isFinished(double t) { - return t > inflectionTime; + return t >= inflectionTime; } } + /** Profile constraints. */ public static class Constraints { + /** Maximum unsigned input voltage. */ public final double maxInput; + /** The State-Space 1x1 system matrix. */ public final double A; + + /** The State-Space 1x1 input matrix. */ public final double B; /** @@ -112,11 +127,15 @@ public class ExponentialProfile { } } + /** Profile state. */ public static class State { + /** The position at this state. */ public double position; + /** The velocity at this state. */ public double velocity; + /** Default constructor. */ public State() {} /** diff --git a/wpimath/src/main/java/edu/wpi/first/math/trajectory/Trajectory.java b/wpimath/src/main/java/edu/wpi/first/math/trajectory/Trajectory.java index 6d9ec0c682..c0dc037a75 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/trajectory/Trajectory.java +++ b/wpimath/src/main/java/edu/wpi/first/math/trajectory/Trajectory.java @@ -20,6 +20,7 @@ import java.util.stream.Collectors; * represent the pose, curvature, time elapsed, velocity, and acceleration at that point. */ public class Trajectory implements ProtobufSerializable { + /** Trajectory protobuf for serialization. */ public static final TrajectoryProto proto = new TrajectoryProto(); private final double m_totalTimeSeconds; @@ -269,28 +270,30 @@ public class Trajectory implements ProtobufSerializable { * represent the pose, curvature, time elapsed, velocity, and acceleration at that point. */ public static class State implements ProtobufSerializable { + /** Trajectory.State protobuf for serialization. */ public static final TrajectoryStateProto proto = new TrajectoryStateProto(); - // The time elapsed since the beginning of the trajectory. + /** The time elapsed since the beginning of the trajectory. */ @JsonProperty("time") public double timeSeconds; - // The speed at that point of the trajectory. + /** The speed at that point of the trajectory. */ @JsonProperty("velocity") public double velocityMetersPerSecond; - // The acceleration at that point of the trajectory. + /** The acceleration at that point of the trajectory. */ @JsonProperty("acceleration") public double accelerationMetersPerSecondSq; - // The pose at that point of the trajectory. + /** The pose at that point of the trajectory. */ @JsonProperty("pose") public Pose2d poseMeters; - // The curvature at that point of the trajectory. + /** The curvature at that point of the trajectory. */ @JsonProperty("curvature") public double curvatureRadPerMeter; + /** Default constructor. */ public State() { poseMeters = new Pose2d(); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryGenerator.java b/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryGenerator.java index e87070292c..fcfef4508c 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryGenerator.java +++ b/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryGenerator.java @@ -19,6 +19,7 @@ import java.util.Collection; import java.util.List; import java.util.function.BiConsumer; +/** Helper class used to generate trajectories with various constraints. */ public final class TrajectoryGenerator { private static final Trajectory kDoNothingTrajectory = new Trajectory(List.of(new Trajectory.State())); @@ -263,16 +264,27 @@ public final class TrajectoryGenerator { return splinePoints; } - // Work around type erasure signatures + /** Control vector list type that works around type erasure signatures. */ public static class ControlVectorList extends ArrayList { - public ControlVectorList(int initialCapacity) { - super(initialCapacity); - } - + /** Default constructor. */ public ControlVectorList() { super(); } + /** + * Constructs a ControlVectorList. + * + * @param initialCapacity The initial list capacity. + */ + public ControlVectorList(int initialCapacity) { + super(initialCapacity); + } + + /** + * Constructs a ControlVectorList. + * + * @param collection A collection of spline control vectors. + */ public ControlVectorList(Collection collection) { super(collection); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryParameterizer.java b/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryParameterizer.java index a741aa09db..35b2a46505 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryParameterizer.java +++ b/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryParameterizer.java @@ -315,7 +315,13 @@ public final class TrajectoryParameterizer { } } + /** Exception for trajectory generation failure. */ public static class TrajectoryGenerationException extends RuntimeException { + /** + * Constructs a TrajectoryGenerationException. + * + * @param message Exception message. + */ public TrajectoryGenerationException(String message) { super(message); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryUtil.java b/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryUtil.java index 2cbba90861..f1b2d6a97b 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryUtil.java +++ b/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryUtil.java @@ -12,6 +12,7 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +/** Trajectory utilities. */ public final class TrajectoryUtil { private TrajectoryUtil() { throw new UnsupportedOperationException("This is a utility class!"); @@ -111,7 +112,13 @@ public final class TrajectoryUtil { return WPIMathJNI.serializeTrajectory(getElementsFromTrajectory(trajectory)); } + /** Exception for trajectory serialization failure. */ public static class TrajectorySerializationException extends RuntimeException { + /** + * Constructs a TrajectorySerializationException. + * + * @param message The exception message. + */ public TrajectorySerializationException(String message) { super(message); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrapezoidProfile.java b/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrapezoidProfile.java index f14aea78f0..5215d3a4f9 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrapezoidProfile.java +++ b/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrapezoidProfile.java @@ -54,9 +54,12 @@ public class TrapezoidProfile { private double m_endFullSpeed; private double m_endDeccel; + /** Profile constraints. */ public static class Constraints { + /** Maximum velocity. */ public final double maxVelocity; + /** Maximum acceleration. */ public final double maxAcceleration; /** @@ -71,24 +74,48 @@ public class TrapezoidProfile { MathSharedStore.reportUsage(MathUsageId.kTrajectory_TrapezoidProfile, 1); } + /** + * Construct constraints for a TrapezoidProfile. + * + * @param Unit type. + * @param maxVelocity maximum velocity + * @param maxAcceleration maximum acceleration + */ public > Constraints( Measure> maxVelocity, Measure>> maxAcceleration) { this(maxVelocity.baseUnitMagnitude(), maxAcceleration.baseUnitMagnitude()); } } + /** Profile state. */ public static class State { + /** The position at this state. */ public double position; + /** The velocity at this state. */ public double velocity; + /** Default constructor. */ public State() {} + /** + * Constructs constraints for a Trapezoid Profile. + * + * @param position The position at this state. + * @param velocity The velocity at this state. + */ public State(double position, double velocity) { this.position = position; this.velocity = velocity; } + /** + * Constructs constraints for a Trapezoid Profile. + * + * @param Unit type. + * @param position The position at this state. + * @param velocity The velocity at this state. + */ public > State(Measure position, Measure> velocity) { this(position.baseUnitMagnitude(), velocity.baseUnitMagnitude()); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/trajectory/constraint/TrajectoryConstraint.java b/wpimath/src/main/java/edu/wpi/first/math/trajectory/constraint/TrajectoryConstraint.java index 1f2c9cfb59..48490d4eba 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/trajectory/constraint/TrajectoryConstraint.java +++ b/wpimath/src/main/java/edu/wpi/first/math/trajectory/constraint/TrajectoryConstraint.java @@ -37,7 +37,10 @@ public interface TrajectoryConstraint { /** Represents a minimum and maximum acceleration. */ class MinMax { + /** The minimum acceleration. */ public double minAccelerationMetersPerSecondSq = -Double.MAX_VALUE; + + /** The maximum acceleration. */ public double maxAccelerationMetersPerSecondSq = Double.MAX_VALUE; /** diff --git a/wpimath/src/main/native/cpp/kinematics/proto/MecanumDriveKinematicsProto.cpp b/wpimath/src/main/native/cpp/kinematics/proto/MecanumDriveKinematicsProto.cpp index 5b3c027e6e..e17102ffbf 100644 --- a/wpimath/src/main/native/cpp/kinematics/proto/MecanumDriveKinematicsProto.cpp +++ b/wpimath/src/main/native/cpp/kinematics/proto/MecanumDriveKinematicsProto.cpp @@ -26,8 +26,8 @@ frc::MecanumDriveKinematics wpi::Protobuf::Unpack( void wpi::Protobuf::Pack( google::protobuf::Message* msg, const frc::MecanumDriveKinematics& value) { auto m = static_cast(msg); - wpi::PackProtobuf(m->mutable_front_left(), value.GetFrontLeftWheel()); - wpi::PackProtobuf(m->mutable_front_right(), value.GetFrontRightWheel()); - wpi::PackProtobuf(m->mutable_rear_left(), value.GetRearLeftWheel()); - wpi::PackProtobuf(m->mutable_rear_right(), value.GetRearRightWheel()); + wpi::PackProtobuf(m->mutable_front_left(), value.GetFrontLeft()); + wpi::PackProtobuf(m->mutable_front_right(), value.GetFrontRight()); + wpi::PackProtobuf(m->mutable_rear_left(), value.GetRearLeft()); + wpi::PackProtobuf(m->mutable_rear_right(), value.GetRearRight()); } diff --git a/wpimath/src/main/native/cpp/kinematics/struct/MecanumDriveKinematicsStruct.cpp b/wpimath/src/main/native/cpp/kinematics/struct/MecanumDriveKinematicsStruct.cpp index 261966cee1..1a27a286a6 100644 --- a/wpimath/src/main/native/cpp/kinematics/struct/MecanumDriveKinematicsStruct.cpp +++ b/wpimath/src/main/native/cpp/kinematics/struct/MecanumDriveKinematicsStruct.cpp @@ -27,8 +27,8 @@ frc::MecanumDriveKinematics StructType::Unpack(std::span data) { void StructType::Pack(std::span data, const frc::MecanumDriveKinematics& value) { - wpi::PackStruct(data, value.GetFrontLeftWheel()); - wpi::PackStruct(data, value.GetFrontRightWheel()); - wpi::PackStruct(data, value.GetRearLeftWheel()); - wpi::PackStruct(data, value.GetRearRightWheel()); + wpi::PackStruct(data, value.GetFrontLeft()); + wpi::PackStruct(data, value.GetFrontRight()); + wpi::PackStruct(data, value.GetRearLeft()); + wpi::PackStruct(data, value.GetRearRight()); } diff --git a/wpimath/src/main/native/include/frc/controller/ArmFeedforward.h b/wpimath/src/main/native/include/frc/controller/ArmFeedforward.h index 933a4051d6..69091ccd9a 100644 --- a/wpimath/src/main/native/include/frc/controller/ArmFeedforward.h +++ b/wpimath/src/main/native/include/frc/controller/ArmFeedforward.h @@ -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, @@ -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; + + /// The acceleration gain, in volt seconds² per radian. const units::unit_t kA; }; } // namespace frc diff --git a/wpimath/src/main/native/include/frc/controller/DifferentialDriveWheelVoltages.h b/wpimath/src/main/native/include/frc/controller/DifferentialDriveWheelVoltages.h index 235a95877e..424cd2d1b3 100644 --- a/wpimath/src/main/native/include/frc/controller/DifferentialDriveWheelVoltages.h +++ b/wpimath/src/main/native/include/frc/controller/DifferentialDriveWheelVoltages.h @@ -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; }; diff --git a/wpimath/src/main/native/include/frc/controller/ElevatorFeedforward.h b/wpimath/src/main/native/include/frc/controller/ElevatorFeedforward.h index 2d81a0ae33..07a0499a53 100644 --- a/wpimath/src/main/native/include/frc/controller/ElevatorFeedforward.h +++ b/wpimath/src/main/native/include/frc/controller/ElevatorFeedforward.h @@ -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; + + /// The acceleration gain. const units::unit_t kA; }; } // namespace frc diff --git a/wpimath/src/main/native/include/frc/controller/SimpleMotorFeedforward.h b/wpimath/src/main/native/include/frc/controller/SimpleMotorFeedforward.h index 767b05d4d6..cc31fc1058 100644 --- a/wpimath/src/main/native/include/frc/controller/SimpleMotorFeedforward.h +++ b/wpimath/src/main/native/include/frc/controller/SimpleMotorFeedforward.h @@ -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; + + /** The acceleration gain. */ const units::unit_t kA; }; } // namespace frc diff --git a/wpimath/src/main/native/include/frc/estimator/KalmanFilterLatencyCompensator.h b/wpimath/src/main/native/include/frc/estimator/KalmanFilterLatencyCompensator.h index d6e41271c8..b93d614f01 100644 --- a/wpimath/src/main/native/include/frc/estimator/KalmanFilterLatencyCompensator.h +++ b/wpimath/src/main/native/include/frc/estimator/KalmanFilterLatencyCompensator.h @@ -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 class KalmanFilterLatencyCompensator { public: + /** + * This class contains all the information about our observer at a given time. + */ struct ObserverSnapshot { + /// The state estimate. Vectord xHat; + /// The square root error covariance. Matrixd squareRootErrorCovariances; + /// The inputs. Vectord inputs; + /// The local measurements. Vectord localMeasurements; ObserverSnapshot(const KalmanFilterType& observer, const Vectord& u, diff --git a/wpimath/src/main/native/include/frc/filter/Debouncer.h b/wpimath/src/main/native/include/frc/filter/Debouncer.h index a929f37358..9ab3e0e168 100644 --- a/wpimath/src/main/native/include/frc/filter/Debouncer.h +++ b/wpimath/src/main/native/include/frc/filter/Debouncer.h @@ -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. diff --git a/wpimath/src/main/native/include/frc/geometry/Quaternion.h b/wpimath/src/main/native/include/frc/geometry/Quaternion.h index a9526bc379..4fe694cf25 100644 --- a/wpimath/src/main/native/include/frc/geometry/Quaternion.h +++ b/wpimath/src/main/native/include/frc/geometry/Quaternion.h @@ -10,6 +10,9 @@ namespace frc { +/** + * Represents a quaternion. + */ class WPILIB_DLLEXPORT Quaternion { public: /** diff --git a/wpimath/src/main/native/include/frc/kinematics/DifferentialDriveKinematics.h b/wpimath/src/main/native/include/frc/kinematics/DifferentialDriveKinematics.h index 3ea6ee92d3..0f0cff9faa 100644 --- a/wpimath/src/main/native/include/frc/kinematics/DifferentialDriveKinematics.h +++ b/wpimath/src/main/native/include/frc/kinematics/DifferentialDriveKinematics.h @@ -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 diff --git a/wpimath/src/main/native/include/frc/kinematics/MecanumDriveKinematics.h b/wpimath/src/main/native/include/frc/kinematics/MecanumDriveKinematics.h index 24f450abf7..f5a53ca953 100644 --- a/wpimath/src/main/native/include/frc/kinematics/MecanumDriveKinematics.h +++ b/wpimath/src/main/native/include/frc/kinematics/MecanumDriveKinematics.h @@ -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; diff --git a/wpimath/src/main/native/include/frc/spline/Spline.h b/wpimath/src/main/native/include/frc/spline/Spline.h index c195a6755f..257b167f38 100644 --- a/wpimath/src/main/native/include/frc/spline/Spline.h +++ b/wpimath/src/main/native/include/frc/spline/Spline.h @@ -44,7 +44,10 @@ class Spline { * dimension. */ struct ControlVector { + /// The x components of the control vector. wpi::array x; + + /// The y components of the control vector. wpi::array y; }; diff --git a/wpimath/src/main/native/include/frc/system/plant/DCMotor.h b/wpimath/src/main/native/include/frc/system/plant/DCMotor.h index de9c3b1b54..a267945247 100644 --- a/wpimath/src/main/native/include/frc/system/plant/DCMotor.h +++ b/wpimath/src/main/native/include/frc/system/plant/DCMotor.h @@ -26,19 +26,28 @@ class WPILIB_DLLEXPORT DCMotor { units::unit_t>>; + /// 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; /** diff --git a/wpimath/src/main/native/include/frc/system/plant/LinearSystemId.h b/wpimath/src/main/native/include/frc/system/plant/LinearSystemId.h index 76979d7b62..ad5d3b0e28 100644 --- a/wpimath/src/main/native/include/frc/system/plant/LinearSystemId.h +++ b/wpimath/src/main/native/include/frc/system/plant/LinearSystemId.h @@ -20,6 +20,9 @@ #include "units/voltage.h" namespace frc { +/** + * Linear system ID utility functions. + */ class WPILIB_DLLEXPORT LinearSystemId { public: template diff --git a/wpimath/src/main/native/include/frc/trajectory/ExponentialProfile.h b/wpimath/src/main/native/include/frc/trajectory/ExponentialProfile.h index f45987b7d0..3622aa7865 100644 --- a/wpimath/src/main/native/include/frc/trajectory/ExponentialProfile.h +++ b/wpimath/src/main/native/include/frc/trajectory/ExponentialProfile.h @@ -55,36 +55,80 @@ class ExponentialProfile { using KA = units::compound_unit>; using kA_t = units::unit_t; + /** + * 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. * diff --git a/wpimath/src/main/native/include/frc/trajectory/Trajectory.h b/wpimath/src/main/native/include/frc/trajectory/Trajectory.h index 2ad972ea49..753bf9e2d1 100644 --- a/wpimath/src/main/native/include/frc/trajectory/Trajectory.h +++ b/wpimath/src/main/native/include/frc/trajectory/Trajectory.h @@ -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}; /** diff --git a/wpimath/src/main/native/include/frc/trajectory/TrajectoryUtil.h b/wpimath/src/main/native/include/frc/trajectory/TrajectoryUtil.h index 3ba882f1ac..48a0a49a9b 100644 --- a/wpimath/src/main/native/include/frc/trajectory/TrajectoryUtil.h +++ b/wpimath/src/main/native/include/frc/trajectory/TrajectoryUtil.h @@ -12,6 +12,9 @@ #include "frc/trajectory/Trajectory.h" namespace frc { +/** + * Trajectory utilities. + */ class WPILIB_DLLEXPORT TrajectoryUtil { public: TrajectoryUtil() = delete; diff --git a/wpimath/src/main/native/include/frc/trajectory/TrapezoidProfile.h b/wpimath/src/main/native/include/frc/trajectory/TrapezoidProfile.h index 18002462a0..08640fbf54 100644 --- a/wpimath/src/main/native/include/frc/trajectory/TrapezoidProfile.h +++ b/wpimath/src/main/native/include/frc/trajectory/TrapezoidProfile.h @@ -52,25 +52,49 @@ class TrapezoidProfile { units::compound_unit>; using Acceleration_t = units::unit_t; + /** + * 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; }; diff --git a/wpimath/src/test/native/cpp/kinematics/proto/MecanumDriveKinematicsProtoTest.cpp b/wpimath/src/test/native/cpp/kinematics/proto/MecanumDriveKinematicsProtoTest.cpp index 7051ca1a0c..c601fc3b4d 100644 --- a/wpimath/src/test/native/cpp/kinematics/proto/MecanumDriveKinematicsProtoTest.cpp +++ b/wpimath/src/test/native/cpp/kinematics/proto/MecanumDriveKinematicsProtoTest.cpp @@ -24,11 +24,8 @@ TEST(MecanumDriveKinematicsProtoTest, Roundtrip) { ProtoType::Pack(proto, kExpectedData); MecanumDriveKinematics unpacked_data = ProtoType::Unpack(*proto); - EXPECT_EQ(kExpectedData.GetFrontLeftWheel(), - unpacked_data.GetFrontLeftWheel()); - EXPECT_EQ(kExpectedData.GetFrontRightWheel(), - unpacked_data.GetFrontRightWheel()); - EXPECT_EQ(kExpectedData.GetRearLeftWheel(), unpacked_data.GetRearLeftWheel()); - EXPECT_EQ(kExpectedData.GetRearRightWheel(), - unpacked_data.GetRearRightWheel()); + EXPECT_EQ(kExpectedData.GetFrontLeft(), unpacked_data.GetFrontLeft()); + EXPECT_EQ(kExpectedData.GetFrontRight(), unpacked_data.GetFrontRight()); + EXPECT_EQ(kExpectedData.GetRearLeft(), unpacked_data.GetRearLeft()); + EXPECT_EQ(kExpectedData.GetRearRight(), unpacked_data.GetRearRight()); } diff --git a/wpimath/src/test/native/cpp/kinematics/struct/MecanumDriveKinematicsStructTest.cpp b/wpimath/src/test/native/cpp/kinematics/struct/MecanumDriveKinematicsStructTest.cpp index 0b3676d63f..920c668ae1 100644 --- a/wpimath/src/test/native/cpp/kinematics/struct/MecanumDriveKinematicsStructTest.cpp +++ b/wpimath/src/test/native/cpp/kinematics/struct/MecanumDriveKinematicsStructTest.cpp @@ -23,11 +23,8 @@ TEST(MecanumDriveKinematicsStructTest, Roundtrip) { MecanumDriveKinematics unpacked_data = StructType::Unpack(buffer); - EXPECT_EQ(kExpectedData.GetFrontLeftWheel(), - unpacked_data.GetFrontLeftWheel()); - EXPECT_EQ(kExpectedData.GetFrontRightWheel(), - unpacked_data.GetFrontRightWheel()); - EXPECT_EQ(kExpectedData.GetRearLeftWheel(), unpacked_data.GetRearLeftWheel()); - EXPECT_EQ(kExpectedData.GetRearRightWheel(), - unpacked_data.GetRearRightWheel()); + EXPECT_EQ(kExpectedData.GetFrontLeft(), unpacked_data.GetFrontLeft()); + EXPECT_EQ(kExpectedData.GetFrontRight(), unpacked_data.GetFrontRight()); + EXPECT_EQ(kExpectedData.GetRearLeft(), unpacked_data.GetRearLeft()); + EXPECT_EQ(kExpectedData.GetRearRight(), unpacked_data.GetRearRight()); } diff --git a/wpiutil/src/main/java/edu/wpi/first/util/CombinedRuntimeLoader.java b/wpiutil/src/main/java/edu/wpi/first/util/CombinedRuntimeLoader.java index 23149bd381..8fe4839d25 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/CombinedRuntimeLoader.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/CombinedRuntimeLoader.java @@ -16,11 +16,17 @@ import java.util.List; import java.util.Map; import java.util.Objects; +/** Loads dynamic libraries for all platforms. */ public final class CombinedRuntimeLoader { private CombinedRuntimeLoader() {} private static String extractionDirectory; + /** + * Returns library extraction directory. + * + * @return Library extraction directory. + */ public static synchronized String getExtractionDirectory() { return extractionDirectory; } @@ -29,6 +35,12 @@ public final class CombinedRuntimeLoader { extractionDirectory = directory; } + /** + * Sets DLL directory. + * + * @param directory Directory. + * @return DLL directory. + */ public static native String setDllDirectory(String directory); private static String getLoadErrorMessage(String libraryName, UnsatisfiedLinkError ule) { diff --git a/wpiutil/src/main/java/edu/wpi/first/util/EventVector.java b/wpiutil/src/main/java/edu/wpi/first/util/EventVector.java index 2910bd2147..60fb5d13d0 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/EventVector.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/EventVector.java @@ -13,6 +13,9 @@ public class EventVector { private final ReentrantLock m_lock = new ReentrantLock(); private final List m_events = new ArrayList<>(); + /** Default constructor. */ + public EventVector() {} + /** * Adds an event to the event vector. * diff --git a/wpiutil/src/main/java/edu/wpi/first/util/InterpolatingTreeMap.java b/wpiutil/src/main/java/edu/wpi/first/util/InterpolatingTreeMap.java index 7810afd787..8efe9172fc 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/InterpolatingTreeMap.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/InterpolatingTreeMap.java @@ -18,6 +18,9 @@ import java.util.TreeMap; public class InterpolatingTreeMap { private final TreeMap m_map = new TreeMap<>(); + /** Default constructor. */ + public InterpolatingTreeMap() {} + /** * Inserts a key-value pair. * diff --git a/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java b/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java index f24ace3323..474666ee02 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java @@ -17,6 +17,11 @@ import java.security.NoSuchAlgorithmException; import java.util.Locale; import java.util.Scanner; +/** + * Loads a native library at runtime. + * + * @param The class to load. + */ public final class RuntimeLoader { private static String defaultExtractionRoot; diff --git a/wpiutil/src/main/java/edu/wpi/first/util/WPIUtilJNI.java b/wpiutil/src/main/java/edu/wpi/first/util/WPIUtilJNI.java index 94165e9618..0bd5b2169c 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/WPIUtilJNI.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/WPIUtilJNI.java @@ -70,16 +70,38 @@ public class WPIUtilJNI { libraryLoaded = true; } + /** + * Write the given string to stderr. + * + * @param str String to write. + */ public static native void writeStderr(String str); + /** Enable mock time. */ public static native void enableMockTime(); + /** Disable mock time. */ public static native void disableMockTime(); + /** + * Set mock time. + * + * @param time The desired time in microseconds. + */ public static native void setMockTime(long time); + /** + * Returns the time. + * + * @return The time. + */ public static native long now(); + /** + * Returns the system time. + * + * @return The system time. + */ public static native long getSystemTime(); /** diff --git a/wpiutil/src/main/java/edu/wpi/first/util/cleanup/CleanupPool.java b/wpiutil/src/main/java/edu/wpi/first/util/cleanup/CleanupPool.java index 0ae5200e8c..4b8c21115f 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/cleanup/CleanupPool.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/cleanup/CleanupPool.java @@ -16,6 +16,9 @@ public class CleanupPool implements AutoCloseable { // state ArrayDeque is faster anyway. private final Deque m_closers = new ArrayDeque<>(); + /** Default constructor. */ + public CleanupPool() {} + /** * Registers an object in the object stack for cleanup. * diff --git a/wpiutil/src/main/java/edu/wpi/first/util/cleanup/SkipCleanup.java b/wpiutil/src/main/java/edu/wpi/first/util/cleanup/SkipCleanup.java index e2bc72eaeb..fcbcb7e896 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/cleanup/SkipCleanup.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/cleanup/SkipCleanup.java @@ -9,6 +9,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** Attribute for telling JVM to skip object cleanup. */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface SkipCleanup {} diff --git a/wpiutil/src/main/java/edu/wpi/first/util/datalog/DataLogJNI.java b/wpiutil/src/main/java/edu/wpi/first/util/datalog/DataLogJNI.java index 70ff70ae2a..c7643390f1 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/datalog/DataLogJNI.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/datalog/DataLogJNI.java @@ -267,4 +267,7 @@ public class DataLogJNI extends WPIUtilJNI { * @param timestamp Time stamp (may be 0 to indicate now) */ static native void appendStringArray(long impl, int entry, String[] value, long timestamp); + + /** Utility class. */ + private DataLogJNI() {} } diff --git a/wpiutil/src/main/java/edu/wpi/first/util/protobuf/ProtobufBuffer.java b/wpiutil/src/main/java/edu/wpi/first/util/protobuf/ProtobufBuffer.java index ae03c63300..1f8fdf090a 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/protobuf/ProtobufBuffer.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/protobuf/ProtobufBuffer.java @@ -26,6 +26,14 @@ public final class ProtobufBuffer> { m_proto = proto; } + /** + * Creates a ProtobufBuffer for the given Protobuf object. + * + * @param The type to serialize. + * @param The Protobuf message type. + * @param proto The Protobuf object. + * @return A ProtobufBuffer for the given Protobuf object. + */ public static > ProtobufBuffer create( Protobuf proto) { return new ProtobufBuffer<>(proto); diff --git a/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableBuilder.java b/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableBuilder.java index db822ce441..ee93725acd 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableBuilder.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableBuilder.java @@ -15,10 +15,14 @@ import java.util.function.LongConsumer; import java.util.function.LongSupplier; import java.util.function.Supplier; +/** Helper class for building Sendable dashboard representations. */ public interface SendableBuilder extends AutoCloseable { /** The backend kinds used for the sendable builder. */ enum BackendKind { + /** Unknown. */ kUnknown, + + /** NetworkTables. */ kNetworkTables } diff --git a/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableRegistry.java b/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableRegistry.java index 6f0ad41d65..025b802094 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableRegistry.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableRegistry.java @@ -506,6 +506,9 @@ public final class SendableRegistry { /** Sendable builder for the sendable. */ public SendableBuilder builder; + + /** Default constructor. */ + public CallbackData() {} } // As foreachLiveWindow is single threaded, cache the components it diff --git a/wpiutil/src/main/java/edu/wpi/first/util/struct/StructBuffer.java b/wpiutil/src/main/java/edu/wpi/first/util/struct/StructBuffer.java index 8bd5768f09..a5d04e0968 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/struct/StructBuffer.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/struct/StructBuffer.java @@ -12,7 +12,7 @@ import java.util.Collection; /** * Reusable buffer for serialization/deserialization to/from a raw struct. * - * @param object type + * @param Object type. */ public final class StructBuffer { private StructBuffer(Struct struct) { @@ -21,6 +21,13 @@ public final class StructBuffer { m_struct = struct; } + /** + * Returns a StructBuffer for the given struct. + * + * @param struct A struct. + * @param Object type. + * @return A StructBuffer for the given struct. + */ public static StructBuffer create(Struct struct) { return new StructBuffer<>(struct); } diff --git a/wpiutil/src/main/java/edu/wpi/first/util/struct/StructDescriptorDatabase.java b/wpiutil/src/main/java/edu/wpi/first/util/struct/StructDescriptorDatabase.java index 1eb58c9baf..459fa9e10f 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/struct/StructDescriptorDatabase.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/struct/StructDescriptorDatabase.java @@ -14,6 +14,9 @@ import java.util.Stack; /** Database of raw struct dynamic descriptors. */ public class StructDescriptorDatabase { + /** Default constructor. */ + public StructDescriptorDatabase() {} + /** * Adds a structure schema to the database. If the struct references other structs that have not * yet been added, it will not be valid until those structs are also added. diff --git a/wpiutil/src/main/java/edu/wpi/first/util/struct/StructFieldType.java b/wpiutil/src/main/java/edu/wpi/first/util/struct/StructFieldType.java index bee855839f..4b3cf179d3 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/struct/StructFieldType.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/struct/StructFieldType.java @@ -6,18 +6,31 @@ package edu.wpi.first.util.struct; /** Known data types for raw struct dynamic fields (see StructFieldDescriptor). */ public enum StructFieldType { + /** bool. */ kBool("bool", false, false, 1), + /** char. */ kChar("char", false, false, 1), + /** int8. */ kInt8("int8", true, false, 1), + /** int16. */ kInt16("int16", true, false, 2), + /** int32. */ kInt32("int32", true, false, 4), + /** int64. */ kInt64("int64", true, false, 8), + /** uint8. */ kUint8("uint8", false, true, 1), + /** uint16. */ kUint16("uint16", false, true, 2), + /** uint32. */ kUint32("uint32", false, true, 4), + /** uint64. */ kUint64("uint64", false, true, 8), + /** float. */ kFloat("float", false, false, 4), + /** double. */ kDouble("double", false, false, 8), + /** struct. */ kStruct("struct", false, false, 0); /** The name of the data type. */ diff --git a/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/ParseException.java b/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/ParseException.java index 7ce4a08621..5e71c79ca9 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/ParseException.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/ParseException.java @@ -4,25 +4,50 @@ package edu.wpi.first.util.struct.parser; +/** Exception for parsing errors. */ public class ParseException extends Exception { /** The parser position. */ private final int m_pos; + /** + * Constructs a ParseException. + * + * @param pos The parser position. + * @param s Reason for parse failure. + */ public ParseException(int pos, String s) { super(s); m_pos = pos; } + /** + * Constructs a ParseException. + * + * @param pos The parser position. + * @param message Reason for parse failure. + * @param cause Exception that caused the parser failure. + */ public ParseException(int pos, String message, Throwable cause) { super(message, cause); m_pos = pos; } + /** + * Constructs a ParseException. + * + * @param pos The parser position. + * @param cause Exception that caused the parser failure. + */ public ParseException(int pos, Throwable cause) { super(cause); m_pos = pos; } + /** + * Returns position in parsed string. + * + * @return Position in parsed string. + */ public int getPosition() { return m_pos; } diff --git a/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/ParsedDeclaration.java b/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/ParsedDeclaration.java index 8184ae5e56..29743ab05a 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/ParsedDeclaration.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/ParsedDeclaration.java @@ -8,18 +8,26 @@ import java.util.Map; /** Raw struct schema declaration. */ public class ParsedDeclaration { + /** Type string. */ @SuppressWarnings("MemberName") public String typeString; + /** Name. */ @SuppressWarnings("MemberName") public String name; + /** Enum values. */ @SuppressWarnings("MemberName") public Map enumValues; + /** Array size. */ @SuppressWarnings("MemberName") public int arraySize = 1; + /** Bit width. */ @SuppressWarnings("MemberName") public int bitWidth; + + /** Default constructor. */ + public ParsedDeclaration() {} } diff --git a/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/ParsedSchema.java b/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/ParsedSchema.java index 2ca175314c..2f7312af9a 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/ParsedSchema.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/ParsedSchema.java @@ -9,6 +9,10 @@ import java.util.List; /** Raw struct schema. */ public class ParsedSchema { + /** Declarations. */ @SuppressWarnings("MemberName") public List declarations = new ArrayList<>(); + + /** Default constructor. */ + public ParsedSchema() {} } diff --git a/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/TokenKind.java b/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/TokenKind.java index 85afa4a3bf..fb74c6f811 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/TokenKind.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/struct/parser/TokenKind.java @@ -6,17 +6,40 @@ package edu.wpi.first.util.struct.parser; /** A lexed raw struct schema token. */ public enum TokenKind { + /** Unknown. */ kUnknown("unknown"), + + /** Integer. */ kInteger("integer"), + + /** Identifier. */ kIdentifier("identifier"), + + /** Left square bracket. */ kLeftBracket("'['"), + + /** Right square bracket. */ kRightBracket("']'"), + + /** Left curly brace. */ kLeftBrace("'{'"), + + /** Right curly brace. */ kRightBrace("'}'"), + + /** Colon. */ kColon("':'"), + + /** Semicolon. */ kSemicolon("';'"), + + /** Comma. */ kComma("','"), + + /** Equals. */ kEquals("'='"), + + /** End of input. */ kEndOfInput(""); private final String m_name; diff --git a/wpiutil/src/main/native/include/wpi/sendable/SendableBuilder.h b/wpiutil/src/main/native/include/wpi/sendable/SendableBuilder.h index 4115420c79..1913d7cc72 100644 --- a/wpiutil/src/main/native/include/wpi/sendable/SendableBuilder.h +++ b/wpiutil/src/main/native/include/wpi/sendable/SendableBuilder.h @@ -15,12 +15,20 @@ namespace wpi { +/** + * Helper class for building Sendable dashboard representations. + */ class SendableBuilder { public: /** * The backend kinds used for the sendable builder. */ - enum BackendKind { kUnknown, kNetworkTables }; + enum BackendKind { + /// Unknown. + kUnknown, + /// NetworkTables. + kNetworkTables + }; virtual ~SendableBuilder() = default; diff --git a/wpiutil/src/main/native/include/wpi/struct/DynamicStruct.h b/wpiutil/src/main/native/include/wpi/struct/DynamicStruct.h index b88894c09d..4254090110 100644 --- a/wpiutil/src/main/native/include/wpi/struct/DynamicStruct.h +++ b/wpiutil/src/main/native/include/wpi/struct/DynamicStruct.h @@ -32,18 +32,31 @@ class StructDescriptorDatabase; * Known data types for raw struct dynamic fields (see StructFieldDescriptor). */ enum class StructFieldType { + /// bool. kBool, + /// char. kChar, + /// int8. kInt8, + /// int16. kInt16, + /// int32. kInt32, + /// int64. kInt64, + /// uint8. kUint8, + /// uint16. kUint16, + /// uint32. kUint32, + /// uint64. kUint64, + /// float. kFloat, + /// double. kDouble, + /// struct. kStruct }; diff --git a/wpiutil/src/main/native/include/wpi/struct/SchemaParser.h b/wpiutil/src/main/native/include/wpi/struct/SchemaParser.h index a8cf1a403f..4e5a1df457 100644 --- a/wpiutil/src/main/native/include/wpi/struct/SchemaParser.h +++ b/wpiutil/src/main/native/include/wpi/struct/SchemaParser.h @@ -17,18 +17,31 @@ namespace wpi::structparser { * A lexed raw struct schema token. */ struct Token { + /** A lexed raw struct schema token kind. */ enum Kind { + /// Unknown. kUnknown, + /// Integer. kInteger, + /// Identifier. kIdentifier, + /// Left square bracket. kLeftBracket, + /// Right square bracket. kRightBracket, + /// Left curly brace. kLeftBrace, + /// Right curly brace. kRightBrace, + /// Colon. kColon, + /// Semicolon. kSemicolon, + /// Comma. kComma, + /// Equals. kEquals, + /// End of input. kEndOfInput, };