View Single Post
  #6   Spotlight this post!  
Unread 02-12-2015, 09:19 AM
Ken Streeter's Avatar
Ken Streeter Ken Streeter is offline
Let the MAYHEM begin!
FRC #1519 (Mechanical Mayhem)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Team: Milford, NH; Me: Bedford, NH
Posts: 468
Ken Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond repute
Re: RoboRio Losing WPILib Preferences

Quote:
Originally Posted by kylelanman View Post
We are currently using Preferences::GetInstance().Gettype("key", default) in the constructor of static instances of Subsystems.
We addressed this issue in our code by moving the calls to Preferences.getInstance().GetFoo() to not be in the constructors of our subsystems, but instead in an "init()" method for the subsystem. The "init()" method is called out of robotInit(), which is quite later in the startup sequence.

Below is our current robotInit() which shows the calls to init() in our subsystems that have some "late initialization" needs.

Code:
    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {
    	
      System.out.println("robotInit");
      SmartDashboard.putString("Auto Prog",  "Initializing...");
      
      DriverStation.reportError("About to construct Autonomous Subsystem... \n", false);      
	  autonomous = new Autonomous();
      DriverStation.reportError("Done constructing Autonomous Subsystem.\n", false);
      
      DriverStation.reportError("About to construct OI... \n", false);      
	  oi = new OI();
      DriverStation.reportError("Done constructing OI.\n", false);
      
      // initialize the subsystems that need it
      drive.init();
      elevator.init();
      
      // instantiate the command used for the autonomous period
      autonomousCommand = new RunAutonomous();
      DriverStation.reportError("Constructed auto command.\n", false);
      SmartDashboard.putString("Auto Prog",  "Done.");
      Autonomous.updateDashboard();
    }
__________________
Ken Streeter - Team 1519 - Mechanical Mayhem (Milford Area Youth Homeschoolers Enriching Minds)
2015 NE District Winners with 195 & 2067, 125 & 1786, 230 & 4908, and 95 & 1307
2013 World Finalists & Archimedes Division Winners with 33 & 469
2013 & 2012 North Carolina Regional Winners with teams 435 & 4828 and 1311 & 2642
2011, 2010, 2006 Granite State Regional Winners with teams 175 & 176, 1073 & 1058, and 1276 & 133
Team 1519 Video Gallery - including Chairman's Video, and the infamous "Speed Racer!"
Reply With Quote