Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
remove some APIs from Encoder, MotorController (#19)
Browse files Browse the repository at this point in the history
* delete some methods from EncoderReader

* remove less used ControlModes in MotorController

* remove EncoderReader.get()

* responding to PR comments
  • Loading branch information
dejabot authored Feb 1, 2024
1 parent 1ae2b81 commit 38bedf9
Show file tree
Hide file tree
Showing 10 changed files with 974 additions and 1,108 deletions.
99 changes: 37 additions & 62 deletions src/main/java/com/team766/hal/EncoderReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,41 @@

public interface EncoderReader extends ControlInputReader {

/**
* Gets the current count. Returns the current count on the Encoder. This
* method compensates for the decoding type.
*
* @return Current count from the Encoder adjusted for the 1x, 2x, or 4x
* scale factor.
*/
int get();

/**
* Reset the Encoder distance to zero. Resets the current count to zero on the encoder.
*/
void reset();

/**
* Determine if the encoder is stopped. Using the MaxPeriod value, a boolean is returned that is
* true if the encoder is considered stopped and false if it is still moving. A stopped encoder
* is one where the most recent pulse width exceeds the MaxPeriod.
*
* @return True if the encoder is considered stopped.
*/
boolean getStopped();

/**
* The last direction the encoder value changed.
*
* @return The last direction the encoder value changed.
*/
boolean getDirection();

/**
* Get the distance the robot has driven since the last reset.
*
* @return The distance driven since the last reset as scaled by the value from
* setDistancePerPulse().
*/
double getDistance();

/**
* Get the current rate of the encoder. Units are distance per second as scaled by the value
* from setDistancePerPulse().
*
* @return The current rate of the encoder.
*/
double getRate();

/**
* Set the distance per pulse for this encoder. This sets the multiplier used to determine the
* distance driven based on the count value from the encoder. Do not include the decoding type
* in this scale. The library already compensates for the decoding type. Set this value based on
* the encoder's rated Pulses per Revolution and factor in gearing reductions following the
* encoder shaft. This distance can be in any units you like, linear or angular.
*
* @param distancePerPulse The scale factor that will be used to convert pulses to useful units.
*/
void setDistancePerPulse(double distancePerPulse);

// Implementation for ControlInputReader interface
@Override
default double getPosition() {
return getDistance();
}
/**
* Reset the Encoder distance to zero. Resets the current count to zero on the encoder.
*/
void reset();

/**
* Get the distance the robot has driven since the last reset.
*
* @return The distance driven since the last reset as scaled by the value from
* setDistancePerPulse().
*/
double getDistance();

/**
* Get the current rate of the encoder. Units are distance per second as scaled by the value
* from setDistancePerPulse().
*
* @return The current rate of the encoder.
*/
double getRate();

/**
* Set the distance per pulse for this encoder. This sets the multiplier used to determine the
* distance driven based on the count value from the encoder. Do not include the decoding type
* in this scale. The library already compensates for the decoding type. Set this value based on
* the encoder's rated Pulses per Revolution and factor in gearing reductions following the
* encoder shaft. This distance can be in any units you like, linear or angular.
*
* @param distancePerPulse The scale factor that will be used to convert pulses to useful units.
*/
void setDistancePerPulse(double distancePerPulse);

// Implementation for ControlInputReader interface
@Override
default double getPosition() {
return getDistance();
}
}
Loading

0 comments on commit 38bedf9

Please sign in to comment.