From 65d0cb2fc2d4ee04fe928f9121843075e577021d Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Wed, 21 Aug 2024 09:54:07 -0700 Subject: [PATCH] javadocs for custom encoder class --- .../com/autodesk/synthesis/CANEncoder.java | 4 +- .../revrobotics/SparkAbsoluteEncoder.java | 94 ++++++++++++------- 2 files changed, 64 insertions(+), 34 deletions(-) diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANEncoder.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANEncoder.java index d00e5439b..9b7220a1c 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANEncoder.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANEncoder.java @@ -36,7 +36,7 @@ public CANEncoder(String name, int deviceId) { /** * Gets the current position of the encoder, simulated. * - * @return Current Position. + * @return Current position in revolutions. */ public double getPosition() { return m_position.get(); @@ -45,7 +45,7 @@ public double getPosition() { /** * Gets the current velocity of the encoder, simulated. * - * @return Current Velocity. + * @return Current velocity in revolutions per second. */ public double getVelocity() { return m_velocity.get(); diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java index 1923be549..de1d952d6 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java @@ -18,94 +18,124 @@ public SparkAbsoluteEncoder(com.revrobotics.SparkAbsoluteEncoder realEncoder, CA this.simEncoder = simEncoder; } - /* - * Get the average sampling depth for an absolute encoder + /** + * Gets the average sampling depth for the real encoder + * * @return The average sampling depth */ public int getAverageDepth() { return this.realEncoder.getAverageDepth(); } - /* - * Get the phase of the AbsoluteEncoder - * Returns: The phase of the encoder + /** + * Gets the phase of the real encoder + * + * @return The phase of the real encoder */ public boolean getInverted() { return this.realEncoder.getInverted(); } - /* - * Get the position of the motor. This returns the native units of 'rotations' by default, and can be changed by a scale factor using setPositionConversionFactor(). - * Returns: Number of rotations of the motor + /** + * Gets the position lf the simulated motor. + * This returns the native units of 'rotations' by default, and can be changed by a scale factor using setPositionConversionFactor(). + * + * @return Number of rotations of the motor */ public double getPosition() { - return this.simEncoder.getPosition() * this.realEncoder.getPositionConversionFactor(); + return this.simEncoder.getPosition(); } - /* - * Set the conversion factor for position of the encoder. Multiplied by the native output units to give you position - * Returns: The conversion factor for position + /** + * Sets the conversion factor for position of the real encoder. Multiplied by the native output units to give you position + * + * @return The conversion factor used by the encoder for position */ public double getPositionConversionFactor() { - return this.getPositionConversionFactor(); + return this.realEncoder.getPositionConversionFactor(); } - /* - * Get the velocity of the motor. This returns the native units of 'rotations per second' by default, and can be changed by a scale factor using setVelocityConversionFactor(). - * Returns: Number of rotations per second of the motor + /** + * Gets the velocity of the simulated motor. This returns the native units of 'rotations per second' by default, and can be changed by a scale factor using setVelocityConversionFactor(). + * + * @return Number of rotations per second of the motor */ public double getVelocity() { return this.simEncoder.getVelocity() * this.realEncoder.getVelocityConversionFactor(); } - /* - * Get the conversion factor for velocity of the encoder. + /** + * Gets the conversion factor for velocity of the real encoder. + * + * @return The conversion factor used by the encoder for position */ public double getVelocityConversionFactor() { return this.realEncoder.getVelocityConversionFactor(); } - /* - * Gets the zero offset for an absolute encoder (the position that is reported as zero). + /** + * Gets the zero offset in revolutions for the real encoder (the position that is reported as zero). + * + * @return The zero offset */ public double getZeroOffset() { return this.realEncoder.getZeroOffset(); } - /* - * Set the average sampling depth for an absolute encoder. + /** + * Sets the average sampling depth for the real encoder. + * + * @param depth The average sampling depth + * + * @return a library error indicating failure or success */ public REVLibError setAverageDepth(int depth) { return this.realEncoder.setAverageDepth(depth); } - /* - * Set the phase of the AbsoluteEncoder so that it is set to be in phase with the motor itself + /** + * Sets the phase of the real encoder + * + * @param inverted Whether the real motor should be inverted + * + * @return a library error indicating failure or success */ public REVLibError setInverted(boolean inverted) { return this.realEncoder.setInverted(inverted); } - /* - * Set the conversion factor for position of the encoder. + /** + * Sets the conversion factor for position of the real encoder. + * + * @param The new position conversion factor + * + * @return a library error indicating failure or success */ public REVLibError setPositionConversionFactor(double factor) { return this.realEncoder.setPositionConversionFactor(factor); } - /* - * Set the conversion factor for velocity of the encoder. + /** + * Sets the conversion factor for velocity of the real encoder. + * + * @param factor The new velocity conversion factor + * + * @return a library error indicating failure or success */ public REVLibError setVelocityConversionFactor(double factor) { return this.realEncoder.setVelocityConversionFactor(factor); } - /* - * Sets the zero offset of an absolute encoder (the position that is reported as zero). + /** + * Sets the zero offset of the real encoder (the position that is reported as zero). + * + * @param offset The new zero offset + * + * @return a library error indicating failure or success */ - public REVLibError setZeroOffset(double factor) { - return this.realEncoder.setZeroOffset(factor); + public REVLibError setZeroOffset(double offset) { + return this.realEncoder.setZeroOffset(offset); } }