Subsystem Groups
NextFTC offers a SubsystemGroup class, which allows you to group multiple subsystems together for easier management and control. This is particularly useful for complex robots with many subsystems, as it enables you to treat them as a single unit.
This can be used in multiple ways. Some examples include a double-jointed arm mechanism, or a swerve drive train with multiple modules that can be controlled independently. This example also illustrates using a SubsystemGroup to represent your robot as a whole, allowing for more streamlined control and coordination between subsystems.
Just like regular subsystems, subsystem groups have an initialize and periodic function; in addition, the initialize function of each subsystem in the group will be called when the group is initialized, and the periodic function of each subsystem will be called every loop.
Creating a Subsystem Group
To create a SubsystemGroup, you must create a subclass of SubsystemGroup, and provide the necessary subsystem instances to its constructor.
object MySubsystemGroup() : SubsystemGroup(
MyFirstSubsystem,
MySecondSubsystem
)Using a Subsystem Group
To register a subsystem group, you can simply pass its instance to the SubsystemComponent constructor in a NextFtcOpMode the way you would with a regular subsystem:
init {
addComponents(
SubsystemComponent(MySubsystemGroup)
)
}