Package com.team2813.lib2813.subsystems
Class MotorSubsystem.MotorSubsystemConfiguration
java.lang.Object
com.team2813.lib2813.subsystems.MotorSubsystem.MotorSubsystemConfiguration
- Enclosing class:
MotorSubsystem<T extends Supplier<Angle>>
A configuration for a MotorSubsystem
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe default acceptable position error.static final doubleThe default starting position if one is not provided. -
Constructor Summary
ConstructorsConstructorDescriptionMotorSubsystemConfiguration(Motor motor, Encoder encoder) Creates a new configuration for a MotorSubsystems.Creates a new config for MotorSubsystems using a motor that has a built-in encoder. -
Method Summary
Modifier and TypeMethodDescriptionacceptableError(double error) Sets the acceptable position error.controller(PIDController controller) Sets the controller used to calculate the next valuecontrolMode(ControlMode controlMode) Sets the control mode to use when giving output to the motor.PID(double p, double i, double d) Sets the PID constants for the controllerpublishTo(NetworkTableInstance ntInstance) Enables publishing of data to the provided network table instance.rotationUnit(AngleUnit rotationUnit) Sets the unit to use for PID calculationsstartingPosition(Angle startingPosition) Sets the initial setpoint of the controllerstartingPosition(Supplier<Angle> startingPositionSupplier) Sets the initial setpoint of the controller from the current value of a supplier.
-
Field Details
-
DEFAULT_ERROR
public static final double DEFAULT_ERRORThe default acceptable position error.- See Also:
-
DEFAULT_STARTING_POSITION
public static final double DEFAULT_STARTING_POSITIONThe default starting position if one is not provided.- See Also:
-
-
Constructor Details
-
MotorSubsystemConfiguration
Creates a new configuration for a MotorSubsystems. The default acceptable error is 5.0, the PID constants are set to 0, and the starting position is 0.0- Parameters:
motor- the motor to controlencoder- the encoder providing feedback
-
MotorSubsystemConfiguration
Creates a new config for MotorSubsystems using a motor that has a built-in encoder. The default acceptable error is 5.0, the PID constants are set to 0, and the starting position is 0.0- Parameters:
motor- the integrated motor controller
-
-
Method Details
-
controller
Sets the controller used to calculate the next value- Parameters:
controller- The PID controller- Returns:
thisfor chaining
-
controlMode
Sets the control mode to use when giving output to the motor. Defaults toControlMode.DUTY_CYCLE.- Parameters:
controlMode- The mode to use when controlling the motor- Returns:
thisfor chaining- Throws:
IllegalArgumentException- IfcontrolModeis for positional control
-
PID
Sets the PID constants for the controller- Parameters:
p- the proportionali- the integrald- the derivative- Returns:
thisfor chaining
-
startingPosition
Sets the initial setpoint of the controller- Parameters:
startingPosition- the initial setpoint- Returns:
thisfor chaining
-
startingPosition
public MotorSubsystem.MotorSubsystemConfiguration startingPosition(Supplier<Angle> startingPositionSupplier) Sets the initial setpoint of the controller from the current value of a supplier.This is provided to allow the subclass to define an
Enum(that implementsSupplier<Angle>) which defines the supported positions of this subsystem.- Parameters:
startingPositionSupplier- supplier to use to get the initial setpoint- Returns:
thisfor chaining
-
acceptableError
Sets the acceptable position error.- Parameters:
error- the error which is considered tolerable for use with atPosition()}- Returns:
thisfor chaining- Throws:
IllegalArgumentException- Iferroris negative
-
rotationUnit
Sets the unit to use for PID calculations- Parameters:
rotationUnit- the angle unit to use for calculations- Returns:
thisfor chaining
-
publishTo
Enables publishing of data to the provided network table instance.- Parameters:
ntInstance- the network table instance to publish to- Returns:
thisfor chaining- Since:
- 2.0.0
-