View Single Post
  #2   Spotlight this post!  
Unread 07-02-2012, 07:09
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 102
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: 1st Post! ZomB Dashboard Troubles

We ran across this same issue at one point. I don't have the robot in front of me, but I think the solution was to add a line in the robot initialization code to set a initial value for each SmartDashboard key name we wanted to retrieve before we started retrieving it.

Here's a example (from a SimpleRobot based perspective):

Code:
private int shooterSpeed = 0;

public void robotInit() {
  // Tell SmartDashboard to register a "Shooter Speed" key and initial value.
  SmartDashboard.putInt("Shooter Speed", shooterSpeed);
}

public void operatorControl() {

   while (isOperatorControl() && isEnabled()) {

      // Read value of "Shooter Speed" back from the dashboard
      int newSpeed = SmartDashboard.getInt("Shooter Speed", shooterSpeed);

      // If operator wants a new speed, update robot state to accomodate
      if (newSpeed != shooterSpeed) {
        doWhatYouNeedToDoOnASpeedChange(newSpeed);
      }

      Timer.delay(0.01);
   }

}
Reply With Quote