Go to Post The robotics, strategics, and technology make up the higher wavelengths, the adrenaline of competition the midband, and the low frequencies that pull at the heart, well that's the people. - John Wanninger [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 01-02-2016, 11:49
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
Sub-Class CANTalon to represent 3 motors

Hi everybody,

This year our team is going with a 6-motor drive train, and our programming team came across the problem of RobotDrive only having two motor and four motor constructors. We only have a tank drive, but I personally like using RobotDrive because of the ease of switching between Tank drive and arcade drive. I saw an old post from 2010 mentioning adding a whole new constructor to the RobotDrive file itself, but I wanted to take a different approach.

Would there be anything wrong with writing our own sub-class of CANTalon (or any class that implemented SpeedController, we are just using CANTalons), whose constructor creates three instances of CANTalons, and overrides .set() by calling .set() on each of the Talons, then constructing RobotDrive with two objects of this class, one for each side of the drive train?

Code outline (not guaranteed to compile )

Code:
public class ThreeMotorGearbox extends CANTalon {
    public CANTalon talon1, talon2, talon3;

    public ThreeMotorGearbox(int talon1id, int talon2id, int talon3id) {
        super(talon1id); //We will be overriding all the important methods, anyway)
        talon1 = new CANTalon(talon1id);
        talon2 = new CANTalon(talon2id);
        talon3 = new CANTalon(talon3id);
    }

    @Override
    public void set(double speed) {
        talon1.set(speed);
        talon2.set(speed);
        talon3.set(speed);
    }
}

//Somewhere in the code
public ThreeMotorGearbox leftSide, rightSide;
public RobotDrive driveTrain;

leftSide = new ThreeMotorGearbox(1,2,3);
rightSide = new ThreeMotorGearbox(4,5,6);
driveTrain = new RobotDrive(leftSide, rightSide);
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:42.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi