View Single Post
  #2   Spotlight this post!  
Unread 30-01-2010, 16:12
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: Feeding the Watchdog

Here's basically how the watchdog works. Except in autonomous mode the watchdog must be enabled. It then must be fed every x settings, x is determined with the SetExpiration(numSeconds) function (usually called in the constructor of your robot class). Failure to do so results in your robot being promptly disabled.

To enable the watchdog you can use the function (SetEnabled(true)) and to disable, SetEnabled(false). Following that you must feed it using Feed().

Here's a sample program in C++ (should be quite similar in Java).

Code:
#include "WPILib.h"

class Robot : public SimpleRobot {
	
	Robot(void) {
		GetWatchdog().SetExpiration(0.1); // Must feed watchdog every 100mS
	}
	
	void Autonomous(void) {
		GetWatchdog().SetEnabled(false);
		// Autonomous Code here
	}
	
	void OperatorControl(void) {
		GetWatchdog().SetEnabled(true);
		
		while (IsOperatorControl() && !IsDisabled()) {
			GetWatchdog.Feed();
			
			// Teleop code here
			
			Wait(0.05);
		}
		
	}
 	
}

START_ROBOT_CLASS(Robot);
Sometimes when your camera is booting up or you execute another function that takes a little time, the Dashboard will say the Watchdog is not fed as it hasn't got that far in the program.

According to http://first.wpi.edu/Images/CMS/Firs...va_for_FRC.pdf to equivalent Java functions are:

Code:
// Similar to C++, just note the case.
getWatchdog().setEnabled(true);
getWatchdog().setExpiration(0.1);
getWatchdog().feed();

Last edited by basicxman : 30-01-2010 at 16:18.
Reply With Quote