Skip to content

NextMecanum

NextMecanum is a drop-in replacement for Pedro Pathing’s Mecanum drivetrain that drives the wheels with NextMotors. Use it wherever your Pedro constants create a Mecanum, such as the drivetrain argument of Pedro’s Follower constructor.

There are three ways to construct a NextMecanum.

NextMecanumConfig replaces Pedro’s MecanumConfig. Each corner is configured with a Lynx module and port instead of a configuration name, so motors split across the Control Hub and an Expansion Hub need no special handling.

val driveConfig = NextMecanumConfig {
it.frontLeftModule.set(RobotController.controlHub)
it.frontLeftPort.set(0)
it.frontLeftDirection.set(DcMotorSimple.Direction.REVERSE)
it.frontRightModule.set(RobotController.controlHub)
it.frontRightPort.set(1)
it.frontRightDirection.set(DcMotorSimple.Direction.FORWARD)
it.backLeftModule.set(RobotController.expansionHub)
it.backLeftPort.set(0)
it.backLeftDirection.set(DcMotorSimple.Direction.REVERSE)
it.backRightModule.set(RobotController.expansionHub)
it.backRightPort.set(1)
it.backRightDirection.set(DcMotorSimple.Direction.FORWARD)
}
val drivetrain = NextMecanum(hardwareMap, driveConfig)

The module, port, and direction of every corner are required. Two more options have defaults:

Option Type Default Description
manualBrakeMode Boolean true Whether the motors brake at zero power while driving manually.
powerThreshold Double 0.01 Smallest power change that triggers a hardware write.

If you already have a Pedro MecanumConfig, pass it instead. NextMecanum looks up the motors by their configuration names, so the config works as is:

val drivetrain = NextMecanum(hardwareMap, mecanumConfig)

To share motors with a drivetrain Mechanism you already have, pass the four NextMotors in front-left, front-right, back-left, back-right order. An optional fifth argument sets manualBrakeMode, which defaults to true.

val drivetrain = NextMecanum(frontLeft, frontRight, backLeft, backRight)

While Pedro is driving manually, the motors brake at zero power if manualBrakeMode is true. The rest of the time, including while following a path, they float.

The last wheel powers NextMecanum applied, normalized to [-1.0, 1.0], as a DoubleArray in front-left, front-right, back-left, back-right order.