Class SpeedControllerGroup
- java.lang.Object
-
- ca.team3161.lib.robot.motion.drivetrains.SpeedControllerGroup
-
- All Implemented Interfaces:
ComposedComponent<edu.wpi.first.wpilibj.SpeedController>,edu.wpi.first.wpilibj.SpeedController
public final class SpeedControllerGroup extends java.lang.Object implements edu.wpi.first.wpilibj.SpeedController, ComposedComponent<edu.wpi.first.wpilibj.SpeedController>
Implements a container for SpeedControllers.
-
-
Constructor Summary
Constructors Constructor Description SpeedControllerGroup(edu.wpi.first.wpilibj.SpeedController... controllers)Create a new SpeedControllerGroup instance.SpeedControllerGroup(java.util.Collection<edu.wpi.first.wpilibj.SpeedController> controllers)Create a new SpeedControllerGroup instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisable()Disable each SpeedController in the collection.doubleget()The current speed of this SpeedControllerGroup.java.util.List<java.lang.Double>getAll()The speeds of all SpeedControllers within this SpeedControllerGroup.java.util.Collection<edu.wpi.first.wpilibj.SpeedController>getComposedComponents()Return the list of SpeedControllers which this SpeedControllerGroup was constructed with.booleangetInverted()voidset(double pwm)Set the pwm value (-1.0 to 1.0).SpeedControllerGroupsetInversion(boolean inversion)Same assetInverted(boolean), but returns "this" rather than void.voidsetInverted(boolean inverted)Invert all PWM values for this SpeedControllerGroup.voidstopMotor()
-
-
-
Constructor Detail
-
SpeedControllerGroup
public SpeedControllerGroup(edu.wpi.first.wpilibj.SpeedController... controllers)
Create a new SpeedControllerGroup instance.- Parameters:
controllers- a varargs list or array of SpeedController objects. May be all the same type, or may be mixed.
-
SpeedControllerGroup
public SpeedControllerGroup(java.util.Collection<edu.wpi.first.wpilibj.SpeedController> controllers)
Create a new SpeedControllerGroup instance.- Parameters:
controllers- a collection of SpeedControllers for this SpeedControllerGroup to manage
-
-
Method Detail
-
setInverted
public void setInverted(boolean inverted)
Invert all PWM values for this SpeedControllerGroup.- Specified by:
setInvertedin interfaceedu.wpi.first.wpilibj.SpeedController- Parameters:
inverted- whether the PWM values should be inverted or not
-
setInversion
public SpeedControllerGroup setInversion(boolean inversion)
Same assetInverted(boolean), but returns "this" rather than void.- Parameters:
inversion- whether the PWM values should be inverted or not- Returns:
- this
-
get
public double get()
The current speed of this SpeedControllerGroup.- Specified by:
getin interfaceedu.wpi.first.wpilibj.SpeedController- Returns:
- the current PWM value of the SpeedController collection (-1.0 to 1.0)
-
getComposedComponents
public java.util.Collection<edu.wpi.first.wpilibj.SpeedController> getComposedComponents()
Return the list of SpeedControllers which this SpeedControllerGroup was constructed with.- Specified by:
getComposedComponentsin interfaceComposedComponent<edu.wpi.first.wpilibj.SpeedController>- Returns:
- the SpeedControllers.
-
getAll
public java.util.List<java.lang.Double> getAll()
The speeds of all SpeedControllers within this SpeedControllerGroup. They should all be nearly identical, other than error due to floating point precision.- Returns:
- a list enumerating all the current PWM values of the SpeedController collection (-1.0 to 1.0)
-
set
public void set(double pwm)
Set the pwm value (-1.0 to 1.0).- Specified by:
setin interfaceedu.wpi.first.wpilibj.SpeedController- Parameters:
pwm- the PWM value to assign to each SpeedController in the collection
-
disable
public void disable()
Disable each SpeedController in the collection.- Specified by:
disablein interfaceedu.wpi.first.wpilibj.SpeedController
-
getInverted
public boolean getInverted()
- Specified by:
getInvertedin interfaceedu.wpi.first.wpilibj.SpeedController
-
stopMotor
public void stopMotor()
- Specified by:
stopMotorin interfaceedu.wpi.first.wpilibj.SpeedController
-
-