Package frc.team670.pi.sensors
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 rotateddouble
getRotations()
Calculates and returns the number of rotations the wheel has gone throughint
getTicks()
Returns number of ticks the encoder has gone throughvoid
update()
Runs the encoder counting in another thread
-
Field Details
-
count
public int count
-
-
Constructor Details
-
Encoder
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 encoderrightP
- 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
-