Quote:
Originally Posted by Oromus
If anyone is looking to group together multiple motors under a single Motor object (i.e. three drivetrain motors under one object like OP's code), I'd like to point to a library of 1902's that has a class called MotorGroup. It works like so:
Code:
MotorGroup leftDrive = new MotorGroup(CANTalon.class, 0, 1, 2);
leftDrive.setPower(1);
MotorGroup rightDrive = new MotorGroup(new CANTalon(3), new CANTalon(4));
rightDrive.setPower(-0.5);
MotorGroup is very flexible because it takes any type of Motor and can contain as many motors as you want, so it should help eliminate having to make awkward wrapper classes or mass-call SpeedController.set().
The link to the source file (and the rest of the repo) can be found here.
To get completely back on-topic and to answer the original question, that wrapper class should work fine. My only suggestion would be to not extend CANTalon.
Disclaimer: MotorGroup relies on other parts of the library to exist, so it does not work as-is without changing it not use BCNLib classes.
|
The only problem with that is RobotDrive does not know to call .setPower, it only every calls .set() assuming any class that implements SpeedController uses that method