![]() |
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 { |
Re: Sub-Class CANTalon to represent 3 motors
Quote:
Edit: SpeedController |
Quote:
|
Re: Sub-Class CANTalon to represent 3 motors
Quote:
|
Re: Sub-Class CANTalon to represent 3 motors
Quote:
Quote:
Ultimately, it comes to not having to call the super constructor, and I will go with notmattlythgoe that directly implementing SpeedController is better |
Re: Sub-Class CANTalon to represent 3 motors
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);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. |
Re: Sub-Class CANTalon to represent 3 motors
CanTalons have a Follower mode, where set() takes the CAN ID of a talon to constantly copy speed from. That way, you only need to pass 2 "master" talons to RobotDrive and have the rest copy those.
|
Re: Sub-Class CANTalon to represent 3 motors
Quote:
http://www.ctr-electronics.com/talon...ical_resources |
Re: Sub-Class CANTalon to represent 3 motors
Quote:
|
Re: Sub-Class CANTalon to represent 3 motors
Quote:
|
Re: Sub-Class CANTalon to represent 3 motors
Quote:
|
Re: Sub-Class CANTalon to represent 3 motors
The slave/follower features of the Talon SRX are reliable. Many teams were successful using this feature last season. You can read more about it in the Talon SRX Software Reference manual.
Check out section 16.33 for a specific example of a solution to your OP. http://www.ctr-electronics.com/talon...ical_resources |
Thanks all!
|
| All times are GMT -5. The time now is 08:25 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi