Package xbot.common.subsystems.simple
Class SimpleMotorSubsystem
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
xbot.common.command.BaseSubsystem
xbot.common.subsystems.simple.SimpleMotorSubsystem
- All Implemented Interfaces:
Sendable
,Subsystem
,DataFrameRefreshable
,IPropertySupport
Generic subsystem that handles a single motor which can be driven in forward and reverse.
-
Field Summary
Fields inherited from class xbot.common.command.BaseSubsystem
aKitLog, dataFrameRefreshables, log
-
Constructor Summary
ConstructorDescriptionSimpleMotorSubsystem
(String name, PropertyFactory pf) Create an instance with default power settings.SimpleMotorSubsystem
(String name, PropertyFactory pf, double defaultForwardPower, double defaultReversePower) Create an instance with the specified default forward and reverse power. -
Method Summary
Modifier and TypeMethodDescriptionfinal Command
Gets a command to drive the motor in the forward direction.final Command
Gets a command to drive the motor in the reverse direction.final Command
Gets a command to stop the motor.final void
Drive the motor in the forward direction.abstract void
setPower
(double power) Sets the motor output power.final void
Drive the motor in the reverse direction.final void
stop()
Stop the motor.Methods inherited from class xbot.common.command.BaseSubsystem
getPrefix, periodic, refreshDataFrame, registerDataFrameRefreshable
Methods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase
addChild, getName, getSubsystem, initSendable, setName, setSubsystem
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Constructor Details
-
SimpleMotorSubsystem
public SimpleMotorSubsystem(String name, PropertyFactory pf, double defaultForwardPower, double defaultReversePower) Create an instance with the specified default forward and reverse power.- Parameters:
name
- The name of the subsystempf
- The property 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 subsystempf
- The property 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
Gets a command to drive the motor in the forward direction.- Returns:
- The command.
-
getReverseCommand
Gets a command to drive the motor in the reverse direction.- Returns:
- The command.
-
getStopCommand
Gets a command to stop the motor.- Returns:
- The command.
-