Class SimpleMotorSubsystem
java.lang.Object
org.wpilib.command2.SubsystemBase
xbot.common.command.BaseSubsystem
xbot.common.subsystems.simple.SimpleMotorSubsystem
- All Implemented Interfaces:
org.wpilib.command2.Subsystem, org.wpilib.telemetry.TelemetryLoggable, TunablePrefixProvider
Generic subsystem that handles a single motor which can be driven in forward and reverse.
-
Field Summary
Fields inherited from class BaseSubsystem
aKitLog, log -
Constructor Summary
ConstructorsConstructorDescriptionSimpleMotorSubsystem(String name, TunableFactory tunableFactory) Create an instance with default power settings.SimpleMotorSubsystem(String name, TunableFactory tunableFactory, double defaultForwardPower, double defaultReversePower) Create an instance with the specified default forward and reverse power. -
Method Summary
Modifier and TypeMethodDescriptionfinal org.wpilib.command2.CommandGets a command to drive the motor in the forward direction.final org.wpilib.command2.CommandGets a command to drive the motor in the reverse direction.final org.wpilib.command2.CommandGets a command to stop the motor.final voidDrive the motor in the forward direction.abstract voidsetPower(double power) Sets the motor output power.final voidDrive the motor in the reverse direction.final voidstop()Stop the motor.Methods inherited from class BaseSubsystem
getPrefix, periodicMethods inherited from class org.wpilib.command2.SubsystemBase
getName, getTelemetryType, logTo, setNameMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.wpilib.command2.Subsystem
defer, getCurrentCommand, getDefaultCommand, idle, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Constructor Details
-
SimpleMotorSubsystem
public SimpleMotorSubsystem(String name, TunableFactory tunableFactory, double defaultForwardPower, double defaultReversePower) Create an instance with the specified default forward and reverse power.- Parameters:
name- The name of the subsystemtunableFactory- The tunable factorydefaultForwardPower- The default power to use in the forward directiondefaultReversePower- The default power to use in the reverse direction
-
SimpleMotorSubsystem
Create an instance with default power settings.- Parameters:
name- The name of the subsystemtunableFactory- The tunable factory
-
-
Method Details
-
setPower
public abstract void setPower(double power) Sets the motor output power.- Parameters:
power- The output power, from -1.0 to 1.0
-
setForward
public final void setForward()Drive the motor in the forward direction. -
setReverse
public final void setReverse()Drive the motor in the reverse direction. -
stop
public final void stop()Stop the motor. -
getForwardCommand
public final org.wpilib.command2.Command getForwardCommand()Gets a command to drive the motor in the forward direction.- Returns:
- The command.
-
getReverseCommand
public final org.wpilib.command2.Command getReverseCommand()Gets a command to drive the motor in the reverse direction.- Returns:
- The command.
-
getStopCommand
public final org.wpilib.command2.Command getStopCommand()Gets a command to stop the motor.- Returns:
- The command.
-