Interface MotorRegulator

  • All Known Implementing Classes:
    JavaMotorRegulator

    public interface MotorRegulator
    Interface for motor regulation regulate velocity; also stop motor at desired rotation angle.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int NO_LIMIT  
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addListener​(RegulatedMotor motor, RegulatedMotorListener listener)
      Add a motor listener.
      void adjustAcceleration​(int newAcc)
      The target acceleration has been changed.
      void adjustSpeed​(float newSpeed)
      The target speed has been changed.
      void endSynchronization​(boolean b)
      Complete a set of synchronized motor operations.
      float getCurrentVelocity()
      Return the current velocity (in degrees/second) that the motor is currently running at.
      int getLimitAngle()
      Return the angle that this Motor is rotating to.
      float getPosition()
      return the regulations models current position.
      int getTachoCount()
      Get the current hardware tachometer reading for the motor,
      boolean isMoving()
      Return true if the motor is currently active
      boolean isStalled()
      Return true if the motor is currently stalled.
      void newMove​(float speed, int acceleration, int limit, boolean hold, boolean waitComplete)
      Initiate a new move and optionally wait for it to complete.
      RegulatedMotorListener removeListener()  
      void resetTachoCount()
      Reset the tachometer base value, after this call the tachometer will return zero for the current position.
      void setControlParamaters​(int typ, float moveP, float moveI, float moveD, float holdP, float holdI, float holdD, int offset)
      Set the motion control parameters used by the regulator.
      void setStallThreshold​(int error, int time)
      Set the stall detection parameters.
      void startSynchronization()
      Begin a set of synchronized motor operations
      void synchronizeWith​(MotorRegulator[] rl)
      Specify a set of motors that should be kept in synchronization with this one.
      void waitComplete()
      Wait until the current movement operation is complete (this can include the motor stalling).
    • Method Detail

      • setControlParamaters

        void setControlParamaters​(int typ,
                                  float moveP,
                                  float moveI,
                                  float moveD,
                                  float holdP,
                                  float holdI,
                                  float holdD,
                                  int offset)
        Set the motion control parameters used by the regulator.
        Parameters:
        typ - The type of motor
        moveP - The Proportional control value used while moving
        moveI - The integral control parameter used while moving
        moveD - The differential control parameter used while moving
        holdP - The Proportional control value used while holding position
        holdI - The integral control value used while holding position
        holdD - The differential control value used while holding position
        offset - Motor PWM offset value range 0-10000.
      • getTachoCount

        int getTachoCount()
        Get the current hardware tachometer reading for the motor,
        Returns:
        hardware reading
      • resetTachoCount

        void resetTachoCount()
        Reset the tachometer base value, after this call the tachometer will return zero for the current position. Note that any in progress movements will be aborted.
      • isMoving

        boolean isMoving()
        Return true if the motor is currently active
        Returns:
        True if the motor is moving.
      • getCurrentVelocity

        float getCurrentVelocity()
        Return the current velocity (in degrees/second) that the motor is currently running at. Note that this value may be supplied from the internal control model not from actually measuring the rotation speed. If the regulator is functioning correctly this will closely match the actual velocity
        Returns:
        velocity
      • setStallThreshold

        void setStallThreshold​(int error,
                               int time)
        Set the stall detection parameters. The motor will be declared as stalled if the error in the motor position exceeds the specified value for longer than the given time.
        Parameters:
        error -
        time -
      • getPosition

        float getPosition()
        return the regulations models current position.
        Returns:
        the models current position
      • newMove

        void newMove​(float speed,
                     int acceleration,
                     int limit,
                     boolean hold,
                     boolean waitComplete)
        Initiate a new move and optionally wait for it to complete. If some other move is currently executing then ensure that this move is terminated correctly and then start the new move operation.
        Parameters:
        speed -
        acceleration -
        limit -
        hold -
        waitComplete -
      • adjustSpeed

        void adjustSpeed​(float newSpeed)
        The target speed has been changed. Reflect this change in the regulator.
        Parameters:
        newSpeed - new target speed.
      • adjustAcceleration

        void adjustAcceleration​(int newAcc)
        The target acceleration has been changed. Updated the regulator.
        Parameters:
        newAcc -
      • waitComplete

        void waitComplete()
        Wait until the current movement operation is complete (this can include the motor stalling).
      • addListener

        void addListener​(RegulatedMotor motor,
                         RegulatedMotorListener listener)
        Add a motor listener. Move operations will be reported to this object.
        Parameters:
        motor -
        listener -
      • getLimitAngle

        int getLimitAngle()
        Return the angle that this Motor is rotating to.
        Returns:
        angle in degrees
      • isStalled

        boolean isStalled()
        Return true if the motor is currently stalled.
        Returns:
        true if the motor is stalled, else false
      • startSynchronization

        void startSynchronization()
        Begin a set of synchronized motor operations
      • endSynchronization

        void endSynchronization​(boolean b)
        Complete a set of synchronized motor operations.
      • synchronizeWith

        void synchronizeWith​(MotorRegulator[] rl)
        Specify a set of motors that should be kept in synchronization with this one. The synchronization mechanism simply ensures that operations between a startSynchronization call and an endSynchronization call will all be executed at the same time (when the endSynchronization method is called). This is all that is needed to ensure that motors will operate in a synchronized fashion. The start/end methods can also be used to ensure that reads of the motor state will also be consistent.
        Parameters:
        rl - an array of motors to synchronize with.