Class MotorSubsystem

java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
robot.subsystems.MotorSubsystem
All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable, edu.wpi.first.wpilibj2.command.Subsystem
Direct Known Subclasses:
ClimberSubsystem, IndexerSubsystem, IntakeSubsystem, ShooterSubsystem

public class MotorSubsystem extends edu.wpi.first.wpilibj2.command.SubsystemBase
  • Field Details

    • motors

      public final SmartMotorController[] motors
    • forwardVoltage

      public final double forwardVoltage
    • backwardVoltage

      public final double backwardVoltage
  • Constructor Details

    • MotorSubsystem

      public MotorSubsystem(SmartMotorController motor, double voltage)
      Control multiple motors with one subsystem. This constructor only controls one motor.
      Parameters:
      motor - the motor that the subsystem controls
      voltage - voltage when motors are running
    • MotorSubsystem

      public MotorSubsystem(SmartMotorController motor, double forwardVoltage, double backwardVoltage)
      Control multiple motors with one subsystem. This constructor only controls one motor.
      Parameters:
      motor - the motor that the subsystem controls
      forwardVoltage - voltage when the motor is running forwards
      backwardVoltage - voltage when the motor is running backwards - should be POSITIVE (is negated later)
    • MotorSubsystem

      public MotorSubsystem(SmartMotorController[] motors, double voltage)
      Control multiple motors with one subsystem. For example, to have two motors, use:
      
           new MotorSubsystem(
               new SmartMotorController[] { motor1, motor2 },
               voltage
           )
       
      Parameters:
      motors - the motors that the subsystem controls
      voltage - voltage when motors are running
    • MotorSubsystem

      public MotorSubsystem(SmartMotorController[] motors, double forwardVoltage, double backwardVoltage)
      Control multiple motors with one subsystem. For example, to have two motors, use:
      
           new MotorSubsystem(
               new SmartMotorController[] { motor1, motor2 },
               forwardVoltage,
               backwardVoltage
           )
       
      Parameters:
      motors - the motors that the subsystem controls
      forwardVoltage - voltage when motors are running forwards
      backwardVoltage - voltage when motors are running backwards - should be POSITIVE (is negated later)
  • Method Details

    • setVoltage

      public void setVoltage(double voltage)
    • stop

      public void stop()
    • setMotorBrake

      public void setMotorBrake(boolean brake)
    • c_controlVoltage

      public edu.wpi.first.wpilibj2.command.Command c_controlVoltage(DoubleSupplier getVoltage, boolean stopOnEnd)
    • c_holdVoltage

      public edu.wpi.first.wpilibj2.command.Command c_holdVoltage(double voltage, boolean stopOnEnd)
    • c_forward

      public edu.wpi.first.wpilibj2.command.Command c_forward(boolean stopOnEnd)
    • c_backward

      public edu.wpi.first.wpilibj2.command.Command c_backward(boolean stopOnEnd)
    • c_stop

      public edu.wpi.first.wpilibj2.command.Command c_stop()
    • c_DEBUG_tunePIDkG

      public edu.wpi.first.wpilibj2.command.Command c_DEBUG_tunePIDkG(DoubleSupplier getVoltage)
      Temporary command for tuning kG PID constant. For example:
      
       joystick.button7.whileTrue(
           Component.arm.c_DEBUG_tunePIDkG(() -> joystick.getAxis(Axis.SLIDER))
       );
       
      Run this command and move the slider until the mechanism is receiving just enough voltage to counter gravity but not enough to move upwards. For ArmFeedforward, the arm should be at the horizontal angle (if not, kG should be set to FINAL_VOLTAGE / Math.cos(radiansFromHorizontal)).