View Single Post
  #9   Spotlight this post!  
Unread 01-02-2016, 13:23
wazateer1 wazateer1 is offline
Registered User
FRC #3506 (YETI Robotics)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2013
Location: Charlotte, NC
Posts: 30
wazateer1 is a splendid one to beholdwazateer1 is a splendid one to beholdwazateer1 is a splendid one to beholdwazateer1 is a splendid one to beholdwazateer1 is a splendid one to beholdwazateer1 is a splendid one to beholdwazateer1 is a splendid one to behold
Re: Sub-Class CANTalon to represent 3 motors

Quote:
Originally Posted by Oromus View Post
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
Reply With Quote