Class EncoderBase

    • Constructor Summary

      Constructors 
      Constructor Description
      EncoderBase()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void fullReset()
      Reset the encoder "0" position
      double getAverageSpeed()  
      double getMeters​(int tpr, double wheel_circumference)
      Get sensor distance traveled in meters
      double getMetersPerCycle​(int tpr, double wheel_circumference)
      Get sensor distance traveled in meters since last cycle
      int getRawTicks()
      Get the raw sensor reading from encoder
      protected abstract int getSensorReading()  
      int getSpeed()
      Get the speed of the encoder in Ticks per cycle (usually 20ms)
      int getTicks()
      Get sensor reading accounting for offsets
      void initSimulationDevice​(edu.wpi.first.wpilibj.SpeedController controller, int tpr, double gearbox_ratio, double max_rpm, double ramp_time)  
      void update()
      Method to be called periodically.
      void zero()
      Set the current encoder position as "0"
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EncoderBase

        public EncoderBase()
    • Method Detail

      • initSimulationDevice

        public void initSimulationDevice​(edu.wpi.first.wpilibj.SpeedController controller,
                                         int tpr,
                                         double gearbox_ratio,
                                         double max_rpm,
                                         double ramp_time)
      • getSensorReading

        protected abstract int getSensorReading()
      • getRawTicks

        public int getRawTicks()
        Get the raw sensor reading from encoder
        Returns:
        Raw sensor reading
      • getTicks

        public int getTicks()
        Get sensor reading accounting for offsets
        Returns:
        Sensor reading
      • getMeters

        public double getMeters​(int tpr,
                                double wheel_circumference)
        Get sensor distance traveled in meters
        Parameters:
        tpr - Encoder ticks per revolution
        wheel_circumference - Circumference of wheel (or gear) attached to encoder
        Returns:
        Meters traveled
      • getMetersPerCycle

        public double getMetersPerCycle​(int tpr,
                                        double wheel_circumference)
        Get sensor distance traveled in meters since last cycle
        Parameters:
        tpr - Encoder ticks per revolution
        wheel_circumference - Circumference of wheel (or gear) attached to encoder
        Returns:
        Meters traveled in last cycle
      • zero

        public void zero()
        Set the current encoder position as "0"
      • fullReset

        public void fullReset()
        Reset the encoder "0" position
      • getSpeed

        public int getSpeed()
        Get the speed of the encoder in Ticks per cycle (usually 20ms)
        Returns:
        Rotation speed
      • getAverageSpeed

        public double getAverageSpeed()
      • update

        public void update()
        Description copied from interface: PeriodicComponent
        Method to be called periodically. Usually in the main robot loop (once per 20ms)
        Specified by:
        update in interface PeriodicComponent