Package frc.team_8840_lib.controllers
Class ControllerGroup
java.lang.Object
frc.team_8840_lib.controllers.ControllerGroup
This class is a wrapper of a SpeedController class.
Personally, I'm stuck between keeping it and removing
it since it was one of the very first classes that was added to the library,
alongside the GameController class. All `forRemoval` tags were
removed though, but this class will keep the @Deprecated annotation
until this class is updated to be more useful/better than the normal
MotorController classes, such as SparkMax or TalonSRX. This class is
primarly kept for half backwards compatibility, and for our langauge,
Till, due to the ease of use for instantiating a group of controllers
with just an enum instead of having to create a new MotorController.
If you are reading this, I would recommend that you use the default MotorController
and MotorControllerGroup definition. Those are much more useful and
are updated more frequently since this class is not used as much and
therefore isn't as important.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPort(int port) Adds a port with default type of groupvoidAdds a new controller to the controller group.static ControllerGroupcombine(String name, ControllerGroup... groups) Combines two or more groups to make another groupDeprecated.voidexternalSet(int port, ControllerGroup.SpeedController controller) Externally put in the port and speed controller objectvoidexternalSet(int port, ControllerGroup.SpeedController controller, String subGroup) Externally put in the controller of a subgroupdoubleGets the average speed of the controllersdoublegetAverageSpeed(String group) Returns the average speed of a subgroupReturns a list of the controllers that are part of the groupgetName()Name of controller groupdoublegetSpeed(int port) Gets the speed of a specific controller at portgetSpeedController(int port) Gets the speed controller object of a portString[]Gets a list of names of the subgroups.voidinvert()Invert every controller part of group.voidinvert(int... ports) Invert only certain ports of the groupbooleanReturns whether the group has subgroups or notvoidsetPortSpeed(int port, double speed) Sets the speed of a certain portvoidsetSpeed(double speed) Sets the speed of the entire groupvoidsetSubGroupSpeed(String name, double speed) Sets the speed of a subgroup of the groupvoidstop()Stops the controller group by setting the speed to 0.subgroupSpeeds(String key) Returns a list of speeds in subgroup matched up to their ports
-
Constructor Details
-
ControllerGroup
Deprecated.Creates a new controller group- Parameters:
name- Name of the groupmainType- Type of the portsports- PWM Ports/CAN IDs of the controllers
-
-
Method Details
-
getName
Name of controller group- Returns:
- name
-
addPort
Adds a new controller to the controller group.- Parameters:
port- Port of controllertype- Type of controller
-
addPort
public void addPort(int port) Adds a port with default type of group- Parameters:
port-
-
invert
public void invert()Invert every controller part of group. -
invert
public void invert(int... ports) Invert only certain ports of the group- Parameters:
ports- Ports
-
setSpeed
public void setSpeed(double speed) Sets the speed of the entire group- Parameters:
speed- Speed (-1 to 1)
-
setSubGroupSpeed
Sets the speed of a subgroup of the group- Parameters:
name- Name of subgroupspeed- Speed of subgroup (-1 to 1)
-
setPortSpeed
public void setPortSpeed(int port, double speed) Sets the speed of a certain port- Parameters:
port- SpeedController portspeed- Speed (-1, 1)
-
getSpeedController
Gets the speed controller object of a port- Parameters:
port- port- Returns:
- SpeedController on port
-
getControllers
Returns a list of the controllers that are part of the group- Returns:
- list of speed controller objects
-
subgroupSpeeds
Returns a list of speeds in subgroup matched up to their ports- Parameters:
key- Subgroup name- Returns:
- HashMap of port and speed
-
externalSet
Externally put in the port and speed controller object- Parameters:
port- Port of controllercontroller- SpeedController object
-
externalSet
Externally put in the controller of a subgroup- Parameters:
port- Port of speed controllercontroller- SpeedController objectsubGroup- Subgroup key of controller
-
isCombination
public boolean isCombination()Returns whether the group has subgroups or not- Returns:
- has subgroups/is combination of groups?
-
getAverageSpeed
public double getAverageSpeed()Gets the average speed of the controllers- Returns:
- Average speed.
-
getAverageSpeed
Returns the average speed of a subgroup- Parameters:
group- Subgroup name- Returns:
- Average speed of subgroup
-
getSpeed
public double getSpeed(int port) Gets the speed of a specific controller at port- Parameters:
port-- Returns:
- Speed of controller
-
getSubGroups
Gets a list of names of the subgroups.- Returns:
- Subgroup names
-
createSC
Deprecated.Creates a speed controller at port with type- Parameters:
port- Port of speed controllertype- Type of speed controller- Returns:
- SpeedController
-
stop
public void stop()Stops the controller group by setting the speed to 0. -
combine
Combines two or more groups to make another group- Parameters:
name- Name of combinationgroups- Groups to be combined- Returns:
- Combined controller group.
-