Go to Post I've worked with space based navigation and lever arms and planes and Kalman filters. .. and I have never, ever once considered looking up to navigate. - purduephotog [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
  #4   Spotlight this post!  
Unread 09-02-2014, 10:18
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 330
fovea1959 will become famous soon enough
Re: What to put in disabled() and robotinit()?

we tapped into robotInit and made sure a corresponding (possibly empty) robotInit() gets called in every subsystem.

did the same for the autonomousInit(), disabledInit(), testInit(), teleopInit(): they all call a modeChanged() method in Robot that's calls a modeChanged() method in every subsystem.

same for all the *periodic() functions: they all call a method in Robot that calls a periodic() method in every subsystem (which take care of subsystem specific network table puts). The Robot.periodic() takes care of robot-wide telemetry (we have a "record network tables to disk" app on our driver station).

Robot has a getCurrentMode() and getPreviousMode() for everyone to use.

If we add a subsystem to the robot, we (just once) make sure it has empty robotInit(), modeChanged(), and periodic() methods, and we make sure that they get added to the list of called routines in Robot.java.

It seems like overkill, but the net effect is that *all* code for a subsystem is either in the subsystem or it's commands: none of it is off to the side in Robot.java. Consistency between subsystems cuts down on silly mistakes. Not having to remember to look in Robot.java for code that does subsystem-specific initializations or periodic() processing; cuts down on silly mistakes.

for example, in our drive subsystem (I'm paraphrasing...)
Code:
public void modeChanged() {
 if (Robot.getCurrentMode() == RobotMode.TELEOP) {
  // drive subsystem specific set up at start of Teleop
  setReverseMode(false);
 }
}
This might be overengineering, but we do like the consistency and modularity.
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 09:31.

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