Since the new 2024 WPILib VS Code I have been struggling to find the replacement for MotorControllerGroup to join two motors on each side for the tank drive. I use CAN ports and mostly SparkMax, but also VictorSPX with the WPI_VictorSPX type. I really need help to find the replacement of the code. On the FRC updates it says about PWMMotorController.addFollower(PWMMotorController) but it doesn’t seem to work, I have tried variants and also doesn’t. Thanks for your understanding.
Just to confirm, you have a PWM controller (VictorSPX) following a CAN controller (SparkMax)? I’m not certain thats a supported architecture.
I personally would try to stick to all the same device for a single mechanism (all SparkMax for example), but if thats not possible for you, then I would at least try to ensure they’re all using the same connectivity.
The good news is that the VictorSPX does support CAN.
If you do have the SPX connected via CAN, then you shouldn’t be using PWMMotorController.
No, sorry I didn’t explained well. We are making the kitbot with only VictorSPX in CAN. And we are using only SparkMax on our main robot in CAN. It’s all updated with the new firmware versions and also all set. The problem I have is with the code, I can’t find the new way to match those controllers with each other for the tankdrive of the kitbot and for the tankdrive of the main robot.
If you have CAN motor controllers that can’t follow each other (e.g., motor controllers from different vendors), you can pass custom setters to this DifferentialDrive constructor overload.
For example:
VictorSPX leftFront = new VictorSPX(0);
VictorSPX leftRear = new SparkMax(1);
VictorSPX rightFront = new VictorSPX(2);
VictorSPX rightRear = new SparkMax(3);
DifferentialDrive drive = new DifferentialDrive(
(double output) -> {
leftFront.set(output);
leftRear.set(output);
},
(double output) -> {
rightFront.set(output);
rightRear.set(output);
});
(I don’t know the exact motor controller APIs, but this should give you an idea.)
Thanks. I just found another solution that is by using the follow command. For example leftrear.follow(leftfront); instead of using the now deprecated MotorControllerGroup(leftrear, leftfront);
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.