Package robot.subsystems
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMotorSubsystem(SmartMotorController[] motors, double voltage) Control multiple motors with one subsystem.MotorSubsystem(SmartMotorController[] motors, double forwardVoltage, double backwardVoltage) Control multiple motors with one subsystem.MotorSubsystem(SmartMotorController motor, double voltage) Control multiple motors with one subsystem.MotorSubsystem(SmartMotorController motor, double forwardVoltage, double backwardVoltage) Control multiple motors with one subsystem. -
Method Summary
Modifier and TypeMethodDescriptionedu.wpi.first.wpilibj2.command.Commandc_backward(boolean stopOnEnd) edu.wpi.first.wpilibj2.command.Commandc_controlVoltage(DoubleSupplier getVoltage, boolean stopOnEnd) edu.wpi.first.wpilibj2.command.Commandc_DEBUG_tunePIDkG(DoubleSupplier getVoltage) Temporary command for tuningkGPID constant.edu.wpi.first.wpilibj2.command.Commandc_forward(boolean stopOnEnd) edu.wpi.first.wpilibj2.command.Commandc_holdVoltage(double voltage, boolean stopOnEnd) edu.wpi.first.wpilibj2.command.Commandc_stop()voidsetMotorBrake(boolean brake) voidsetVoltage(double voltage) voidstop()Methods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase
addChild, getName, getSubsystem, initSendable, setName, setSubsystemMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, idle, periodic, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Field Details
-
motors
-
forwardVoltage
public final double forwardVoltage -
backwardVoltage
public final double backwardVoltage
-
-
Constructor Details
-
MotorSubsystem
Control multiple motors with one subsystem. This constructor only controls one motor.- Parameters:
motor- the motor that the subsystem controlsvoltage- voltage when motors are running
-
MotorSubsystem
Control multiple motors with one subsystem. This constructor only controls one motor.- Parameters:
motor- the motor that the subsystem controlsforwardVoltage- voltage when the motor is running forwardsbackwardVoltage- voltage when the motor is running backwards - should be POSITIVE (is negated later)
-
MotorSubsystem
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 controlsvoltage- voltage when motors are running
-
MotorSubsystem
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 controlsforwardVoltage- voltage when motors are running forwardsbackwardVoltage- 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
Temporary command for tuningkGPID constant. For example:
Run this command and move the slider until the mechanism is receiving just enough voltage to counter gravity but not enough to move upwards. Forjoystick.button7.whileTrue( Component.arm.c_DEBUG_tunePIDkG(() -> joystick.getAxis(Axis.SLIDER)) );ArmFeedforward, the arm should be at the horizontal angle (if not,kGshould be set toFINAL_VOLTAGE / Math.cos(radiansFromHorizontal)).
-