Class ControllerGroup

java.lang.Object
frc.team_8840_lib.controllers.ControllerGroup

public class ControllerGroup extends Object
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.
  • Constructor Details

    • ControllerGroup

      @Deprecated public ControllerGroup(String name, SCType mainType, int... ports)
      Deprecated.
      Creates a new controller group
      Parameters:
      name - Name of the group
      mainType - Type of the ports
      ports - PWM Ports/CAN IDs of the controllers
  • Method Details

    • getName

      public String getName()
      Name of controller group
      Returns:
      name
    • addPort

      public void addPort(int port, SCType type)
      Adds a new controller to the controller group.
      Parameters:
      port - Port of controller
      type - 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

      public void setSubGroupSpeed(String name, double speed)
      Sets the speed of a subgroup of the group
      Parameters:
      name - Name of subgroup
      speed - Speed of subgroup (-1 to 1)
    • setPortSpeed

      public void setPortSpeed(int port, double speed)
      Sets the speed of a certain port
      Parameters:
      port - SpeedController port
      speed - Speed (-1, 1)
    • getSpeedController

      public ControllerGroup.SpeedController getSpeedController(int port)
      Gets the speed controller object of a port
      Parameters:
      port - port
      Returns:
      SpeedController on port
    • getControllers

      public ControllerGroup.SpeedController[] getControllers()
      Returns a list of the controllers that are part of the group
      Returns:
      list of speed controller objects
    • subgroupSpeeds

      public HashMap<Integer,Double> subgroupSpeeds(String key)
      Returns a list of speeds in subgroup matched up to their ports
      Parameters:
      key - Subgroup name
      Returns:
      HashMap of port and speed
    • externalSet

      public void externalSet(int port, ControllerGroup.SpeedController controller)
      Externally put in the port and speed controller object
      Parameters:
      port - Port of controller
      controller - SpeedController object
    • externalSet

      public void externalSet(int port, ControllerGroup.SpeedController controller, String subGroup)
      Externally put in the controller of a subgroup
      Parameters:
      port - Port of speed controller
      controller - SpeedController object
      subGroup - 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

      public double getAverageSpeed(String group)
      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

      public String[] getSubGroups()
      Gets a list of names of the subgroups.
      Returns:
      Subgroup names
    • createSC

      @Deprecated public static ControllerGroup.SpeedController createSC(int port, SCType type)
      Deprecated.
      Creates a speed controller at port with type
      Parameters:
      port - Port of speed controller
      type - Type of speed controller
      Returns:
      SpeedController
    • stop

      public void stop()
      Stops the controller group by setting the speed to 0.
    • combine

      public static ControllerGroup combine(String name, ControllerGroup... groups)
      Combines two or more groups to make another group
      Parameters:
      name - Name of combination
      groups - Groups to be combined
      Returns:
      Combined controller group.