EasyStack Docs

EasyMotorGroup

Esta página ainda não foi traduzida. Mostrando a versão em inglês.

The EasyMotorGroup allows you to control multiple synchronized motors (like a dual-motor arm, an intake, or a basic chassis side) as if they were a single EasyMotor instance.

It requires at least one leader motor, and any number of followers. When you issue a command (like setPower or moveToPosition) to the group, the command is automatically scaled and sent to all of the motors within the group.

Note: By default, position and velocity readings on an EasyMotorGroup will only return the data from the Leader motor.

#Creating an EasyMotorGroup

To create an EasyMotorGroup, initialize your individual EasyMotor instances first, and then pass them to the group constructor. The first motor passed becomes the default leader.

Java
EasyMotor leftSlide = new EasyMotor(hardwareMap, "leftSlide");
EasyMotor rightSlide = new EasyMotor(hardwareMap, "rightSlide").reversed();

// Group them together (leftSlide is the leader)
EasyMotorGroup slides = new EasyMotorGroup(leftSlide, rightSlide);

// Now, one command applies to all motors in the group
slides.setPower(1.0);
slides.moveToPosition(1000.0);

You can optionally change the leader after initialization using setLeaderMotor(int index), where the index corresponds to the order the motors were passed into the constructor.

#Encoder Strategies

If your motors are mechanically linked (e.g., chained together on a chassis), reading just the leader's encoder might be sufficient. However, if they are independent sides of a mechanism (like two sides of an elevator), one side might slip or skip a belt tooth.

You can change how the group interprets its "current position" using setEncoderStrategy():

Java
// Averages the encoder readings from all motors in the group
slides.setEncoderStrategy(EasyMotorGroup.EncoderStrategy.AVERAGE);

// Uses only the maximum reading among the motors
slides.setEncoderStrategy(EasyMotorGroup.EncoderStrategy.MAX);

// Uses only the minimum reading among the motors
slides.setEncoderStrategy(EasyMotorGroup.EncoderStrategy.MIN);

#Cross-Coupling Synchronization

When driving two motors on the same mechanism, one might lag behind due to friction differences or uneven weight distribution. If this happens on an elevator, the mechanism could jam diagonally.

Enabling cross-coupling actively adjusts the power sent to individual motors to keep them perfectly synced based on their individual encoder differences. The system calculates the average position of the group, and penalizes or boosts individual motors that drift away from that average.

Java

Java
// Enables cross-coupling with the default gain (0.5)
slides.crossCoupled();

// Enables cross-coupling with a custom aggressiveness (gain)
slides.crossCoupled(0.8);

(Note: Enabling cross-coupling automatically changes the EncoderStrategy to AVERAGE if it was previously set to LEADER_ONLY).

#Unified Configuration

EasyMotorGroup mirrors almost all the configuration methods of a single EasyMotor. When you call a configuration method on the group, it broadcasts that setting to every motor inside it.

Java
// Sets limits, tolerances, and feedforward for all motors simultaneously
slides.setPositionLimits(0.0, 3500.0)
        .setPositionTolerance(15.0)
        .setStaticFeedforward(0.1)
        .brakeMode();

#Reading Amperage

You can easily get the total electrical current drawn by the entire mechanism by calling getCurrentAmps(). The group sums the current of all individual motors, which is highly useful for detecting if your mechanism is jammed or carrying too much weight.

Java
double totalCurrent = slides.getCurrentAmps();
if (totalCurrent > 8.0) {
    // The combined motors are drawing over 8 Amps, something might be stuck!
}

Última atualização 2026-11-16

EasyStack - FTC Java library

This site records page views of visitors to understand how the documentation is used. Nothing is sold or shared with third parties.