Interface SparkMaxRelativeEncoder

    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      int getAverageDepth()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the velocity calculation process's sampling depth for a quadrature or hall sensor encoder.
      int getCountsPerRevolution()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the counts per revolution of the quadrature encoder.
      boolean getInverted()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the phase of the MotorFeedbackSensor.
      int getMeasurementPeriod()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the position measurement period used to calculate the velocity of a quadrature or hall sensor encoder.
      double getPosition()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the position of the motor.
      double getPositionConversionFactor()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the conversion factor for position of the encoder.
      double getVelocity()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the velocity of the motor.
      double getVelocityConversionFactor()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the conversion factor for velocity of the encoder.
      REVLibError setAverageDepth​(int depth)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the sampling depth of the velocity calculation process for a quadrature or hall sensor encoder.
      REVLibError setInverted​(boolean inverted)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the phase of the MotorFeedbackSensor so that it is set to be in phase with the motor itself.
      REVLibError setMeasurementPeriod​(int period_ms)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the position measurement period used to calculate the velocity of a quadrature or hall sensor encoder.
      REVLibError setPosition​(double position)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the position of the encoder.
      REVLibError setPositionConversionFactor​(double factor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the conversion factor for position of the encoder.
      REVLibError setVelocityConversionFactor​(double factor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the conversion factor for velocity of the encoder.
    • Method Detail

      • getPosition

        double getPosition()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Description copied from interface: RelativeEncoder
        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().
        Specified by:
        getPosition in interface CANEncoder
        Specified by:
        getPosition in interface RelativeEncoder
        Returns:
        Number of rotations of the motor
      • getVelocity

        double getVelocity()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Description copied from interface: RelativeEncoder
        Get the velocity of the motor. This returns the native units of 'RPM' by default, and can be changed by a scale factor using setVelocityConversionFactor().
        Specified by:
        getVelocity in interface CANEncoder
        Specified by:
        getVelocity in interface RelativeEncoder
        Returns:
        Number the RPM of the motor
      • setPosition

        REVLibError setPosition​(double position)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Description copied from interface: RelativeEncoder
        Set the position of the encoder. By default the units are 'rotations' and can be changed by a scale factor using setPositionConversionFactor().
        Specified by:
        setPosition in interface CANEncoder
        Specified by:
        setPosition in interface RelativeEncoder
        Parameters:
        position - Number of rotations of the motor
        Returns:
        REVLibError.kOk if successful
      • getPositionConversionFactor

        double getPositionConversionFactor()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Description copied from interface: RelativeEncoder
        Get the conversion factor for position of the encoder. Multiplied by the native output units to give you position
        Specified by:
        getPositionConversionFactor in interface CANEncoder
        Specified by:
        getPositionConversionFactor in interface RelativeEncoder
        Returns:
        The conversion factor for position
      • getVelocityConversionFactor

        double getVelocityConversionFactor()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Description copied from interface: RelativeEncoder
        Get the conversion factor for velocity of the encoder. Multiplied by the native output units to give you velocity
        Specified by:
        getVelocityConversionFactor in interface CANEncoder
        Specified by:
        getVelocityConversionFactor in interface RelativeEncoder
        Returns:
        The conversion factor for velocity
      • setAverageDepth

        REVLibError setAverageDepth​(int depth)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Description copied from interface: RelativeEncoder
        Set the sampling depth of the velocity calculation process for a quadrature or hall sensor encoder. This value sets the number of samples in the average for velocity readings. For a quadrature encoder, this can be any value from 1 to 64 (default). For a hall sensor, it must be either 1, 2, 4, or 8 (default).
        Specified by:
        setAverageDepth in interface CANEncoder
        Specified by:
        setAverageDepth in interface RelativeEncoder
        Parameters:
        depth - The velocity calculation process's sampling depth
        Returns:
        REVLibError.kOk if successful
      • getAverageDepth

        int getAverageDepth()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Description copied from interface: RelativeEncoder
        Get the velocity calculation process's sampling depth for a quadrature or hall sensor encoder.
        Specified by:
        getAverageDepth in interface CANEncoder
        Specified by:
        getAverageDepth in interface RelativeEncoder
        Returns:
        The velocity calculation averaging process's sampling depth
      • setMeasurementPeriod

        REVLibError setMeasurementPeriod​(int period_ms)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Description copied from interface: RelativeEncoder
        Set the position measurement period used to calculate the velocity of a quadrature or hall sensor encoder. For a quadrature encoder, this number may be between 1 and 100 (default). For a hall sensor, this number may be between 8 and 64. The default for a hall sensor is 32ms.

        The basic formula to calculate velocity is change in position / change in time. This parameter sets the change in time for measurement.

        Specified by:
        setMeasurementPeriod in interface CANEncoder
        Specified by:
        setMeasurementPeriod in interface RelativeEncoder
        Parameters:
        period_ms - Measurement period in milliseconds
        Returns:
        REVLibError.kOk if successful
      • getMeasurementPeriod

        int getMeasurementPeriod()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Description copied from interface: RelativeEncoder
        Get the position measurement period used to calculate the velocity of a quadrature or hall sensor encoder.
        Specified by:
        getMeasurementPeriod in interface CANEncoder
        Specified by:
        getMeasurementPeriod in interface RelativeEncoder
        Returns:
        The measurement period in milliseconds
      • getCountsPerRevolution

        int getCountsPerRevolution()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Description copied from interface: RelativeEncoder
        Get the counts per revolution of the quadrature encoder.

        For a description on the difference between CPR, PPR, etc. go to https://www.cuidevices.com/blog/what-is-encoder-ppr-cpr-and-lpr

        Specified by:
        getCountsPerRevolution in interface CANEncoder
        Specified by:
        getCountsPerRevolution in interface RelativeEncoder
        Returns:
        Counts per revolution
      • setInverted

        REVLibError setInverted​(boolean inverted)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Description copied from interface: MotorFeedbackSensor
        Set the phase of the MotorFeedbackSensor so that it is set to be in phase with the motor itself. This only works for quadrature encoders and analog sensors. This will throw an error if the user tries to set the inversion of the hall sensor.
        Specified by:
        setInverted in interface CANEncoder
        Specified by:
        setInverted in interface CANSensor
        Specified by:
        setInverted in interface MotorFeedbackSensor
        Specified by:
        setInverted in interface RelativeEncoder
        Parameters:
        inverted - The phase of the sensor
        Returns:
        REVLibError.kOk if successful