Class CompositeMotor
Motor interface.
Use this when two or more motors are mechanically coupled on the same mechanism (e.g., dual-motor shooter flywheels). One motor is designated the primary; its encoder feedback is used for position, velocity, and telemetry reporting. All other motors are followers that receive identical voltage and speed commands but can have independent configurations (inversion, current limits, gear ratio) defined in their own motor config.
This class lives in devices/motor/ so any subsystem that needs paired motors can reuse it. Because the adapter implements Motor,
the subsystem hierarchy (AbstractMotorSubsystem, AbstractVelocitySubsystem) remains completely unaware of multi-motor wiring.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface frc.robot.devices.motor.MotorIO
MotorIO.MotorIOInputs -
Constructor Summary
ConstructorsConstructorDescriptionCompositeMotor(Motor primary, Motor... followers) Creates a composite motor from a primary motor and one or more followers. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the primary motor's measured position in radians.doubleReturns the primary motor's measured velocity in radians per second.edu.wpi.first.units.measure.VoltageReturns the voltage applied to the primary motor.voidsetEncoderPosition(double positionRadians) Overwrites the encoder position on the primary motor and all followers.voidsetVoltage(edu.wpi.first.units.measure.Voltage voltage) Sends a voltage command to the primary motor and all followers.voidstop()Stops the primary motor and all followers immediately.voidupdateInputs(MotorIO.MotorIOInputs inputs) Updates telemetry inputs from the primary motor's encoder and sensors.
-
Constructor Details
-
CompositeMotor
Creates a composite motor from a primary motor and one or more followers.Each motor instance should already be fully configured (CAN ID, inversion, current limits, etc.) before being passed here. The composite does not alter any motor configuration; it only forwards commands.
- Parameters:
primary- motor whose encoder is authoritative for position and velocity readingsfollowers- additional motors that mirror the primary's voltage and speed commands
-
-
Method Details
-
setVoltage
public void setVoltage(edu.wpi.first.units.measure.Voltage voltage) Sends a voltage command to the primary motor and all followers.- Specified by:
setVoltagein interfaceMotor- Parameters:
voltage- desired output voltage
-
getPositionRadians
public double getPositionRadians()Returns the primary motor's measured position in radians.- Specified by:
getPositionRadiansin interfaceMotor- Returns:
- mechanism position from the primary encoder
-
getVelocityRadiansPerSecond
public double getVelocityRadiansPerSecond()Returns the primary motor's measured velocity in radians per second.- Specified by:
getVelocityRadiansPerSecondin interfaceMotor- Returns:
- mechanism velocity from the primary encoder
-
setEncoderPosition
public void setEncoderPosition(double positionRadians) Overwrites the encoder position on the primary motor and all followers.- Specified by:
setEncoderPositionin interfaceMotor- Parameters:
positionRadians- new encoder position in mechanism radians
-
getVoltage
public edu.wpi.first.units.measure.Voltage getVoltage()Returns the voltage applied to the primary motor.- Specified by:
getVoltagein interfaceMotor- Returns:
- primary motor's applied voltage
-
stop
public void stop()Stops the primary motor and all followers immediately. -
updateInputs
Updates telemetry inputs from the primary motor's encoder and sensors.Only the primary motor's readings are captured because both motors are mechanically coupled and share the same mechanism state. Follower health (current draw, temperature) can be monitored separately if needed by accessing follower motors directly.
- Specified by:
updateInputsin interfaceMotorIO- Parameters:
inputs- mutable inputs container to fill for logging
-