Hi
I am an experienced programmer, but a newbie to FRC. Apologize if this is a silly question. We are using Java, with WPILibJ.
We have just built a prototype robot with 6 talons, three per side driving a single shaft.
I used the IE web user interface to set the IDs for each talon and run a self test on them - all worked fine. I can blink the light of each talon to ensure I have the IDs correct (checked many times).
I set up a drivetrain class extending SubSystem that encapsulated the creation of the talons, a RobotDrive class for driving, then a Command that called the tankDrive() on the RobotDrive.
The problem is that only one of the talons would enable when the drive station is switched to Teleop mode. Web UI self test on the other talons would still work, but show them as not enabled, and their lights would stay flashing orange.
After considerable messing about, I found that if I create CANTalon objects as member variables of the base Robot class and initialize them with the declaration, they all get enabled correctly. Trying to create them as member variables of the SubSystem class, and they do not enable, but I can create them again in SubSystem
While we now have it working, this seems very clumsy to me and makes me wonder if I have either completely mis-understood how the SubSystem class is supposed to work, or if there is a fundamental issue with setting up talons in classes other than the base robot class.
Clearly initializing them as member variables of the Robot class means they get created as soon as the Robot class is instantiated (even before its constructor is called).
I had a look at the source code for the RobotBase class in WPILibJ:
and it looks like there is very little code executed after the Robot class is instantiated before control is handed of to the main scheduling loop.
Is that going to be necessary for other Talons and anything else we have on the CAN bus going forward?
Regards
David