Class SpeedConstraintModule

  • All Implemented Interfaces:
    DriveModule

    public class SpeedConstraintModule
    extends java.lang.Object
    implements DriveModule
    A drivetrain module which will constrain the maximum speed of the robot.
    • Constructor Detail

      • SpeedConstraintModule

        public SpeedConstraintModule​(double maxSpeed,
                                     boolean shouldScaleSpeeds)
        Default constructor
        Parameters:
        maxSpeed - The maximum speed
        shouldScaleSpeeds - True if the speeds should be scaled to the clamped range, or false otherwise
    • Method Detail

      • run

        public DriveSpeed run​(DriveSpeed currentSpeed,
                              DriveSpeed desiredSpeed,
                              double deltaTime)
        Description copied from interface: DriveModule
        Run the drive module
        Specified by:
        run in interface DriveModule
        Parameters:
        currentSpeed - the current speed of the drivetrain
        desiredSpeed - the desired speed of the drivetrain
        deltaTime - the delta time since the last call in seconds
        Returns:
        the speed the drivetrain should set
      • setMaxSpeed

        public void setMaxSpeed​(double maxSpeed)
      • setShouldScaleSpeeds

        public void setShouldScaleSpeeds​(boolean shouldScaleSpeeds)