Class AngleTracker
public class AngleTracker
extends java.lang.Object
Angle tracking is actually incredibly simple - use the encoder's CPR and the encoder's count to determine how many ticks equals how many degrees.
- Since:
- 0.1.0
- Author:
- Colin Robertson
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AngleTracker(Encoder encoder)
Create a new angle tracker. -
Method Summary
Modifier and Type Method Description double
getAngle()
Get angle.Encoder
getEncoder()
Get the encoder used in the tracker.void
update()
Update the tracker based on the encoder's count.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
encoder
A reference to the encoder that's used in tracking.AngleTracker is a self-sufficient class, meaning that it doesn't need any other parameters fed into it for it to work - it just does its thing. To support this FABULOUS lifestyle, we need to locally store an encoder and get the value from it, rather than outsourcing encoder value reading.
-
cpr
private final double cprThe encoder's CPR.CPR, in the event you were unaware, is counts per rotation. In other words, how many times the encoder has to say "hey!" for the code to register that the encoder has rotated fully once.
-
tpd
private final double tpdTPD = Ticks per Degrees. -
angle
private double angleThe current angle, measured in degrees.This value should always be within the defined range of (0) to (360). It isn't required for some mathematical complexity or anything - it's just a matter of personal preference.
-
-
Constructor Details
-
AngleTracker
Create a new angle tracker.- Parameters:
encoder
- the encoder to be used.
-
-
Method Details
-
update
public void update()Update the tracker based on the encoder's count. -
getAngle
public double getAngle()Get angle.Hit da Nae-Nae? Hell to the yeah.
- Returns:
- angle.
-
getEncoder
Get the encoder used in the tracker.- Returns:
- the tracker's encoder.
-