Class Controller

java.lang.Object
com.cdarobotics.cdalib.controllers.Controller
Direct Known Subclasses:
CompoundController, FFController, NullController, PIDController

public abstract class Controller extends Object
Base type for closed-loop and feedforward controllers. A controller drives a measured value toward a target setpoint; each loop update(double, double) is called with the current measurement and elapsed time and returns the control output to apply.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double
    The setpoint this controller is driving the measured value toward.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Controller(double target)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
     
    void
    setTarget(double target)
    Sets the setpoint.
    abstract double
    update(double current, double dt)
    Computes the control output for this loop.

    Methods inherited from class java.lang.Object

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

    • target

      protected double target
      The setpoint this controller is driving the measured value toward.
  • Constructor Details

    • Controller

      public Controller(double target)
      Parameters:
      target - the initial setpoint
  • Method Details

    • update

      public abstract double update(double current, double dt)
      Computes the control output for this loop.
      Parameters:
      current - the current measured value
      dt - the time elapsed since the previous update, in seconds
      Returns:
      the control output to apply
    • getTarget

      public double getTarget()
      Returns:
      the current setpoint.
    • setTarget

      public void setTarget(double target)
      Sets the setpoint.
      Parameters:
      target - the new setpoint