How to tankdrive without motorcontrollergroup?

VS Code is telling us that motorcontrollergroup is deprecated, and to use “follow” instead, but tankdrive is supposed to be a method of a DifferentialDrive class object, and DifferentialDrive requires listing motorcontrollergroups as parameters. How do we program tankdrive without motorcontrollergroups?

Sorry if I’m missing something basic here. I really did scour the internet looking for an answer for this first.

The deprecation message for MotorControllerGroup (WPILib API 2024.2.1) explains what to do. The example projects show using PWMMotorController.addFollower() as well.

Once you have following set up, you just need to pass one motor controller per side. You can either pass the objects directly (for now) or use method references (DifferentialDrive(left::set, right::set)).

1 Like

you can set all the motors and use the “.follow” command at roboinit for example
just like this: FrontLeft.follow(BackLeft);

Ah, so I was wrong about DifferentialDrive requiring MotorControllerGroups; you can just enter motor controllers there. Thanks for your help!

Also deprecation does not mean actual removal. If you REALLY want to use it, you can do so if the class is not removed yet. And if you’re annoyed by the VSCode “crossing” the lines, just put the annotation that would suppress the removal warnings.
We use some of the libraries that are slated for deprecation as well that way, simply because we like them :slight_smile: And as part of the summer projects, when we’re not in a middle of the build season, we learn how to use the new way of doing things properly.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.