Class Encoder

java.lang.Object
frc.team670.pi.sensors.Encoder

public class Encoder
extends java.lang.Object
Represents an encoder connected to the pi
Author:
ctychen, lakshbhambhani
  • Field Summary

    Fields 
    Modifier and Type Field Description
    int count  
  • Constructor Summary

    Constructors 
    Constructor Description
    Encoder​(int leftP, int rightP, boolean reversed)
    Creates an encoder on 2 pins which can be used to get data from the motor
  • Method Summary

    Modifier and Type Method Description
    double getDistance()
    Calculates and returns the distance for which the motors have rotated
    double getRotations()
    Calculates and returns the number of rotations the wheel has gone through
    int getTicks()
    Returns number of ticks the encoder has gone through
    void update()
    Runs the encoder counting in another thread

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • count

      public int count
  • Constructor Details

    • Encoder

      public Encoder​(int leftP, int rightP, boolean reversed) throws PigpioException
      Creates an encoder on 2 pins which can be used to get data from the motor
      Parameters:
      leftP - Pin for the left sensor on the encoder
      rightP - Pin for the right sensor on the encoder
      Throws:
      PigpioException
  • Method Details

    • update

      public void update()
      Runs the encoder counting in another thread
    • getTicks

      public int getTicks()
      Returns number of ticks the encoder has gone through
      Returns:
      int Ticks - the number of ticks
    • getRotations

      public double getRotations()
      Calculates and returns the number of rotations the wheel has gone through
      Returns:
      Double rotations - the number of rotations the wheel has gone through
    • getDistance

      public double getDistance()
      Calculates and returns the distance for which the motors have rotated
      Returns:
      distance traveled in centimeters